]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Multiple libusb backend fixes (STR #4098, STR #4100)
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Wed, 23 May 2012 22:47:01 +0000 (22:47 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Wed, 23 May 2012 22:47:01 +0000 (22:47 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10508 7a7537e8-13f0-0310-91df-b6672ffda945

CHANGES-1.5.txt
backend/usb-libusb.c

index 0ad7e379dff768c758aef645c3d1b9e56f4dd396..d8dda7d092f273f9f8d1306d688ccff85a356117 100644 (file)
@@ -3,6 +3,7 @@ CHANGES-1.5.txt
 
 CHANGES IN CUPS V1.5.4
 
+       - Multiple libusb backend fixes (STR #4098, STR #4100)
        - The IPP backend no longer tries to get the job status for printers
          that do not implement the required operation (STR #4083)
        - Sending a document in an unsupported format to an IPP printer now
index 7a1e7f4ca13396ea72c5053e73be0b4db3d67f34..5811fde1f0dfb3dd6a244efc0a079608e0201e27 100644 (file)
@@ -1089,9 +1089,45 @@ open_device(usb_printer_t *printer,      /* I - Printer */
   if (libusb_open(printer->device, &printer->handle) < 0)
     return (-1);
 
+  printer->usblp_attached = 0;
+
   if (verbose)
     fputs("STATE: +connecting-to-device\n", stderr);
 
+  if ((errcode = libusb_get_device_descriptor (printer->device, &devdesc)) < 0)
+  {
+    fprintf(stderr, "DEBUG: Failed to get device descriptor, code: %d\n",
+           errcode);
+    goto error;
+  }
+
+ /*
+  * Get the "usblp" kernel module out of the way. This backend only
+  * works without the module attached.
+  */
+
+  errcode = libusb_kernel_driver_active(printer->handle, printer->iface);
+  if (errcode == 0)
+    printer->usblp_attached = 0;
+  else if (errcode == 1)
+  {
+    printer->usblp_attached = 1;
+    if ((errcode =
+        libusb_detach_kernel_driver(printer->handle, printer->iface)) < 0)
+    {
+      fprintf(stderr, "DEBUG: Failed to detach \"usblp\" module from %04x:%04x\n",
+             devdesc.idVendor, devdesc.idProduct);
+      goto error;
+    }
+  }
+  else
+  {
+    printer->usblp_attached = 0;
+    fprintf(stderr, "DEBUG: Failed to check whether %04x:%04x has the \"usblp\" kernel module attached\n",
+             devdesc.idVendor, devdesc.idProduct);
+    goto error;
+  }
+
  /*
   * Set the desired configuration, but only if it needs changing. Some
   * printers (e.g., Samsung) don't like libusb_set_configuration. It will
@@ -1168,11 +1204,13 @@ open_device(usb_printer_t *printer,     /* I - Printer */
   while ((errcode = libusb_claim_interface(printer->handle, number1)) < 0)
   {
     if (errcode != LIBUSB_ERROR_BUSY)
+    {
       fprintf(stderr,
               "DEBUG: Failed to claim interface %d for %04x:%04x: %s\n",
               number1, devdesc.idVendor, devdesc.idProduct, strerror(errno));
 
-    goto error;
+      goto error;
+    }
   }
 
  /*
@@ -1192,12 +1230,14 @@ open_device(usb_printer_t *printer,     /* I - Printer */
           < 0)
     {
       if (errcode != LIBUSB_ERROR_BUSY)
+      {
         fprintf(stderr,
                 "DEBUG: Failed to set alternate interface %d for %04x:%04x: "
                 "%s\n",
                 number2, devdesc.idVendor, devdesc.idProduct, strerror(errno));
 
-      goto error;
+       goto error;
+      }
     }
   }