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 1/2] Bluetooth: hci_bcm: Drop CONFIG_PM guards
Date: Fri, 13 Nov 2026 15:25:59 +0100 [thread overview]
Message-ID: <20261113142600.74004-1-paul.cercueil@bootlin.com> (raw)
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
next 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 Paul Cercueil [this message]
2026-11-13 14:26 ` [PATCH 2/2] Bluetooth: btusb: Prevent conditional compilation Paul Cercueil
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-1-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®