bluetooth: hci_h5: avoid unused variable warnings
PATCH 1/1 bluetooth: hci_h5: avoid unused variable warnings
When CONFIG_BT_HCIUART_RTL is disabled, the hci_h5 driver produces a build warning because of an incorrect set of #ifdef guards:
drivers/bluetooth/hci_h5.c:920:22: error: 'rtl_vnd' defined but not used [-Werror=unused-variable]
Replacing the #ifdef with an IS_ENABLED() check shuts up the error and simplifies the logic.
--- drivers/bluetooth/hci_h5.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/bluetooth/hci_h5.c +3 -7
@@ -841,7 +841,6 @@ static void h5_serdev_remove(struct serdev_device *serdev)hci_uart_unregister_device (&h5->serdev_hu); } -#ifdef CONFIG_BT_HCIUART_RTL static int h5_btrtl_setup (struct h5 *h5) {struct btrtl_device_info *btrtl_dev;
@@ -923,24 +922,21 @@ static struct h5_vnd rtl_vnd = { .close = h5_btrtl_close, .acpi_gpio_map = acpi_btrtl_gpios, }; -#endif -#ifdef CONFIG_ACPI static const struct acpi_device_id h5_acpi_match[] = { -#ifdef CONFIG_BT_HCIUART_RTL {"OBDA8723" , (kernel_ulong_t)&rtl_vnd }, -#endif { }, };MODULE_DEVICE_TABLE (acpi, h5_acpi_match); -#endif static struct serdev_device_driver h5_serdev_driver = { .probe = h5_serdev_probe, .remove = h5_serdev_remove, .driver = { .name ="hci_uart_h5" , - .acpi_match_table =ACPI_PTR (h5_acpi_match), + .acpi_match_table = (IS_ENABLED (CONFIG_BT_HCIUART_RTL ) && +IS_ENABLED (CONFIG_ACPI )) ? + h5_acpi_match :0 , }, };
Signature · 1 line
2.18.0
Quoted 9 lines · Arnd Bergmann
When
CONFIG_BT_HCIUART_RTLis disabled, thehci_h5driver produces a build warning because of an incorrect set of #ifdef guards:
drivers/bluetooth/hci_h5.c:920:22: error: 'rtl_vnd' defined but not used [-Werror=unused-variable]Replacing the #ifdef with an
IS_ENABLED()check shuts up the error and simplifies the logic.Signed-off-by Arnd Bergmann <[email protected]>
-Kees
Quoted 47 lines
--- drivers/bluetooth/hci_h5.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)drivers/bluetooth/hci_h5.c +3
-8@@ -841,7 +841,6 @@ static void h5_serdev_remove(struct serdev_device *serdev)hci_uart_unregister_device (&h5->serdev_hu); } -#ifdef CONFIG_BT_HCIUART_RTL static int h5_btrtl_setup (struct h5 *h5) {struct btrtl_device_info *btrtl_dev;@@ -923,24 +922,21 @@ static struct h5_vnd rtl_vnd = { .close = h5_btrtl_close, .acpi_gpio_map = acpi_btrtl_gpios, }; -#endif -#ifdef CONFIG_ACPI static const struct acpi_device_id h5_acpi_match[] = { -#ifdef CONFIG_BT_HCIUART_RTL {"OBDA8723" , (kernel_ulong_t)&rtl_vnd }, -#endif { }, };MODULE_DEVICE_TABLE (acpi, h5_acpi_match); -#endif static struct serdev_device_driver h5_serdev_driver = { .probe = h5_serdev_probe, .remove = h5_serdev_remove, .driver = { .name ="hci_uart_h5" , - .acpi_match_table =ACPI_PTR (h5_acpi_match), + .acpi_match_table = (IS_ENABLED (CONFIG_BT_HCIUART_RTL ) && +IS_ENABLED (CONFIG_ACPI )) ? + h5_acpi_match :0 , }, }; --2.18.0
Signature · 2 lines
Kees Cook Pixel Security
Marcel Holtmann
maintainerHi Arnd,
Quoted 41 lines
When
CONFIG_BT_HCIUART_RTLis disabled, thehci_h5driver produces a build warning because of an incorrect set of #ifdef guards:
drivers/bluetooth/hci_h5.c:920:22: error: 'rtl_vnd' defined but not used [-Werror=unused-variable]Replacing the #ifdef with an
IS_ENABLED()check shuts up the error and simplifies the logic.Signed-off-by Arnd Bergmann <[email protected]>---
drivers/bluetooth/hci_h5.c| 10 +++-------1 file changed, 3 insertions(+), 7 deletions(-)drivers/bluetooth/hci_h5.c +0
-6@@ -841,7 +841,6 @@ static void h5_serdev_remove(struct serdev_device *serdev)hci_uart_unregister_device (&h5->serdev_hu); } -#ifdef CONFIG_BT_HCIUART_RTL static int h5_btrtl_setup (struct h5 *h5) {struct btrtl_device_info *btrtl_dev;@@ -923,24 +922,21 @@ static struct h5_vnd rtl_vnd = { .close = h5_btrtl_close, .acpi_gpio_map = acpi_btrtl_gpios, }; -#endif -#ifdef CONFIG_ACPI static const struct acpi_device_id h5_acpi_match[] = { -#ifdef CONFIG_BT_HCIUART_RTL {"OBDA8723" , (kernel_ulong_t)&rtl_vnd }, -#endif { }, };MODULE_DEVICE_TABLE (acpi, h5_acpi_match); -#endif
drivers/bluetooth/hci_h5.c static struct h5_vnd rtl_vnd = { · line 940
Quoted 10 lines
drivers/bluetooth/hci_h5.c +3
-1static struct serdev_device_driver h5_serdev_driver = { .probe = h5_serdev_probe, .remove = h5_serdev_remove, .driver = { .name ="hci_uart_h5" , - .acpi_match_table =ACPI_PTR (h5_acpi_match), + .acpi_match_table = (IS_ENABLED (CONFIG_BT_HCIUART_RTL ) && +IS_ENABLED (CONFIG_ACPI )) ? + h5_acpi_match :0 , },
I do not like this construct at all. It will also blow up once we have a second vendor with H:5 support. We need to find another way to solve this.
Regards
Marcel
Hi Arnd,
Quoted 9 lines · Arnd Bergmann
When
CONFIG_BT_HCIUART_RTLis disabled, thehci_h5driver produces a build warning because of an incorrect set of #ifdef guards:
drivers/bluetooth/hci_h5.c:920:22: error: 'rtl_vnd' defined but not used [-Werror=unused-variable]Replacing the #ifdef with an
IS_ENABLED()check shuts up the error and simplifies the logic.Signed-off-by Arnd Bergmann <[email protected]>
Hmm, so now you're counting on dead code elimination to remove references to unavailable symbols. I'm not sure I like this and since Marcel has also indicated the does not like this fix I believe we need another fix.
I will write another fix for this.
Regards,
Hans
Quoted 45 lines
--- drivers/bluetooth/hci_h5.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)drivers/bluetooth/hci_h5.c +3
-7@@ -841,7 +841,6 @@ static void h5_serdev_remove(struct serdev_device *serdev)hci_uart_unregister_device (&h5->serdev_hu); } -#ifdef CONFIG_BT_HCIUART_RTL static int h5_btrtl_setup (struct h5 *h5) {struct btrtl_device_info *btrtl_dev;@@ -923,24 +922,21 @@ static struct h5_vnd rtl_vnd = { .close = h5_btrtl_close, .acpi_gpio_map = acpi_btrtl_gpios, }; -#endif -#ifdef CONFIG_ACPI static const struct acpi_device_id h5_acpi_match[] = { -#ifdef CONFIG_BT_HCIUART_RTL {"OBDA8723" , (kernel_ulong_t)&rtl_vnd }, -#endif { }, };MODULE_DEVICE_TABLE (acpi, h5_acpi_match); -#endif static struct serdev_device_driver h5_serdev_driver = { .probe = h5_serdev_probe, .remove = h5_serdev_remove, .driver = { .name ="hci_uart_h5" , - .acpi_match_table =ACPI_PTR (h5_acpi_match), + .acpi_match_table = (IS_ENABLED (CONFIG_BT_HCIUART_RTL ) && +IS_ENABLED (CONFIG_ACPI )) ? + h5_acpi_match :0 , }, };
Quoted 9 lines · Hans de Goede
Hi Arnd,
Quoted 5 lines · Arnd Bergmann
When
CONFIG_BT_HCIUART_RTLis disabled, thehci_h5driver produces a build warning because of an incorrect set of #ifdef guards:
drivers/bluetooth/hci_h5.c:920:22: error: 'rtl_vnd' defined but not used [-Werror=unused-variable]
Quoted 7 lines
Quoted 4 lines
Replacing the #ifdef with an
IS_ENABLED()check shuts up the error and simplifies the logic.Signed-off-by Arnd Bergmann <[email protected]>Hmm, so now you're counting on dead code elimination to remove references to unavailable symbols.
Generally depending on dead code elimination is very reliable, as this is easy for gcc to get right. However, you are right that this is actually an exception since the MODULE_DEVICE_TABLE() entry will keep
a reference around that prevents the compiler from eliminating it.
Quoted 6 lines
I'm not sure I like this and
since Marcel has also indicated the does not like this fix I believe we need another fix.I will write another fix for this.
Ok, thanks!
Arnd