summaryrefslogtreecommitdiffstats
path: root/src/usb-device.c
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2014-11-18 23:51:04 +0100
committerPali Rohár <pali.rohar@gmail.com>2014-11-18 23:51:04 +0100
commitbc4aeefab5c80308ef96ea33e3085c72094b622b (patch)
treef7c0e5fc71cefa878c31d394fe09f70c15b5d580 /src/usb-device.c
parentea980459f1a903052f831510e03c08109f2157c4 (diff)
download0xFFFF-bc4aeefab5c80308ef96ea33e3085c72094b622b.tar.bz2
usb-device: Do not claim USB interface in raw disk mode
Diffstat (limited to 'src/usb-device.c')
-rw-r--r--src/usb-device.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/usb-device.c b/src/usb-device.c
index 0ef55b4..1f9b403 100644
--- a/src/usb-device.c
+++ b/src/usb-device.c
@@ -42,9 +42,9 @@
static struct usb_flash_device usb_devices[] = {
{ 0x0421, 0x0105, 2, 1, -1, FLASH_NOLO, { DEVICE_SU_18, DEVICE_RX_44, DEVICE_RX_48, DEVICE_RX_51, 0 } },
{ 0x0421, 0x0106, 0, -1, -1, FLASH_COLD, { DEVICE_RX_51, 0 } },
- { 0x0421, 0x01c7, 0, -1, -1, FLASH_DISK, { DEVICE_RX_51, 0 } },
+ { 0x0421, 0x01c7, -1, -1, -1, FLASH_DISK, { DEVICE_RX_51, 0 } },
{ 0x0421, 0x01c8, 1, 1, -1, FLASH_MKII, { DEVICE_RX_51, 0 } },
- { 0x0421, 0x0431, 0, -1, -1, FLASH_DISK, { DEVICE_SU_18, DEVICE_RX_34, 0 } },
+ { 0x0421, 0x0431, -1, -1, -1, FLASH_DISK, { DEVICE_SU_18, DEVICE_RX_34, 0 } },
{ 0x0421, 0x3f00, 2, 1, -1, FLASH_NOLO, { DEVICE_RX_34, 0 } },
};
@@ -90,6 +90,9 @@ static void usb_reattach_kernel_driver(usb_dev_handle * udev, int interface) {
.data = NULL,
};
+ if ( interface < 0 )
+ return;
+
usb_release_interface(udev, interface);
ioctl(*((int *)udev), _IOWR('U', 18, command), &command);
#endif
@@ -159,18 +162,22 @@ static struct usb_device_info * usb_device_is_valid(struct usb_device * dev) {
usb_descriptor_info_print(udev, dev, product, sizeof(product));
+ if ( usb_devices[i].interface >= 0 ) {
+
#ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP
- PRINTF_LINE("Detaching kernel from USB interface...");
- usb_detach_kernel_driver_np(udev, usb_devices[i].interface);
+ PRINTF_LINE("Detaching kernel from USB interface...");
+ usb_detach_kernel_driver_np(udev, usb_devices[i].interface);
#endif
- PRINTF_LINE("Claiming USB interface...");
- if ( usb_claim_interface(udev, usb_devices[i].interface) < 0 ) {
- PRINTF_ERROR("usb_claim_interface failed");
- fprintf(stderr, "\n");
- usb_reattach_kernel_driver(udev, usb_devices[i].interface);
- usb_close(udev);
- return NULL;
+ PRINTF_LINE("Claiming USB interface...");
+ if ( usb_claim_interface(udev, usb_devices[i].interface) < 0 ) {
+ PRINTF_ERROR("usb_claim_interface failed");
+ fprintf(stderr, "\n");
+ usb_reattach_kernel_driver(udev, usb_devices[i].interface);
+ usb_close(udev);
+ return NULL;
+ }
+
}
if ( usb_devices[i].alternate >= 0 ) {