* [PATCH] Bluetooth: btusb: avoid unused function warning
@ 2019-09-18 19:59 Arnd Bergmann
2019-09-19 7:32 ` Marcel Holtmann
2019-09-27 6:43 ` Marcel Holtmann
0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2019-09-18 19:59 UTC (permalink / raw)
To: Marcel Holtmann, Johan Hedberg
Cc: Arnd Bergmann, Alex Lu, Matthias Kaehlcke, Rajat Jain,
Raghuram Hegde, linux-bluetooth, linux-kernel
The btusb_rtl_cmd_timeout() function is used inside of an
ifdef, leading to a warning when this part is hidden
from the compiler:
drivers/bluetooth/btusb.c:530:13: error: unused function 'btusb_rtl_cmd_timeout' [-Werror,-Wunused-function]
Use an IS_ENABLED() check instead so the compiler can see
the code and then discard it silently.
Fixes: d7ef0d1e3968 ("Bluetooth: btusb: Use cmd_timeout to reset Realtek device")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/bluetooth/btusb.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index a9c35ebb30f8..23e606aaaea4 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3807,8 +3807,8 @@ static int btusb_probe(struct usb_interface *intf,
btusb_check_needs_reset_resume(intf);
}
-#ifdef CONFIG_BT_HCIBTUSB_RTL
- if (id->driver_info & BTUSB_REALTEK) {
+ if (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) &&
+ (id->driver_info & BTUSB_REALTEK)) {
hdev->setup = btrtl_setup_realtek;
hdev->shutdown = btrtl_shutdown_realtek;
hdev->cmd_timeout = btusb_rtl_cmd_timeout;
@@ -3819,7 +3819,6 @@ static int btusb_probe(struct usb_interface *intf,
*/
set_bit(BTUSB_WAKEUP_DISABLE, &data->flags);
}
-#endif
if (id->driver_info & BTUSB_AMP) {
/* AMP controllers do not support SCO packets */
--
2.20.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Bluetooth: btusb: avoid unused function warning
2019-09-18 19:59 [PATCH] Bluetooth: btusb: avoid unused function warning Arnd Bergmann
@ 2019-09-19 7:32 ` Marcel Holtmann
2019-09-19 12:26 ` Arnd Bergmann
2019-09-27 6:43 ` Marcel Holtmann
1 sibling, 1 reply; 5+ messages in thread
From: Marcel Holtmann @ 2019-09-19 7:32 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Johan Hedberg, Alex Lu, Matthias Kaehlcke, Rajat Jain,
Raghuram Hegde, linux-bluetooth, linux-kernel
Hi Arnd,
> The btusb_rtl_cmd_timeout() function is used inside of an
> ifdef, leading to a warning when this part is hidden
> from the compiler:
>
> drivers/bluetooth/btusb.c:530:13: error: unused function 'btusb_rtl_cmd_timeout' [-Werror,-Wunused-function]
>
> Use an IS_ENABLED() check instead so the compiler can see
> the code and then discard it silently.
>
> Fixes: d7ef0d1e3968 ("Bluetooth: btusb: Use cmd_timeout to reset Realtek device")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/bluetooth/btusb.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index a9c35ebb30f8..23e606aaaea4 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -3807,8 +3807,8 @@ static int btusb_probe(struct usb_interface *intf,
> btusb_check_needs_reset_resume(intf);
> }
>
> -#ifdef CONFIG_BT_HCIBTUSB_RTL
> - if (id->driver_info & BTUSB_REALTEK) {
> + if (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) &&
> + (id->driver_info & BTUSB_REALTEK)) {
> hdev->setup = btrtl_setup_realtek;
> hdev->shutdown = btrtl_shutdown_realtek;
> hdev->cmd_timeout = btusb_rtl_cmd_timeout;
> @@ -3819,7 +3819,6 @@ static int btusb_probe(struct usb_interface *intf,
> */
> set_bit(BTUSB_WAKEUP_DISABLE, &data->flags);
> }
> -#endif
I prefer that we stick another ifdef around the btusb_rtl_cmd_timeout function since that is how we did it for the other vendors as well.
However I start to wonder if we need all these vendor ifdef anyway. The vendor specific functions should turn into empty stubs if their support is not selected.
Regards
Marcel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Bluetooth: btusb: avoid unused function warning
2019-09-19 7:32 ` Marcel Holtmann
@ 2019-09-19 12:26 ` Arnd Bergmann
2019-09-19 12:36 ` Marcel Holtmann
0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2019-09-19 12:26 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Johan Hedberg, Alex Lu, Matthias Kaehlcke, Rajat Jain,
Raghuram Hegde, Bluez mailing list, linux-kernel
On Thu, Sep 19, 2019 at 9:32 AM Marcel Holtmann <marcel@holtmann.org> wrote:
>
> > The btusb_rtl_cmd_timeout() function is used inside of an
> > ifdef, leading to a warning when this part is hidden
> > from the compiler:
> >
> > drivers/bluetooth/btusb.c:530:13: error: unused function 'btusb_rtl_cmd_timeout' [-Werror,-Wunused-function]
> >
> > Use an IS_ENABLED() check instead so the compiler can see
> > the code and then discard it silently.
> >
> > Fixes: d7ef0d1e3968 ("Bluetooth: btusb: Use cmd_timeout to reset Realtek device")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> > drivers/bluetooth/btusb.c | 5 ++---
> > 1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> > index a9c35ebb30f8..23e606aaaea4 100644
> > --- a/drivers/bluetooth/btusb.c
> > +++ b/drivers/bluetooth/btusb.c
> > @@ -3807,8 +3807,8 @@ static int btusb_probe(struct usb_interface *intf,
> > btusb_check_needs_reset_resume(intf);
> > }
> >
> > -#ifdef CONFIG_BT_HCIBTUSB_RTL
> > - if (id->driver_info & BTUSB_REALTEK) {
> > + if (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) &&
> > + (id->driver_info & BTUSB_REALTEK)) {
> > hdev->setup = btrtl_setup_realtek;
> > hdev->shutdown = btrtl_shutdown_realtek;
> > hdev->cmd_timeout = btusb_rtl_cmd_timeout;
> > @@ -3819,7 +3819,6 @@ static int btusb_probe(struct usb_interface *intf,
> > */
> > set_bit(BTUSB_WAKEUP_DISABLE, &data->flags);
> > }
> > -#endif
>
> I prefer that we stick another ifdef around the btusb_rtl_cmd_timeout function since that
> is how we did it for the other vendors as well.
Ok. Can you just commit that with 'Reported-by: Arnd Bergmann <arnd@arndb.de>'?
> However I start to wonder if we need all these vendor ifdef anyway. The vendor specific
> functions should turn into empty stubs if their support is not selected.
It just wastes a little bit of object code space, which my approach
above avoids.
I guess one could also be clever and redefine those macros like
#define BTUSB_REALTEK (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) ? 0x20000 : 0)
so the if() section gets silently dropped, in addition to treating
zero like BTUSB_IGNORE.
Arnd
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Bluetooth: btusb: avoid unused function warning
2019-09-19 12:26 ` Arnd Bergmann
@ 2019-09-19 12:36 ` Marcel Holtmann
0 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2019-09-19 12:36 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Johan Hedberg, Alex Lu, Matthias Kaehlcke, Rajat Jain,
Raghuram Hegde, Bluez mailing list, linux-kernel
Hi Arnd,
>>> The btusb_rtl_cmd_timeout() function is used inside of an
>>> ifdef, leading to a warning when this part is hidden
>>> from the compiler:
>>>
>>> drivers/bluetooth/btusb.c:530:13: error: unused function 'btusb_rtl_cmd_timeout' [-Werror,-Wunused-function]
>>>
>>> Use an IS_ENABLED() check instead so the compiler can see
>>> the code and then discard it silently.
>>>
>>> Fixes: d7ef0d1e3968 ("Bluetooth: btusb: Use cmd_timeout to reset Realtek device")
>>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>>> ---
>>> drivers/bluetooth/btusb.c | 5 ++---
>>> 1 file changed, 2 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
>>> index a9c35ebb30f8..23e606aaaea4 100644
>>> --- a/drivers/bluetooth/btusb.c
>>> +++ b/drivers/bluetooth/btusb.c
>>> @@ -3807,8 +3807,8 @@ static int btusb_probe(struct usb_interface *intf,
>>> btusb_check_needs_reset_resume(intf);
>>> }
>>>
>>> -#ifdef CONFIG_BT_HCIBTUSB_RTL
>>> - if (id->driver_info & BTUSB_REALTEK) {
>>> + if (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) &&
>>> + (id->driver_info & BTUSB_REALTEK)) {
>>> hdev->setup = btrtl_setup_realtek;
>>> hdev->shutdown = btrtl_shutdown_realtek;
>>> hdev->cmd_timeout = btusb_rtl_cmd_timeout;
>>> @@ -3819,7 +3819,6 @@ static int btusb_probe(struct usb_interface *intf,
>>> */
>>> set_bit(BTUSB_WAKEUP_DISABLE, &data->flags);
>>> }
>>> -#endif
>>
>> I prefer that we stick another ifdef around the btusb_rtl_cmd_timeout function since that
>> is how we did it for the other vendors as well.
>
> Ok. Can you just commit that with 'Reported-by: Arnd Bergmann <arnd@arndb.de>'?
>
>> However I start to wonder if we need all these vendor ifdef anyway. The vendor specific
>> functions should turn into empty stubs if their support is not selected.
>
> It just wastes a little bit of object code space, which my approach
> above avoids.
>
> I guess one could also be clever and redefine those macros like
>
> #define BTUSB_REALTEK (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) ? 0x20000 : 0)
>
> so the if() section gets silently dropped, in addition to treating
> zero like BTUSB_IGNORE.
we could do that as well. I just want it to be consistent in the code.
Regards
Marcel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Bluetooth: btusb: avoid unused function warning
2019-09-18 19:59 [PATCH] Bluetooth: btusb: avoid unused function warning Arnd Bergmann
2019-09-19 7:32 ` Marcel Holtmann
@ 2019-09-27 6:43 ` Marcel Holtmann
1 sibling, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2019-09-27 6:43 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Johan Hedberg, Alex Lu, Matthias Kaehlcke, Rajat Jain,
Raghuram Hegde, linux-bluetooth, linux-kernel
Hi Arnd,
> The btusb_rtl_cmd_timeout() function is used inside of an
> ifdef, leading to a warning when this part is hidden
> from the compiler:
>
> drivers/bluetooth/btusb.c:530:13: error: unused function 'btusb_rtl_cmd_timeout' [-Werror,-Wunused-function]
>
> Use an IS_ENABLED() check instead so the compiler can see
> the code and then discard it silently.
>
> Fixes: d7ef0d1e3968 ("Bluetooth: btusb: Use cmd_timeout to reset Realtek device")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/bluetooth/btusb.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-09-27 6:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-18 19:59 [PATCH] Bluetooth: btusb: avoid unused function warning Arnd Bergmann
2019-09-19 7:32 ` Marcel Holtmann
2019-09-19 12:26 ` Arnd Bergmann
2019-09-19 12:36 ` Marcel Holtmann
2019-09-27 6:43 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).