Skip to contentSkip to conversation

Bluetooth: btusb: avoid unused function warning

PATCH In review Arnd Bergmann 2 participants 5 messages Sep 18, 2019 – Sep 27, 2019 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: btusb: avoid unused function warning

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")
---
 drivers/bluetooth/btusb.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/bluetooth/btusb.c +2 -3
index a9c35ebb30f8..23e606aaaea4 100644
@@ -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 */
Signature · 1 line
2.20.0
maintainer
#1 lore raw

Hi Arnd,

Quoted 31 lines

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")

---
drivers/bluetooth/btusb.c | 5 ++---

1 file changed, 2 insertions(+), 3 deletions(-)
drivers/bluetooth/btusb.c +2 -2
index a9c35ebb30f8..23e606aaaea4 100644
@@ -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;

drivers/bluetooth/btusb.c static int btusb_probe(struct usb_interface *intf, · line 3822

Quoted 4 lines
drivers/bluetooth/btusb.c +0 -1
@@ -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

#2 lore raw
Quoted 24 lines · Marcel Holtmann
Quoted 24 lines

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")

---
drivers/bluetooth/btusb.c | 5 ++---

1 file changed, 2 insertions(+), 3 deletions(-)
drivers/bluetooth/btusb.c +0 -0
index a9c35ebb30f8..23e606aaaea4 100644
@@ -3807,8 +3807,8 @@ static int btusb_probe(struct usb_interface *intf,
              btusb_check_needs_reset_resume(intf);
      }
 
Quoted 15 lines

drivers/bluetooth/btusb.c static int btusb_probe(struct usb_interface *intf, · line 3822

Quoted 12 lines
drivers/bluetooth/btusb.c +2 -3
-#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 <[email protected]>'?

Quoted 2 lines

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

maintainer
#3 lore raw

Hi Arnd,

Quoted 47 lines
Quoted 23 lines
Quoted 23 lines

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")

---
drivers/bluetooth/btusb.c | 5 ++---

1 file changed, 2 insertions(+), 3 deletions(-)
drivers/bluetooth/btusb.c +0 -0
index a9c35ebb30f8..23e606aaaea4 100644
@@ -3807,8 +3807,8 @@ static int btusb_probe(struct usb_interface *intf,
             btusb_check_needs_reset_resume(intf);
     }
 
Quoted 15 lines

drivers/bluetooth/btusb.c static int btusb_probe(struct usb_interface *intf, · line 3822

Quoted 12 lines
drivers/bluetooth/btusb.c +2 -3
-#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 <[email protected]>'?

Quoted 2 lines

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.

Quoted 6 lines

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

maintainer
#4 lore raw
In reply to Arnd Bergmann

Hi Arnd,

Quoted 6 lines

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]

Quoted 8 lines

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")

---
drivers/bluetooth/btusb.c | 5 ++---

1 file changed, 2 insertions(+), 3 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel