From 9e5a85bd108d9c22d316d9f86044d1780227d56d Mon Sep 17 00:00:00 2001 From: Gilles Boccon-Gibod Date: Fri, 25 Nov 2022 17:52:13 -0800 Subject: [PATCH] use libusb auto-detach feature --- bumble/transport/usb.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bumble/transport/usb.py b/bumble/transport/usb.py index 91b22b61..1133a5ea 100644 --- a/bumble/transport/usb.py +++ b/bumble/transport/usb.py @@ -414,14 +414,13 @@ def find_endpoints(device): device = found.open() - # Detach the kernel driver if supported and needed + # Auto-detach the kernel driver if supported if usb1.hasCapability(usb1.CAP_SUPPORTS_DETACH_KERNEL_DRIVER): try: - if device.kernelDriverActive(interface): - logger.debug("detaching kernel driver") - device.detachKernelDriver(interface) - except usb1.USBError: - pass + logger.debug('auto-detaching kernel driver') + device.setAutoDetachKernelDriver(True) + except usb1.USBError as error: + logger.warning(f'unable to auto-detach kernel driver: {error}') # Set the configuration if needed try: