Skip to content

Commit

Permalink
Merge pull request #16 from claui/fix-kernel-driver-compat
Browse files Browse the repository at this point in the history
Fix regression for drivers with no detach support
  • Loading branch information
claui authored Sep 4, 2024
2 parents 4ac486c + 4bbc7f1 commit 89dd527
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions itchcraft/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,26 @@ def serial_number(self) -> Optional[str]:
def _detach_driver_if_needed(
device: usb.core.Device, interface_index: usb_types.InterfaceIndex
) -> None:
if device.is_kernel_driver_active(interface_index):
try:
want_to_detach_driver = device.is_kernel_driver_active(
interface_index
)
except NotImplementedError:
logger.debug(
'Detaching driver from interface #%d',
'Note: unable to detach driver for interface #%d; proceeding',
interface_index,
)
device.detach_kernel_driver(interface_index)
logger.debug('Driver successfully detached')
want_to_detach_driver = False

if not want_to_detach_driver:
return

logger.debug(
'Detaching driver from interface #%d',
interface_index,
)
device.detach_kernel_driver(interface_index)
logger.debug('Driver successfully detached')


def _find_endpoint(
Expand Down

0 comments on commit 89dd527

Please sign in to comment.