diff mbox series

[v7,1/2] Bluetooth: add quirk disabling LE Read Transmit Power

Message ID A6DD9616-E669-4382-95A0-B9DBAF46712D@live.com
State Superseded
Headers show
Series [v7,1/2] Bluetooth: add quirk disabling LE Read Transmit Power | expand

Commit Message

Aditya Garg Nov. 30, 2021, 11:38 a.m. UTC
From: Aditya Garg <gargaditya08@live.com>

Some devices have a bug causing them to not work if they query 
LE tx power on startup. Thus we add a quirk in order to not query it 
and default min/max tx power values to HCI_TX_POWER_INVALID.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
---
v7 :- Added Tested-by.
 include/net/bluetooth/hci.h | 9 +++++++++
 net/bluetooth/hci_core.c    | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

Comments

Aditya Garg Nov. 30, 2021, 11:50 a.m. UTC | #1
> On 30-Nov-2021, at 5:11 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> 
> On Tue, Nov 30, 2021 at 11:38:58AM +0000, Aditya Garg wrote:
>> From: Aditya Garg <gargaditya08@live.com>
>> 
>> Some devices have a bug causing them to not work if they query 
>> LE tx power on startup. Thus we add a quirk in order to not query it 
>> and default min/max tx power values to HCI_TX_POWER_INVALID.
>> 
>> Signed-off-by: Aditya Garg <gargaditya08@live.com>
>> Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
>> Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
>> Link:
>> https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
>> Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
>> ---
>> v7 :- Added Tested-by.
>> include/net/bluetooth/hci.h | 9 +++++++++
>> net/bluetooth/hci_core.c    | 3 ++-
>> 2 files changed, 11 insertions(+), 1 deletion(-)
>> 
>> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
>> index 63065bc01b766c..383342efcdc464 100644
>> --- a/include/net/bluetooth/hci.h
>> +++ b/include/net/bluetooth/hci.h
>> @@ -246,6 +246,15 @@ enum {
>> 	 * HCI after resume.
>> 	 */
>> 	HCI_QUIRK_NO_SUSPEND_NOTIFIER,
>> +
>> +	/*
>> +	 * When this quirk is set, LE tx power is not queried on startup
>> +	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
>> +	 *
>> +	 * This quirk can be set before hci_register_dev is called or
>> +	 * during the hdev->setup vendor callback.
>> +	 */
>> +	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
>> };
>> 
>> /* HCI device flags */
>> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
>> index 8d33aa64846b1c..434c6878fe9640 100644
>> --- a/net/bluetooth/hci_core.c
>> +++ b/net/bluetooth/hci_core.c
>> @@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
>> 			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
>> 		}
>> 
>> -		if (hdev->commands[38] & 0x80) {
>> +		if ((hdev->commands[38] & 0x80) &&
>> +		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {
> 
> This line is still not properly formatted.
I hope its fine in the resent patch. I sent the patch as HTML by mistake.
> 
> Please always use scripts/checkpatch.pl to find issues like this.
> 
> thanks,
> 
> greg k-h
diff mbox series

Patch

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 63065bc01b766c..383342efcdc464 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -246,6 +246,15 @@  enum {
 	 * HCI after resume.
 	 */
 	HCI_QUIRK_NO_SUSPEND_NOTIFIER,
+
+	/*
+	 * When this quirk is set, LE tx power is not queried on startup
+	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
+	 *
+	 * This quirk can be set before hci_register_dev is called or
+	 * during the hdev->setup vendor callback.
+	 */
+	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
 };
 
 /* HCI device flags */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8d33aa64846b1c..434c6878fe9640 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -619,7 +619,8 @@  static int hci_init3_req(struct hci_request *req, unsigned long opt)
 			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
 		}
 
-		if (hdev->commands[38] & 0x80) {
+		if ((hdev->commands[38] & 0x80) &&
+		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {
 			/* Read LE Min/Max Tx Power*/
 			hci_req_add(req, HCI_OP_LE_READ_TRANSMIT_POWER,
 				    0, NULL);