All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] Bluetooth: hci_bcm: Ignore deprecated command fail case
@ 2020-10-14  5:47 Amitesh Chandra
  2020-11-11 11:07 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Amitesh Chandra @ 2020-10-14  5:47 UTC (permalink / raw)
  To: marcel, johan.hedberg, linux-bluetooth, linux-kernel
  Cc: amitesh.chandra, ravi.nagarajan, cheneyni, Manoj Babulal

From: Manoj Babulal <manoj.babulal@broadcom.com>

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

Signed-off-by: Amitesh Chandra <amitesh.chandra@broadcom.com>
Signed-off-by: Manoj Babulal <manoj.babulal@broadcom.com>
---
 drivers/bluetooth/hci_bcm.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
index 680478f..d316788 100644
--- a/drivers/bluetooth/hci_bcm.c
+++ b/drivers/bluetooth/hci_bcm.c
@@ -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);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 3/3] Bluetooth: hci_bcm: Ignore deprecated command fail case
  2020-10-14  5:47 [PATCH 3/3] Bluetooth: hci_bcm: Ignore deprecated command fail case Amitesh Chandra
@ 2020-11-11 11:07 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2020-11-11 11:07 UTC (permalink / raw)
  To: Amitesh Chandra
  Cc: Johan Hedberg, linux-bluetooth, open list, amitesh.chandra,
	ravi.nagarajan, cheneyni, Manoj Babulal

Hi Amitesh,

> Broadcom VSC uart_clock_setting is deprecated in
> newer controllers. Ignore error if the controller
> returns invalid or bad request error code.
> 
> Signed-off-by: Amitesh Chandra <amitesh.chandra@broadcom.com>
> Signed-off-by: Manoj Babulal <manoj.babulal@broadcom.com>
> ---
> drivers/bluetooth/hci_bcm.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
> index 680478f..d316788 100644
> --- a/drivers/bluetooth/hci_bcm.c
> +++ b/drivers/bluetooth/hci_bcm.c
> @@ -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);
> 	}

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-11 11:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-14  5:47 [PATCH 3/3] Bluetooth: hci_bcm: Ignore deprecated command fail case Amitesh Chandra
2020-11-11 11:07 ` Marcel Holtmann

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.