Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751864AbdGHVWu (ORCPT ); Sat, 8 Jul 2017 17:22:50 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:33330 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751021AbdGHVWs (ORCPT ); Sat, 8 Jul 2017 17:22:48 -0400 MIME-Version: 1.0 In-Reply-To: <83ff1554464c781df142117ed30430476ec73634.1499537263.git.sathyanarayanan.kuppuswamy@linux.intel.com> References: <83ff1554464c781df142117ed30430476ec73634.1499537263.git.sathyanarayanan.kuppuswamy@linux.intel.com> From: Andy Shevchenko Date: Sun, 9 Jul 2017 00:22:47 +0300 Message-ID: Subject: Re: [PATCH v2 1/1] mux: consumer: Add dummy functions for !CONFIG_MULTIPLEXER case To: Kuppuswamy Sathyanarayanan Cc: Peter Rosin , "linux-kernel@vger.kernel.org" , Sathyanarayanan Kuppuswamy Natarajan Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2464 Lines: 95 On Sat, Jul 8, 2017 at 9:12 PM, wrote: > From: Kuppuswamy Sathyanarayanan > > Add dummy functions to avoid compile time issues when CONFIG_MULTIPLEXER > is not enabled. > I don't think the error return code is okay to all of them. The return value should be choosen carefully (for some functions it's okay IMO to return 0). > Signed-off-by: Kuppuswamy Sathyanarayanan > --- > include/linux/mux/consumer.h | 38 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 38 insertions(+) > > Changes since v1: > * Changed #ifdef to #if IS_ENABLED. > > diff --git a/include/linux/mux/consumer.h b/include/linux/mux/consumer.h > index 5577e1b..df78988 100644 > --- a/include/linux/mux/consumer.h > +++ b/include/linux/mux/consumer.h > @@ -16,6 +16,7 @@ > struct device; > struct mux_control; > > +#if IS_ENABLED(CONFIG_MULTIPLEXER) > unsigned int mux_control_states(struct mux_control *mux); > int __must_check mux_control_select(struct mux_control *mux, > unsigned int state); > @@ -29,4 +30,41 @@ void mux_control_put(struct mux_control *mux); > struct mux_control *devm_mux_control_get(struct device *dev, > const char *mux_name); > > +#else > +unsigned int mux_control_states(struct mux_control *mux) > +{ > + return -ENODEV; Peter, is here we are obliged to return error code in such case? > +} > + > +int __must_check mux_control_select(struct mux_control *mux, > + unsigned int state) > +{ > + return -ENODEV; return 0; ? > +} > + > +int __must_check mux_control_try_select(struct mux_control *mux, > + unsigned int state) > +{ > + return -ENODEV; > +} return 0; ? > + > +int mux_control_deselect(struct mux_control *mux) > +{ > + return -ENODEV; > +} return 0; ? > + > +struct mux_control *mux_control_get(struct device *dev, const char *mux_name) > +{ > + return ERR_PTR(-ENODEV); > +} > + > +void mux_control_put(struct mux_control *mux) {} > + > +struct mux_control *devm_mux_control_get(struct device *dev, > + const char *mux_name) > +{ > + return ERR_PTR(-ENODEV); > +} > +#endif > + > #endif /* _LINUX_MUX_CONSUMER_H */ > -- > 2.7.4 > -- With Best Regards, Andy Shevchenko