From: Paul Cercueil <paul.cercueil@bootlin.com>
To: Marcel Holtmann <marcel@holtmann.org>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Paul Cercueil <paul.cercueil@bootlin.com>
Subject: [PATCH 2/2] Bluetooth: btusb: Prevent conditional compilation
Date: Fri, 13 Nov 2026 15:26:00 +0100 [thread overview]
Message-ID: <20261113142600.74004-2-paul.cercueil@bootlin.com> (raw)
In-Reply-To: <20261113142600.74004-1-paul.cercueil@bootlin.com>
Use IS_ENABLED() when possible instead of #ifdef macro guards.
It makes the code cleaner, and the compiler will still discard the code
blocks if the corresponding configuration option is disabled.
Note the small change where we now check for
"IS_ENABLED(CONFIG_PM) && data->oob_wake_irq". These code paths were
dead when CONFIG_PM was not set, and I'm not sure the compiler was
seeing that.
Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>
---
drivers/bluetooth/btusb_main.c | 35 ++++++++++------------------------
1 file changed, 10 insertions(+), 25 deletions(-)
diff --git a/drivers/bluetooth/btusb_main.c b/drivers/bluetooth/btusb_main.c
index 92a78a7e6039..295c743f42f7 100644
--- a/drivers/bluetooth/btusb_main.c
+++ b/drivers/bluetooth/btusb_main.c
@@ -3220,7 +3220,6 @@ static int btusb_mtk_shutdown(struct hci_dev *hdev)
return ret;
}
-#ifdef CONFIG_PM
/* Configure an out-of-band gpio as wake-up pin, if specified in device tree */
static int marvell_config_oob_wake(struct hci_dev *hdev)
{
@@ -3262,12 +3261,6 @@ static int marvell_config_oob_wake(struct hci_dev *hdev)
return 0;
}
-#else
-static inline int marvell_config_oob_wake(struct hci_dev *hdev)
-{
- return 0;
-}
-#endif
static int btusb_set_bdaddr_marvell(struct hci_dev *hdev,
const bdaddr_t *bdaddr)
@@ -4044,7 +4037,6 @@ static int btusb_bcm_set_diag(struct hci_dev *hdev, bool enable)
return submit_or_queue_tx_urb(hdev, urb);
}
-#ifdef CONFIG_PM
static irqreturn_t btusb_oob_wake_handler(int irq, void *priv)
{
struct btusb_data *data = priv;
@@ -4110,12 +4102,6 @@ static int btusb_config_oob_wake(struct hci_dev *hdev)
return ret;
}
-#else
-static inline int btusb_config_oob_wake(struct hci_dev *hdev)
-{
- return 0;
-}
-#endif
static void btusb_check_needs_reset_resume(struct usb_interface *intf)
{
@@ -4547,12 +4533,15 @@ static int btusb_probe(struct usb_interface *intf,
hdev->wakeup = btusb_wakeup;
hdev->hci_drv = &btusb_hci_drv;
- err = btusb_config_oob_wake(hdev);
- if (err)
- goto err_put_reset;
+ if (IS_ENABLED(CONFIG_PM)) {
+ err = btusb_config_oob_wake(hdev);
+ if (err)
+ goto err_put_reset;
+ }
/* Marvell devices may need a specific chip configuration */
- if (id->driver_info & BTUSB_MARVELL && data->oob_wake_irq) {
+ if (IS_ENABLED(CONFIG_PM)
+ && id->driver_info & BTUSB_MARVELL && data->oob_wake_irq) {
err = marvell_config_oob_wake(hdev);
if (err)
goto err_disable_wakeup;
@@ -4837,7 +4826,7 @@ static int btusb_probe(struct usb_interface *intf,
err_kill_tx_urbs:
usb_kill_anchored_urbs(&data->tx_anchor);
err_disable_wakeup:
- if (data->oob_wake_irq) {
+ if (IS_ENABLED(CONFIG_PM) && data->oob_wake_irq) {
device_init_wakeup(&data->udev->dev, false);
free_irq(data->oob_wake_irq, data);
}
@@ -4876,7 +4865,7 @@ static void btusb_disconnect(struct usb_interface *intf)
hci_unregister_dev(hdev);
- if (data->oob_wake_irq) {
+ if (IS_ENABLED(CONFIG_PM) && data->oob_wake_irq) {
device_init_wakeup(&data->udev->dev, false);
free_irq(data->oob_wake_irq, data);
}
@@ -5076,7 +5065,6 @@ static int btusb_resume(struct usb_interface *intf)
return err;
}
-#ifdef CONFIG_DEV_COREDUMP
static void btusb_coredump(struct device *dev)
{
struct btusb_data *data = dev_get_drvdata(dev);
@@ -5085,7 +5073,6 @@ static void btusb_coredump(struct device *dev)
if (hdev->dump.coredump)
hdev->dump.coredump(hdev);
}
-#endif
static struct usb_driver btusb_driver = {
.name = "btusb",
@@ -5097,11 +5084,9 @@ static struct usb_driver btusb_driver = {
.supports_autosuspend = 1,
.disable_hub_initiated_lpm = 1,
-#ifdef CONFIG_DEV_COREDUMP
.driver = {
- .coredump = btusb_coredump,
+ .coredump = PTR_IF(IS_ENABLED(CONFIG_DEV_COREDUMP), btusb_coredump),
},
-#endif
};
module_usb_driver(btusb_driver);
--
2.47.3
prev parent reply other threads:[~2026-11-13 14:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 14:25 [PATCH 1/2] Bluetooth: hci_bcm: Drop CONFIG_PM guards Paul Cercueil
2026-11-13 14:26 ` Paul Cercueil [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261113142600.74004-2-paul.cercueil@bootlin.com \
--to=paul.cercueil@bootlin.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®