Skip to content

Commit 3d05fc8

Browse files
Bartosz GolaszewskiVudentz
authored andcommitted
Bluetooth: qca: set power_ctrl_enabled on NULL returned by gpiod_get_optional()
Any return value from gpiod_get_optional() other than a pointer to a GPIO descriptor or a NULL-pointer is an error and the driver should abort probing. That being said: commit 56d074d ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()") no longer sets power_ctrl_enabled on NULL-pointer returned by devm_gpiod_get_optional(). Restore this behavior but bail-out on errors. While at it: also bail-out on error returned when trying to get the "swctrl" GPIO. Reported-by: Wren Turkal <[email protected]> Reported-by: Zijun Hu <[email protected]> Closes: https://lore.kernel.org/linux-bluetooth/[email protected]/ Fixes: 56d074d ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()") Reviewed-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]> Tested-by: Wren Turkal" <[email protected]> Reported-by: Wren Turkal <[email protected]> Reported-by: Zijun Hu <[email protected]> Reviewed-by: Krzysztof Kozlowski<[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 88cd6e6 commit 3d05fc8

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

drivers/bluetooth/hci_qca.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,16 +2332,21 @@ static int qca_serdev_probe(struct serdev_device *serdev)
23322332
(data->soc_type == QCA_WCN6750 ||
23332333
data->soc_type == QCA_WCN6855)) {
23342334
dev_err(&serdev->dev, "failed to acquire BT_EN gpio\n");
2335-
power_ctrl_enabled = false;
2335+
return PTR_ERR(qcadev->bt_en);
23362336
}
23372337

2338+
if (!qcadev->bt_en)
2339+
power_ctrl_enabled = false;
2340+
23382341
qcadev->sw_ctrl = devm_gpiod_get_optional(&serdev->dev, "swctrl",
23392342
GPIOD_IN);
23402343
if (IS_ERR(qcadev->sw_ctrl) &&
23412344
(data->soc_type == QCA_WCN6750 ||
23422345
data->soc_type == QCA_WCN6855 ||
2343-
data->soc_type == QCA_WCN7850))
2344-
dev_warn(&serdev->dev, "failed to acquire SW_CTRL gpio\n");
2346+
data->soc_type == QCA_WCN7850)) {
2347+
dev_err(&serdev->dev, "failed to acquire SW_CTRL gpio\n");
2348+
return PTR_ERR(qcadev->sw_ctrl);
2349+
}
23452350

23462351
qcadev->susclk = devm_clk_get_optional(&serdev->dev, NULL);
23472352
if (IS_ERR(qcadev->susclk)) {
@@ -2360,10 +2365,13 @@ static int qca_serdev_probe(struct serdev_device *serdev)
23602365
qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable",
23612366
GPIOD_OUT_LOW);
23622367
if (IS_ERR(qcadev->bt_en)) {
2363-
dev_warn(&serdev->dev, "failed to acquire enable gpio\n");
2364-
power_ctrl_enabled = false;
2368+
dev_err(&serdev->dev, "failed to acquire enable gpio\n");
2369+
return PTR_ERR(qcadev->bt_en);
23652370
}
23662371

2372+
if (!qcadev->bt_en)
2373+
power_ctrl_enabled = false;
2374+
23672375
qcadev->susclk = devm_clk_get_optional(&serdev->dev, NULL);
23682376
if (IS_ERR(qcadev->susclk)) {
23692377
dev_warn(&serdev->dev, "failed to acquire clk\n");

0 commit comments

Comments
 (0)