Skip to content

Commit 017a01c

Browse files
Raghuram Hegdeholtmann
authored andcommitted
Bluetooth: btusb: Add shutdown routine for BTUSB_INTEL_NEW devices
If BT operations (BREDR inquiry/LE scan) were triggered through the stack, followed by BT turn off through 'hciconfig hci0 down', the controller would still be active and consume power. Also, there is a possibility that a race condition/ synchronization issue might arise on the subsequent BT turn on, as the controller might try to push the events that were queued up before processing the HCI Reset command. btusb_shutdown_intel_new routine shall reset the controller and stop all BT operation. Advantages: 1. Power save on the platform 2. Host and controller will be in Sync. Signed-off-by: Raghuram Hegde <[email protected]> Signed-off-by: Chethan T N <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 2de66bb commit 017a01c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

drivers/bluetooth/btusb.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,6 +2434,24 @@ static int btusb_shutdown_intel(struct hci_dev *hdev)
24342434
return 0;
24352435
}
24362436

2437+
static int btusb_shutdown_intel_new(struct hci_dev *hdev)
2438+
{
2439+
struct sk_buff *skb;
2440+
2441+
/* Send HCI Reset to the controller to stop any BT activity which
2442+
* were triggered. This will help to save power and maintain the
2443+
* sync b/w Host and controller
2444+
*/
2445+
skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
2446+
if (IS_ERR(skb)) {
2447+
bt_dev_err(hdev, "HCI reset during shutdown failed");
2448+
return PTR_ERR(skb);
2449+
}
2450+
kfree_skb(skb);
2451+
2452+
return 0;
2453+
}
2454+
24372455
#ifdef CONFIG_PM
24382456
/* Configure an out-of-band gpio as wake-up pin, if specified in device tree */
24392457
static int marvell_config_oob_wake(struct hci_dev *hdev)
@@ -3139,6 +3157,7 @@ static int btusb_probe(struct usb_interface *intf,
31393157
hdev->manufacturer = 2;
31403158
hdev->send = btusb_send_frame_intel;
31413159
hdev->setup = btusb_setup_intel_new;
3160+
hdev->shutdown = btusb_shutdown_intel_new;
31423161
hdev->hw_error = btintel_hw_error;
31433162
hdev->set_diag = btintel_set_diag;
31443163
hdev->set_bdaddr = btintel_set_bdaddr;

0 commit comments

Comments
 (0)