Skip to content

Commit 7bd9fb0

Browse files
jason77-wangholtmann
authored andcommitted
Bluetooth: btusb: Fix the autosuspend enable and disable
I tried to disable the autosuspend on btusb through the module parameter enable_autosuspend, this parameter is set to N, but the usb bluetooth device is still runtime suspended. $ cat /sys/module/btusb/parameters/enable_autosuspend N $ cat /sys/bus/usb/devices/3-10/power/runtime_status suspended $ cat /sys/bus/usb/devices/3-10/power/runtime_suspended_time 65187 We already set ".supports_autosuspend = 1" in the usb_driver, this device will be set autosuspend enabled by usb core, we don't need to call usb_enable_autosuspend() in the btusb_probe(). Instead if users set the parameter enable_autosuspend to N, we need to call usb_disable_autosuspend() in the btusb_probe(). After this change and set the parameter to N, we could see the device is not runtime suspended anymore. $ cat /sys/module/btusb/parameters/enable_autosuspend N $ cat /sys/bus/usb/devices/3-10/power/runtime_status active $ cat /sys/bus/usb/devices/3-10/power/runtime_suspended_time 0 And if we disable the autosuspend in the btusb_probe(), we need to enable the autosuspend in the disconnect(), this could guarantee that the device could be runtime suspended after we rmmod the btusb. Signed-off-by: Hui Wang <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent b1810fe commit 7bd9fb0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/bluetooth/btusb.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4840,8 +4840,8 @@ static int btusb_probe(struct usb_interface *intf,
48404840
data->diag = NULL;
48414841
}
48424842

4843-
if (enable_autosuspend)
4844-
usb_enable_autosuspend(data->udev);
4843+
if (!enable_autosuspend)
4844+
usb_disable_autosuspend(data->udev);
48454845

48464846
err = hci_register_dev(hdev);
48474847
if (err < 0)
@@ -4901,6 +4901,9 @@ static void btusb_disconnect(struct usb_interface *intf)
49014901
gpiod_put(data->reset_gpio);
49024902

49034903
hci_free_dev(hdev);
4904+
4905+
if (!enable_autosuspend)
4906+
usb_enable_autosuspend(data->udev);
49044907
}
49054908

49064909
#ifdef CONFIG_PM

0 commit comments

Comments
 (0)