All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zijun Hu <quic_zijuhu@quicinc.com>
To: <luiz.dentz@gmail.com>, <luiz.von.dentz@intel.com>,
	<marcel@holtmann.org>
Cc: <linux-bluetooth@vger.kernel.org>, Zijun Hu <quic_zijuhu@quicinc.com>
Subject: [PATCH v2 4/4] Bluetooth: qca: Fix wrong soc type returned for tool btattach
Date: Wed, 17 Apr 2024 20:52:16 +0800	[thread overview]
Message-ID: <1713358336-29619-5-git-send-email-quic_zijuhu@quicinc.com> (raw)
In-Reply-To: <1713358336-29619-1-git-send-email-quic_zijuhu@quicinc.com>

qca_soc_type() returns wrong soc type QCA_ROME when use tool btattach
for any other soc type such as QCA_QCA2066, and wrong soc type will
cause later initialization failure, fixed by using user specified
soc type for hci_uart derived from tool btattach.

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
 drivers/bluetooth/btqca.h   | 1 +
 drivers/bluetooth/hci_qca.c | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btqca.h b/drivers/bluetooth/btqca.h
index dc31984f71dc..a148d4c4e1bd 100644
--- a/drivers/bluetooth/btqca.h
+++ b/drivers/bluetooth/btqca.h
@@ -153,6 +153,7 @@ enum qca_btsoc_type {
 	QCA_WCN6750,
 	QCA_WCN6855,
 	QCA_WCN7850,
+	QCA_MAX,
 };
 
 #if IS_ENABLED(CONFIG_BT_QCA)
diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index c04b97332bca..7c3577a4887c 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -238,12 +238,17 @@ static void qca_dmp_hdr(struct hci_dev *hdev, struct sk_buff *skb);
 
 static enum qca_btsoc_type qca_soc_type(struct hci_uart *hu)
 {
+	/* For Non-serdev device, hu->proto_data records soc type
+	 * set by ioctl HCIUARTSETPROTODATA.
+	 */
+	int proto_data = (int)hu->proto_data;
 	enum qca_btsoc_type soc_type;
 
 	if (hu->serdev) {
 		struct qca_serdev *qsd = serdev_device_get_drvdata(hu->serdev);
-
 		soc_type = qsd->btsoc_type;
+	} else if ((proto_data > 0) && (proto_data < QCA_MAX)) {
+		soc_type = (enum qca_btsoc_type)proto_data;
 	} else {
 		soc_type = QCA_ROME;
 	}
@@ -2281,6 +2286,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
 		return -ENOMEM;
 
 	qcadev->serdev_hu.serdev = serdev;
+	qcadev->serdev_hu.proto_data = 0;
 	data = device_get_match_data(&serdev->dev);
 	serdev_device_set_drvdata(serdev, qcadev);
 	device_property_read_string(&serdev->dev, "firmware-name",
-- 
2.7.4


  parent reply	other threads:[~2024-04-17 12:53 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20  6:08 [PATCH v1 0/2] Bluetooth: qca: Add tool btattach support for more QCA soc types Zijun Hu
2024-03-20  6:08 ` [PATCH v1 1/2] Bluetooth: hci_ldisc: Add a ioctl HCIUARTSETPROTODATA Zijun Hu
2024-03-20  6:34   ` Bluetooth: qca: Add tool btattach support for more QCA soc types bluez.test.bot
2024-03-20  6:08 ` [PATCH v1 2/2] Bluetooth: qca: Fix wrong soc_type returned for tool btattach Zijun Hu
2024-03-20  7:19 ` [PATCH v1] tools/btattach: Add support for all QCA soc_types Zijun Hu
2024-03-20  9:02   ` [v1] " bluez.test.bot
2024-04-12 16:26 ` [PATCH v1 0/3] Fix 2 tool btattach issues for QCA controllers Zijun Hu
2024-04-12 16:26   ` [PATCH v1 1/3] Bluetooth: qca: Fix crash caused by tool btattach for QCA_ROME Zijun Hu
2024-04-12 16:56     ` Fix 2 tool btattach issues for QCA controllers bluez.test.bot
2024-04-12 16:26   ` [PATCH v1 2/3] Bluetooth: hci_ldisc: Add a ioctl HCIUARTSETPROTODATA Zijun Hu
2024-04-12 16:26   ` [PATCH v1 3/3] Bluetooth: qca: Fix wrong soc type returned for tool btattach Zijun Hu
2024-04-12 16:26   ` [PATCH BlueZ v1] tools/btattach: Add support for more QCA soc types Zijun Hu
2024-04-12 18:02     ` [BlueZ,v1] " bluez.test.bot
2024-04-12 20:10     ` [PATCH BlueZ v1] " Wren Turkal
2024-04-13  2:44       ` quic_zijuhu
2024-04-13  3:12         ` Wren Turkal
2024-04-18  3:38     ` [PATCH BlueZ v2] " Zijun Hu
2024-04-18  5:40       ` [BlueZ,v2] " bluez.test.bot
2024-04-17 12:52 ` [PATCH v2 0/4] Fix 2 tool btattach issues for QCA controllers Zijun Hu
2024-04-17 12:52   ` [PATCH v2 1/4] Bluetooth: qca: Fix crash caused by tool btattach for QCA_ROME Zijun Hu
2024-04-17 12:52   ` [PATCH v2 2/4] Bluetooth: qca: Fix nullptr dereference for non-serdev devices Zijun Hu
2024-04-17 12:52   ` [PATCH v2 3/4] Bluetooth: hci_ldisc: Add a ioctl HCIUARTSETPROTODATA Zijun Hu
2024-04-17 21:27     ` Luiz Augusto von Dentz
2024-04-18  0:44       ` quic_zijuhu
2024-04-17 12:52   ` Zijun Hu [this message]
2024-04-17 21:39     ` [PATCH v2 4/4] Bluetooth: qca: Fix wrong soc type returned for tool btattach Luiz Augusto von Dentz
2024-04-18  1:26       ` quic_zijuhu
2024-04-18  3:11   ` [PATCH v3 0/4] Fix 2 tool btattach issues for QCA controllers Zijun Hu
2024-04-18  3:11     ` [PATCH v3 1/4] Bluetooth: qca: Fix crash caused by tool btattach for QCA_ROME Zijun Hu
2024-04-18  3:57       ` Fix 2 tool btattach issues for QCA controllers bluez.test.bot
2024-04-18  3:11     ` [PATCH v3 2/4] Bluetooth: qca: Fix nullptr dereference for non-serdev devices Zijun Hu
2024-04-18 16:08       ` Johan Hovold
2024-04-18 22:15         ` quic_zijuhu
2024-04-18  3:11     ` [PATCH v3 3/4] Bluetooth: hci_ldisc: Add a ioctl HCIUARTSETPROTODATA Zijun Hu
2024-04-18  3:11     ` [PATCH v3 4/4] Bluetooth: qca: Support more soc types for non-serdev devices Zijun Hu

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=1713358336-29619-5-git-send-email-quic_zijuhu@quicinc.com \
    --to=quic_zijuhu@quicinc.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=luiz.von.dentz@intel.com \
    --cc=marcel@holtmann.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.