Skip to contentSkip to conversation

Bluetooth: hci_bcm: Ignore deprecated command fail case

PATCH In review Amitesh Chandra 2 participants 2 messages Oct 14, 2020 – Nov 11, 2020 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 Bluetooth: hci_bcm: Ignore deprecated command fail case

From: Manoj Babulal <[email protected]>

Broadcom VSC uart_clock_setting is deprecated in newer controllers. Ignore error if the controller returns invalid or bad request error code.

---
 drivers/bluetooth/hci_bcm.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/bluetooth/hci_bcm.c +9 -6
index 680478f..d316788 100644
@@ -158,15 +158,18 @@ static int bcm_set_baudrate(struct hci_uart *hu, unsigned int speed)
 		skb = __hci_cmd_sync(hdev, 0xfc45, 1, &clock, HCI_INIT_TIMEOUT);
 		if (IS_ERR(skb)) {
 			int err = PTR_ERR(skb);
-			bt_dev_err(hdev, "BCM: failed to write clock (%d)",
-				   err);
-			return err;
+			/* Ignore err if command is deprecated in controller */
+			if (err != -EBADRQC) {
+				bt_dev_err(hdev, "BCM: failed to write "
+						"clock (%d)", err);
+				return err;
+			}
+		} else {
+			kfree_skb(skb);
 		}
-
-		kfree_skb(skb);
 	}
 
-	bt_dev_dbg(hdev, "Set Controller UART speed to %d bit/s", speed);
+	bt_dev_info(hdev, "Set Controller UART speed to %d bit/s", speed);
 
 	param.zero = cpu_to_le16(0);
 	param.baud_rate = cpu_to_le32(speed);
Signature · 1 line
2.7.4
maintainer
#1 lore raw

Hi Amitesh,

Quoted 23 lines

Broadcom VSC uart_clock_setting is deprecated in
newer controllers. Ignore error if the controller
returns invalid or bad request error code.

---
drivers/bluetooth/hci_bcm.c | 15 +++++++++------

1 file changed, 9 insertions(+), 6 deletions(-)
drivers/bluetooth/hci_bcm.c +2 -3
index 680478f..d316788 100644
@@ -158,15 +158,18 @@ static int bcm_set_baudrate(struct hci_uart *hu, unsigned int speed)
 		skb = __hci_cmd_sync(hdev, 0xfc45, 1, &clock, HCI_INIT_TIMEOUT);
 		if (IS_ERR(skb)) {
 			int err = PTR_ERR(skb);
-			bt_dev_err(hdev, "BCM: failed to write clock (%d)",
-				   err);
-			return err;
+			/* Ignore err if command is deprecated in controller */
+			if (err != -EBADRQC) {

drivers/bluetooth/hci_bcm.c static int bcm_set_baudrate(struct hci_uart *hu, unsigned int speed) · line 170

Quoted 10 lines
drivers/bluetooth/hci_bcm.c +6 -2
+				bt_dev_err(hdev, "BCM: failed to write "
+						"clock (%d)", err);
+				return err;
+			}
+		} else {
+			kfree_skb(skb);
 		}
-
-		kfree_skb(skb);
 	}

So I really disliked try-and-error of HCI commands. Can we know up-front somehow if the controller supports a command or not. It is a total waste of time to send a command that might fail. So we better know this before sending it.

Regards

Marcel