Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression for drivers with no detach support #16

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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