Blob Blame History Raw
diff -ur libmtp-1.0.6-orig/src/libusb-glue.c libmtp-1.0.6/src/libusb-glue.c
--- libmtp-1.0.6-orig/src/libusb-glue.c	2011-06-23 19:33:51.736858307 +0200
+++ libmtp-1.0.6/src/libusb-glue.c	2011-10-22 23:31:01.766206773 +0200
@@ -275,6 +275,13 @@
 	    &dev->config[i].interface[j].altsetting[k];
 
 	  /*
+	   * MTP interfaces have three endpoints, two bulk and one
+	   * interrupt. Don't probe anything else.
+	   */
+	  if (intf->bNumEndpoints != 3)
+	    continue;
+
+	  /*
 	   * We only want to probe for the OS descriptor if the
 	   * device is USB_CLASS_VENDOR_SPEC or one of the interfaces
 	   * in it is, so flag if we find an interface like this.
@@ -1753,6 +1760,16 @@
     usb_resetep(ptp_usb->handle, ptp_usb->outep);
     usb_release_interface(ptp_usb->handle, (int) ptp_usb->interface);
   }
+  if (FLAG_FORCE_RESET_ON_CLOSE(ptp_usb)) {
+    /*
+     * Some devices really love to get reset after being
+     * disconnected. Again, since Windows never disconnects
+     * a device closing behaviour is seldom or never exercised
+     * on devices when engineered and often error prone.
+     * Reset may help some.
+     */
+    usb_reset(ptp_usb->handle);
+  }
   usb_close(ptp_usb->handle);
 }
 
@@ -1911,10 +1928,9 @@
    */
   if ((ret = ptp_opensession(params, 1)) == PTP_ERROR_IO) {
     LIBMTP_ERROR("PTP_ERROR_IO: failed to open session, trying again after resetting USB interface\n");
-    close_usb(ptp_usb);
-
     LIBMTP_ERROR("LIBMTP libusb: Attempt to reset device\n");
     usb_reset(ptp_usb->handle);
+    close_usb(ptp_usb);
 
     if(init_ptp_usb(params, ptp_usb, libusb_device) <0) {
       LIBMTP_ERROR("LIBMTP PANIC: Could not init USB on second attempt\n");
diff -ur libmtp-1.0.6-orig/src/libusb-glue.h libmtp-1.0.6/src/libusb-glue.h
--- libmtp-1.0.6-orig/src/libusb-glue.h	2011-06-23 19:33:51.736858307 +0200
+++ libmtp-1.0.6/src/libusb-glue.h	2011-10-22 23:32:29.377583765 +0200
@@ -136,6 +136,10 @@
   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_UNIQUE_FILENAMES)
 #define FLAG_SWITCH_MODE_BLACKBERRY(a) \
   ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_SWITCH_MODE_BLACKBERRY)
+#define FLAG_LONG_TIMEOUT(a) \
+  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_LONG_TIMEOUT)
+#define FLAG_FORCE_RESET_ON_CLOSE(a) \
+  ((a)->rawdevice.device_entry.device_flags & DEVICE_FLAG_FORCE_RESET_ON_CLOSE)
 
 /* connect_first_device return codes */
 #define PTP_CD_RC_CONNECTED	0
Endast i libmtp-1.0.6/src: libusb-glue.h.orig
diff -ur libmtp-1.0.6-orig/util/mtp-hotplug.c libmtp-1.0.6/util/mtp-hotplug.c
--- libmtp-1.0.6-orig/util/mtp-hotplug.c	2011-06-23 19:33:51.713858478 +0200
+++ libmtp-1.0.6/util/mtp-hotplug.c	2011-10-22 23:31:01.766206773 +0200
@@ -140,6 +140,12 @@
       printf("SUBSYSTEM==\"usb\", GOTO=\"libmtp_usb_rules\"\n"
 	     "GOTO=\"libmtp_rules_end\"\n\n"
 	     "LABEL=\"libmtp_usb_rules\"\n\n");
+      printf("# Some sensitive devices we surely don\'t wanna probe, color instruments\n");
+      printf("ATTR{idVendor}==\"0670\", GOTO=\"libmtp_rules_end\"\n");
+      printf("ATTR{idVendor}==\"0765\", GOTO=\"libmtp_rules_end\"\n");
+      printf("ATTR{idVendor}==\"085c\", GOTO=\"libmtp_rules_end\"\n");
+      printf("ATTR{idVendor}==\"0971\", GOTO=\"libmtp_rules_end\"\n");
+      printf("\n");
       break;
     case style_udev_old:
       printf("# UDEV-style hotplug map for libmtp\n");
@@ -242,7 +248,7 @@
      * every USB device that is either PTP or vendor specific
      */
     printf("\n# Autoprobe vendor-specific, communication and PTP devices\n");
-    printf("ENV{ID_MTP_DEVICE}!=\"1\", ATTR{bDeviceClass}==\"00|02|06|ff\", PROGRAM=\"%smtp-probe /sys$env{DEVPATH} $attr{busnum} $attr{devnum}\", RESULT==\"1\", %s", mtp_probe_dir, action);
+    printf("ENV{ID_MTP_DEVICE}!=\"1\", ENV{MTP_NO_PROBE}!=\"1\", ENV{COLOR_MEASUREMENT_DEVICE}!=\"1\", ENV{libsane_matched}!=\"yes\", ATTR{bDeviceClass}==\"00|02|06|ef|ff\", PROGRAM=\"%smtp-probe /sys$env{DEVPATH} $attr{busnum} $attr{devnum}\", RESULT==\"1\", %s", mtp_probe_dir, action);
     if (udev_group != NULL) printf(", GROUP=\"%s\"", udev_group);
     if (udev_mode != NULL) printf(", MODE=\"%s\"", udev_mode);
     printf("\n");