Skip to content

Commit b80f4e3

Browse files
Bartosz GolaszewskiVudentz
authored andcommitted
Bluetooth: hci_qca: schedule a devm action for disabling the clock
In preparation for unduplicating the hci_uart registration code, schedule a devres action for disabling the SUSCLK rather than doing it manually. We cannot really use devm_clk_get_enabled() as we also set the rate before enabling the clock. While this should in theory work, I don't want to risk breaking existing users. One solution for the future is to add devm_clk_get_enabled_with_rate() to the clock framework. Signed-off-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent bd3f305 commit b80f4e3

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

drivers/bluetooth/hci_qca.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,6 +2295,13 @@ static int qca_init_regulators(struct qca_power *qca,
22952295
return 0;
22962296
}
22972297

2298+
static void qca_clk_disable_unprepare(void *data)
2299+
{
2300+
struct clk *clk = data;
2301+
2302+
clk_disable_unprepare(clk);
2303+
}
2304+
22982305
static int qca_serdev_probe(struct serdev_device *serdev)
22992306
{
23002307
struct qca_serdev *qcadev;
@@ -2434,10 +2441,15 @@ static int qca_serdev_probe(struct serdev_device *serdev)
24342441
if (err)
24352442
return err;
24362443

2444+
err = devm_add_action_or_reset(&serdev->dev,
2445+
qca_clk_disable_unprepare,
2446+
qcadev->susclk);
2447+
if (err)
2448+
return err;
2449+
24372450
err = hci_uart_register_device(&qcadev->serdev_hu, &qca_proto);
24382451
if (err) {
24392452
BT_ERR("Rome serdev registration failed");
2440-
clk_disable_unprepare(qcadev->susclk);
24412453
return err;
24422454
}
24432455
}
@@ -2477,15 +2489,10 @@ static void qca_serdev_remove(struct serdev_device *serdev)
24772489
case QCA_WCN6750:
24782490
case QCA_WCN6855:
24792491
case QCA_WCN7850:
2480-
if (power->vregs_on) {
2492+
if (power->vregs_on)
24812493
qca_power_shutdown(&qcadev->serdev_hu);
2482-
break;
2483-
}
2484-
fallthrough;
2485-
2494+
break;
24862495
default:
2487-
if (qcadev->susclk)
2488-
clk_disable_unprepare(qcadev->susclk);
24892496
}
24902497

24912498
hci_uart_unregister_device(&qcadev->serdev_hu);

0 commit comments

Comments
 (0)