[PATCH v4 2/4] Bluetooth: qca: Power off after unregistering the HCI device

From: Michael McAllister

Date: Thu Nov 26 2026 - 14:00:18 EST


qca_serdev_remove() powers off while HCI setup and UART writes can still
be running. Leave power-off to qca_close(), after HCI unregistration and
write-work cancellation, while the serial transport is still available.

Check the actual port state before sending the power-off pulse, since
PROTO_READY is already clear during protocol cleanup. Start serdev
controllers in QCA_BT_OFF so registration failure does not send a pulse
before HCI allocation or power-on.

Signed-off-by: Michael McAllister <me@xxxxxxxxxxxxxxxxxxxxx>
---
drivers/bluetooth/hci_qca.c | 23 ++---------------------
1 file changed, 2 insertions(+), 21 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 0f893f16a..53239b0ab 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -616,6 +616,7 @@ static int qca_open(struct hci_uart *hu)
hu->priv = qca;

if (hu->serdev) {
+ set_bit(QCA_BT_OFF, &qca->flags);
qcadev = serdev_device_get_drvdata(hu->serdev);

switch (qcadev->btsoc_type) {
@@ -2286,11 +2287,7 @@ static void qca_power_off(struct hci_uart *hu)
case QCA_WCN3990:
case QCA_WCN3991:
case QCA_WCN3998:
- /* Both of these write to the serial port which may have
- * already been closed by hci_uart_close(), which closes
- * the port if HCI_QUIRK_NON_PERSISTENT_SETUP is set.
- */
- if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) {
+ if (hu->serdev_open) {
host_set_baudrate(hu, 2400);
qca_send_power_pulse(hu, false);
}
@@ -2664,22 +2661,6 @@ static void qca_serdev_remove(struct serdev_device *serdev)
{
struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);

- switch (qcadev->btsoc_type) {
- case QCA_WCN3988:
- case QCA_WCN3990:
- case QCA_WCN3991:
- case QCA_WCN3998:
- case QCA_WCN6750:
- case QCA_QCA2066:
- case QCA_WCN6855:
- case QCA_WCN7850:
- if (qcadev->vregs_on)
- qca_power_off(&qcadev->serdev_hu);
- break;
- default:
- break;
- }
-
hci_uart_unregister_device(&qcadev->serdev_hu);
}

--
2.39.5