Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/2] Bluetooth: hci_bcm: Drop CONFIG_PM guards
@ 2026-11-13 14:25 Paul Cercueil
  2026-11-13 14:26 ` [PATCH 2/2] Bluetooth: btusb: Prevent conditional compilation Paul Cercueil
  2026-11-13 17:01 ` [1/2] Bluetooth: hci_bcm: Drop CONFIG_PM guards bluez.test.bot
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Cercueil @ 2026-11-13 14:25 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: linux-bluetooth, linux-kernel, Thomas Petazzoni, Paul Cercueil

Use the modem PM macros for the suspend and resume functions. These
ensure that the PM functions will be automatically dropped by the
compiler when CONFIG_PM is disabled.

Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>
---
 drivers/bluetooth/hci_bcm.c | 44 +++++++++++--------------------------
 1 file changed, 13 insertions(+), 31 deletions(-)

diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
index 83091e5c5702..ca030ed25540 100644
--- a/drivers/bluetooth/hci_bcm.c
+++ b/drivers/bluetooth/hci_bcm.c
@@ -139,10 +139,8 @@ struct bcm_device {
 	bool			irq_active_low;
 	bool			irq_acquired;
 
-#ifdef CONFIG_PM
 	struct hci_uart		*hu;
 	bool			is_suspended;
-#endif
 	bool			no_early_set_baudrate;
 	bool			drive_rts_on_open;
 	bool			no_uart_clock_set;
@@ -230,11 +228,9 @@ static bool bcm_device_exists(struct bcm_device *device)
 {
 	struct list_head *p;
 
-#ifdef CONFIG_PM
 	/* Devices using serdev always exist */
-	if (device && device->hu && device->hu->serdev)
+	if (IS_ENABLED(CONFIG_PM) && device && device->hu && device->hu->serdev)
 		return true;
-#endif
 
 	list_for_each(p, &bcm_device_list) {
 		struct bcm_device *dev = list_entry(p, struct bcm_device, list);
@@ -318,7 +314,6 @@ static int bcm_gpio_set_power(struct bcm_device *dev, bool powered)
 	return err;
 }
 
-#ifdef CONFIG_PM
 static irqreturn_t bcm_host_wake(int irq, void *data)
 {
 	struct bcm_device *bdev = data;
@@ -409,10 +404,6 @@ static int bcm_setup_sleep(struct hci_uart *hu)
 
 	return 0;
 }
-#else
-static inline int bcm_request_irq(struct bcm_data *bcm) { return 0; }
-static inline int bcm_setup_sleep(struct hci_uart *hu) { return 0; }
-#endif
 
 static int bcm_set_diag(struct hci_dev *hdev, bool enable)
 {
@@ -475,9 +466,8 @@ static int bcm_open(struct hci_uart *hu)
 		 */
 		if (hu->tty->dev->parent == dev->dev->parent) {
 			bcm->dev = dev;
-#ifdef CONFIG_PM
-			dev->hu = hu;
-#endif
+			if (IS_ENABLED(CONFIG_PM))
+				dev->hu = hu;
 			break;
 		}
 	}
@@ -513,10 +503,8 @@ static int bcm_open(struct hci_uart *hu)
 	return 0;
 
 err_unset_hu:
-#ifdef CONFIG_PM
-	if (!hu->serdev)
+	if (IS_ENABLED(CONFIG_PM) && !hu->serdev)
 		bcm->dev->hu = NULL;
-#endif
 	mutex_unlock(&bcm_device_lock);
 	hu->priv = NULL;
 	kfree(bcm);
@@ -538,9 +526,8 @@ static int bcm_close(struct hci_uart *hu)
 		bdev = serdev_device_get_drvdata(hu->serdev);
 	} else if (bcm_device_exists(bcm->dev)) {
 		bdev = bcm->dev;
-#ifdef CONFIG_PM
-		bdev->hu = NULL;
-#endif
+		if (IS_ENABLED(CONFIG_PM))
+			bdev->hu = NULL;
 	}
 
 	if (bdev) {
@@ -646,7 +633,7 @@ static int bcm_setup(struct hci_uart *hu)
 	if (hci_test_quirk(hu->hdev, HCI_QUIRK_INVALID_BDADDR))
 		hci_set_quirk(hu->hdev, HCI_QUIRK_USE_BDADDR_PROPERTY);
 
-	if (!bcm_request_irq(bcm))
+	if (IS_ENABLED(CONFIG_PM) && !bcm_request_irq(bcm))
 		err = bcm_setup_sleep(hu);
 
 	return err;
@@ -755,7 +742,6 @@ static struct sk_buff *bcm_dequeue(struct hci_uart *hu)
 	return skb;
 }
 
-#ifdef CONFIG_PM
 static int bcm_suspend_device(struct device *dev)
 {
 	struct bcm_device *bdev = dev_get_drvdata(dev);
@@ -811,9 +797,7 @@ static int bcm_resume_device(struct device *dev)
 
 	return 0;
 }
-#endif
 
-#ifdef CONFIG_PM_SLEEP
 /* suspend callback */
 static int bcm_suspend(struct device *dev)
 {
@@ -885,7 +869,6 @@ static int bcm_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
 /* Some firmware reports an IRQ which does not work (wrong pin in fw table?) */
 static struct gpiod_lookup_table irq_on_int33fc02_pin17_gpios = {
@@ -1489,8 +1472,8 @@ MODULE_DEVICE_TABLE(acpi, bcm_acpi_match);
 
 /* suspend and resume callbacks */
 static const struct dev_pm_ops bcm_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(bcm_suspend, bcm_resume)
-	SET_RUNTIME_PM_OPS(bcm_suspend_device, bcm_resume_device, NULL)
+	SYSTEM_SLEEP_PM_OPS(bcm_suspend, bcm_resume)
+	RUNTIME_PM_OPS(bcm_suspend_device, bcm_resume_device, NULL)
 };
 
 static struct platform_driver bcm_driver = {
@@ -1499,7 +1482,7 @@ static struct platform_driver bcm_driver = {
 	.driver = {
 		.name = "hci_bcm",
 		.acpi_match_table = ACPI_PTR(bcm_acpi_match),
-		.pm = &bcm_pm_ops,
+		.pm = pm_ptr(&bcm_pm_ops),
 	},
 };
 
@@ -1514,9 +1497,8 @@ static int bcm_serdev_probe(struct serdev_device *serdev)
 		return -ENOMEM;
 
 	bcmdev->dev = &serdev->dev;
-#ifdef CONFIG_PM
-	bcmdev->hu = &bcmdev->serdev_hu;
-#endif
+	if (IS_ENABLED(CONFIG_PM))
+		bcmdev->hu = &bcmdev->serdev_hu;
 	bcmdev->serdev_hu.serdev = serdev;
 	serdev_device_set_drvdata(serdev, bcmdev);
 
@@ -1608,7 +1590,7 @@ static struct serdev_device_driver bcm_serdev_driver = {
 		.name = "hci_uart_bcm",
 		.of_match_table = of_match_ptr(bcm_bluetooth_of_match),
 		.acpi_match_table = ACPI_PTR(bcm_acpi_match),
-		.pm = &bcm_pm_ops,
+		.pm = pm_ptr(&bcm_pm_ops),
 	},
 };
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] Bluetooth: btusb: Prevent conditional compilation
  2026-11-13 14:25 [PATCH 1/2] Bluetooth: hci_bcm: Drop CONFIG_PM guards Paul Cercueil
@ 2026-11-13 14:26 ` Paul Cercueil
  2026-11-13 17:01 ` [1/2] Bluetooth: hci_bcm: Drop CONFIG_PM guards bluez.test.bot
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Cercueil @ 2026-11-13 14:26 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: linux-bluetooth, linux-kernel, Thomas Petazzoni, Paul Cercueil

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [1/2] Bluetooth: hci_bcm: Drop CONFIG_PM guards
  2026-11-13 14:25 [PATCH 1/2] Bluetooth: hci_bcm: Drop CONFIG_PM guards Paul Cercueil
  2026-11-13 14:26 ` [PATCH 2/2] Bluetooth: btusb: Prevent conditional compilation Paul Cercueil
@ 2026-11-13 17:01 ` bluez.test.bot
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-11-13 17:01 UTC (permalink / raw)
  To: linux-bluetooth, paul.cercueil

[-- Attachment #1: Type: text/plain, Size: 1020 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1210616/

---Test result---

Test Summary:
CheckPatch                    PASS      0.80 seconds
VerifyFixes                   PASS      0.05 seconds
VerifySignedoff               PASS      0.05 seconds
GitLint                       PASS      0.33 seconds
SubjectPrefix                 PASS      0.10 seconds
BuildKernel                   PASS      20.30 seconds
CheckAllWarning               PASS      23.18 seconds
CheckSparse                   PASS      24.60 seconds
BuildKernel32                 PASS      20.48 seconds
CheckKernelLLVM               PASS      20.77 seconds
TestRunnerSetup               PASS      486.08 seconds
IncrementalBuild              PASS      20.61 seconds



https://github.com/bluez/bluetooth-next/pull/1129

---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-13 17:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13 14:25 [PATCH 1/2] Bluetooth: hci_bcm: Drop CONFIG_PM guards Paul Cercueil
2026-11-13 14:26 ` [PATCH 2/2] Bluetooth: btusb: Prevent conditional compilation Paul Cercueil
2026-11-13 17:01 ` [1/2] Bluetooth: hci_bcm: Drop CONFIG_PM guards bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox