diff mbox series

[v3] Bluetooth: qca: Fix QCA6390 enable failure after reboot or disable

Message ID 1713366251-22144-1-git-send-email-quic_zijuhu@quicinc.com
State New
Headers show
Series [v3] Bluetooth: qca: Fix QCA6390 enable failure after reboot or disable | expand

Commit Message

Zijun Hu April 17, 2024, 3:04 p.m. UTC
Fix QCA6390 enable failure after reboot or disable.

it is a debugging change and don't merge.

Fixes: 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()")
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
Changes v2 -> v3
 - Fix Reverting the 56d074d26c58 error
Changes v1 -> v2
 - Revert part of 56d074d26c58

 drivers/bluetooth/hci_qca.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index b61ca9828284..f58bce5448ee 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -2362,7 +2362,7 @@  static int qca_serdev_probe(struct serdev_device *serdev)
 			BT_INFO("%s: Got enable gpio(%d) ", __func__, desc_to_gpio(qcadev->bt_en));
 		else
 			BT_INFO("%s: qcadev->bt_en(nullptr)", __func__);
-		if (IS_ERR(qcadev->bt_en) &&
+		if (IS_ERR_OR_NULL(qcadev->bt_en) &&
 		    (data->soc_type == QCA_WCN6750 ||
 		     data->soc_type == QCA_WCN6855)) {
 			dev_err(&serdev->dev, "failed to acquire BT_EN gpio\n");
@@ -2378,7 +2378,7 @@  static int qca_serdev_probe(struct serdev_device *serdev)
 				desc_to_gpio(qcadev->sw_ctrl));
 		else
 			BT_INFO("%s: qcadev->sw_ctrl(nullptr)", __func__);
-		if (IS_ERR(qcadev->sw_ctrl) &&
+		if (IS_ERR_OR_NULL(qcadev->sw_ctrl) &&
 		    (data->soc_type == QCA_WCN6750 ||
 		     data->soc_type == QCA_WCN6855 ||
 		     data->soc_type == QCA_WCN7850))
@@ -2411,7 +2411,7 @@  static int qca_serdev_probe(struct serdev_device *serdev)
 				__func__, desc_to_gpio(qcadev->bt_en));
 		else
 			BT_INFO("%s: default qcadev->bt_en(nullptr)", __func__);
-		if (IS_ERR(qcadev->bt_en)) {
+		if (IS_ERR_OR_NULL(qcadev->bt_en)) {
 			dev_warn(&serdev->dev, "failed to acquire enable gpio\n");
 			power_ctrl_enabled = false;
 		}
@@ -2499,14 +2499,19 @@  static void qca_serdev_shutdown(struct device *dev)
 	struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);
 	struct hci_uart *hu = &qcadev->serdev_hu;
 	struct hci_dev *hdev = hu->hdev;
-	struct qca_data *qca = hu->priv;
 	const u8 ibs_wake_cmd[] = { 0xFD };
 	const u8 edl_reset_soc_cmd[] = { 0x01, 0x00, 0xFC, 0x01, 0x05 };
 
 	if (qcadev->btsoc_type == QCA_QCA6390) {
-		if (test_bit(QCA_BT_OFF, &qca->flags) ||
-		    !test_bit(HCI_RUNNING, &hdev->flags))
+		if (test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
+			BT_INFO("%s: Don't need to send EDL_RESET_REQ", __func__);
 			return;
+		}
+
+		if (hci_dev_test_flag(hdev, HCI_SETUP)) {
+			BT_INFO("%s: Don't send EDL_RESET_REQ due to NOT setup ", __func__);
+			return;
+		}
 
 		BT_INFO("%s: Start to send EDL_RESET_REQ", __func__);
 		serdev_device_write_flush(serdev);