lkml.org 
[lkml]   [2021]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v3 5/6] usb: Iterator for ports
From
Date
On 3/31/21 11:37 PM, Heikki Krogerus wrote:
> On Wed, Mar 31, 2021 at 09:41:22AM -0700, Guenter Roeck wrote:
>>> diff --git a/include/linux/usb.h b/include/linux/usb.h
>>> index ddd2f5b2a2827..ebcd03d835d04 100644
>>> --- a/include/linux/usb.h
>>> +++ b/include/linux/usb.h
>>> @@ -882,6 +882,15 @@ extern struct usb_host_interface *usb_find_alt_setting(
>>> unsigned int iface_num,
>>> unsigned int alt_num);
>>>
>>> +#ifdef CONFIG_USB
>>
>> #if IS_ENABLED(CONFIG_USB)
>
Note that IS_REACHABLE(), as you ended up using, has a slightly different
semantics.

With IS_ENABLED(), one still has to ensure, via config file dependencies,
that the code using the API is reachable. That would be something like
depends on USB || USB=n
This dependency ensures that the code using the API code is not built
into the kernel if USB is built as module. In most cases this reflects
the intended use case.

IS_REACHABLE(), on the other side, will disable the API if USB is built
as module and the calling code is built into the kernel. This can have
unexpected results and should be used with caution.

Thanks,
Guenter

> Thanks Guenter.
>
>>> +int usb_for_each_port(void *data, int (*fn)(struct device *, void *));
>>> +#else
>>> +static inline int usb_for_each_port(void *data, int (*fn)(struct device *, void *))
>>> +{
>>> + return 0;
>>> +}
>>> +#endif
>>> +
>>> /* port claiming functions */
>>> int usb_hub_claim_port(struct usb_device *hdev, unsigned port1,
>>> struct usb_dev_state *owner);
>>>
>

\
 
 \ /
  Last update: 2021-04-05 21:26    [W:0.051 / U:1.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site