mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 1/1] mux: consumer: Add dummy functions for !CONFIG_MULTIPLEXER case
@ 2017-07-08 18:12 sathyanarayanan.kuppuswamy
  2017-07-08 21:22 ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: sathyanarayanan.kuppuswamy @ 2017-07-08 18:12 UTC (permalink / raw)
  To: peda; +Cc: linux-kernel, sathyaosid, Kuppuswamy Sathyanarayanan

From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>

Add dummy functions to avoid compile time issues when CONFIG_MULTIPLEXER
is not enabled.

Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
---
 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;
+}
+
+int __must_check mux_control_select(struct mux_control *mux,
+				    unsigned int state)
+{
+	return -ENODEV;
+}
+
+int __must_check mux_control_try_select(struct mux_control *mux,
+					unsigned int state)
+{
+	return -ENODEV;
+}
+
+int mux_control_deselect(struct mux_control *mux)
+{
+	return -ENODEV;
+}
+
+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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] mux: consumer: Add dummy functions for !CONFIG_MULTIPLEXER case
  2017-07-08 18:12 [PATCH v2 1/1] mux: consumer: Add dummy functions for !CONFIG_MULTIPLEXER case sathyanarayanan.kuppuswamy
@ 2017-07-08 21:22 ` Andy Shevchenko
  2017-07-09  6:59   ` Peter Rosin
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2017-07-08 21:22 UTC (permalink / raw)
  To: Kuppuswamy Sathyanarayanan
  Cc: Peter Rosin, linux-kernel, Sathyanarayanan Kuppuswamy Natarajan

On Sat, Jul 8, 2017 at 9:12 PM,
<sathyanarayanan.kuppuswamy@linux.intel.com> wrote:
> From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>
> 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 <sathyanarayanan.kuppuswamy@linux.intel.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] mux: consumer: Add dummy functions for !CONFIG_MULTIPLEXER case
  2017-07-08 21:22 ` Andy Shevchenko
@ 2017-07-09  6:59   ` Peter Rosin
  2017-07-09  7:42     ` Kuppuswamy, Sathyanarayanan
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Rosin @ 2017-07-09  6:59 UTC (permalink / raw)
  To: Andy Shevchenko, Kuppuswamy Sathyanarayanan
  Cc: linux-kernel, Sathyanarayanan Kuppuswamy Natarajan

On 2017-07-08 23:22, Andy Shevchenko wrote:
> On Sat, Jul 8, 2017 at 9:12 PM,
> <sathyanarayanan.kuppuswamy@linux.intel.com> wrote:
>> From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>>
>> 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).

BTW, is ENODEV correct for this situation? I have this nagging feeling
that ENODEV is over-used?

And again, all these stubs should all be inlines, or things will break it
this file is included more than once.

>> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>> ---
>>  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?

Since it will presumably be difficult to obtain a mux_control
w/o the mux-core being present, it doesn't matter much what
most of these stubs return.

For this stub, 0 is perhaps best, since the kernel-doc for
mux_control_states mentions nothing about any error possibility.

>> +}
>> +
>> +int __must_check mux_control_select(struct mux_control *mux,
>> +                                   unsigned int state)
>> +{
>> +       return -ENODEV;
> 
> return 0; ?

Maybe. But it doesn't matter much, but in this case the consumer must
handle errors. See above.

>> +}
>> +
>> +int __must_check mux_control_try_select(struct mux_control *mux,
>> +                                       unsigned int state)
>> +{
>> +       return -ENODEV;
>> +}
> 
> return 0; ?

Maybe. But it doesn't matter much, but in this case the consumer must
handle errors. See above.

>> +
>> +int mux_control_deselect(struct mux_control *mux)
>> +{
>> +       return -ENODEV;
>> +}
> 
> return 0; ?

Probably. See above.

Cheers,
peda

>> +
>> +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
>>
> 
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] mux: consumer: Add dummy functions for !CONFIG_MULTIPLEXER case
  2017-07-09  6:59   ` Peter Rosin
@ 2017-07-09  7:42     ` Kuppuswamy, Sathyanarayanan
  0 siblings, 0 replies; 4+ messages in thread
From: Kuppuswamy, Sathyanarayanan @ 2017-07-09  7:42 UTC (permalink / raw)
  To: Peter Rosin, Andy Shevchenko, Kuppuswamy Sathyanarayanan; +Cc: linux-kernel

Hi,


On 7/8/2017 11:59 PM, Peter Rosin wrote:
> On 2017-07-08 23:22, Andy Shevchenko wrote:
>> On Sat, Jul 8, 2017 at 9:12 PM,
>> <sathyanarayanan.kuppuswamy@linux.intel.com> wrote:
>>> From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>>>
>>> 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).
> BTW, is ENODEV correct for this situation? I have this nagging feeling
> that ENODEV is over-used?
I used ENODEV to signify that the MUX device is not available/enabled.
>
> And again, all these stubs should all be inlines, or things will break it
> this file is included more than once.
I will fix the inline problem in next version.
>
>>> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>>> ---
>>>   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?
> Since it will presumably be difficult to obtain a mux_control
> w/o the mux-core being present, it doesn't matter much what
> most of these stubs return.
>
> For this stub, 0 is perhaps best, since the kernel-doc for
> mux_control_states mentions nothing about any error possibility.
Agreed. Since it returns the total number of MUX states, 0 seems to more
appropriate. I can fix it in next version.
>
>>> +}
>>> +
>>> +int __must_check mux_control_select(struct mux_control *mux,
>>> +                                   unsigned int state)
>>> +{
>>> +       return -ENODEV;
>> return 0; ?
> Maybe. But it doesn't matter much, but in this case the consumer must
> handle errors. See above.
>
>>> +}
>>> +
>>> +int __must_check mux_control_try_select(struct mux_control *mux,
>>> +                                       unsigned int state)
>>> +{
>>> +       return -ENODEV;
>>> +}
>> return 0; ?
> Maybe. But it doesn't matter much, but in this case the consumer must
> handle errors. See above.
>
>>> +
>>> +int mux_control_deselect(struct mux_control *mux)
>>> +{
>>> +       return -ENODEV;
>>> +}
>> return 0; ?
> Probably. See above.
>
> Cheers,
> peda
>
>>> +
>>> +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
>>>
>>
>>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-07-09  7:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-08 18:12 [PATCH v2 1/1] mux: consumer: Add dummy functions for !CONFIG_MULTIPLEXER case sathyanarayanan.kuppuswamy
2017-07-08 21:22 ` Andy Shevchenko
2017-07-09  6:59   ` Peter Rosin
2017-07-09  7:42     ` Kuppuswamy, Sathyanarayanan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®