[PATCH] USB: shuttle_usbat: Hardcode detection of HP CDRW devices
authorPeter Chubb <peterc@gelato.unsw.edu.au>
Tue, 2 May 2006 17:29:34 +0000 (18:29 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 21 Jun 2006 22:04:10 +0000 (15:04 -0700)
Use USB vendor and product IDs to determine whether the attached
device is a CDROM or a Flash device.  Daniel Drake says that the
*same* vendor and product IDs for non-HP vendor ID could be either
flash or cdrom, so try to probe for them.

Signed-off-by: Peter Chubb <peterc@gelato.unsw.edu.au>
Signed-off-by: Daniel Drake <dsd@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/storage/shuttle_usbat.c
drivers/usb/storage/shuttle_usbat.h
drivers/usb/storage/unusual_devs.h

index 92095b858eb7ff4ad532119f624ccf1d6de9e27f..8fcec01dc622f29f9fb3f8e6c50030b523b16730 100644 (file)
@@ -893,22 +893,28 @@ static int usbat_identify_device(struct us_data *us,
  * Set the transport function based on the device type
  */
 static int usbat_set_transport(struct us_data *us,
-                              struct usbat_info *info)
+                              struct usbat_info *info,
+                              int devicetype)
 {
-       int rc;
 
-       if (!info->devicetype) {
-               rc = usbat_identify_device(us, info);
-               if (rc != USB_STOR_TRANSPORT_GOOD) {
-                       US_DEBUGP("usbat_set_transport: Could not identify device\n");
-                       return 1;
-               }
-       }
+       if (!info->devicetype)
+               info->devicetype = devicetype;
 
-       if (usbat_get_device_type(us) == USBAT_DEV_HP8200)
+       if (!info->devicetype)
+               usbat_identify_device(us, info);
+
+       switch (info->devicetype) {
+       default:
+               return USB_STOR_TRANSPORT_ERROR;
+
+       case  USBAT_DEV_HP8200:
                us->transport = usbat_hp8200e_transport;
-       else if (usbat_get_device_type(us) == USBAT_DEV_FLASH)
+               break;
+
+       case USBAT_DEV_FLASH:
                us->transport = usbat_flash_transport;
+               break;
+       }
 
        return 0;
 }
@@ -1316,7 +1322,7 @@ static int usbat_select_and_test_registers(struct us_data *us)
 /*
  * Initialize the USBAT processor and the storage device
  */
-int init_usbat(struct us_data *us)
+static int init_usbat(struct us_data *us, int devicetype)
 {
        int rc;
        struct usbat_info *info;
@@ -1398,7 +1404,7 @@ int init_usbat(struct us_data *us)
        US_DEBUGP("INIT 9\n");
 
        /* At this point, we need to detect which device we are using */
-       if (usbat_set_transport(us, info))
+       if (usbat_set_transport(us, info, devicetype))
                return USB_STOR_TRANSPORT_ERROR;
 
        US_DEBUGP("INIT 10\n");
@@ -1701,6 +1707,22 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us)
        return USB_STOR_TRANSPORT_FAILED;
 }
 
+int init_usbat_cd(struct us_data *us)
+{
+       return init_usbat(us, USBAT_DEV_HP8200);
+}
+
+
+int init_usbat_flash(struct us_data *us)
+{
+       return init_usbat(us, USBAT_DEV_FLASH);
+}
+
+int init_usbat_probe(struct us_data *us)
+{
+       return init_usbat(us, 0);
+}
+
 /*
  * Default transport function. Attempts to detect which transport function
  * should be called, makes it the new default, and calls it.
@@ -1714,9 +1736,8 @@ int usbat_transport(struct scsi_cmnd *srb, struct us_data *us)
 {
        struct usbat_info *info = (struct usbat_info*) (us->extra);
 
-       if (usbat_set_transport(us, info))
+       if (usbat_set_transport(us, info, 0))
                return USB_STOR_TRANSPORT_ERROR;
 
        return us->transport(srb, us);  
 }
-
index 25e7d8b340b84db1f315d895623b7c322e655480..3ddf143a1dec25c05a805c0fd33f625a51a21326 100644 (file)
 #define USBAT_FEAT_ET2 0x01
 
 extern int usbat_transport(struct scsi_cmnd *srb, struct us_data *us);
-extern int init_usbat(struct us_data *us);
+extern int init_usbat_cd(struct us_data *us);
+extern int init_usbat_flash(struct us_data *us);
+extern int init_usbat_probe(struct us_data *us);
 
 struct usbat_info {
        int devicetype;
index aec5ea8682d5379cd461fe6a9376bfbcacd70b49..f24fa12eaedf937ccf55d19b11f5d8974b0838b0 100644 (file)
@@ -78,12 +78,12 @@ UNUSUAL_DEV(  0x03f0, 0x0107, 0x0200, 0x0200,
 UNUSUAL_DEV(  0x03f0, 0x0207, 0x0001, 0x0001, 
                "HP",
                "CD-Writer+ 8200e",
-               US_SC_8070, US_PR_USBAT, init_usbat, 0),
+               US_SC_8070, US_PR_USBAT, init_usbat_cd, 0),
 
 UNUSUAL_DEV(  0x03f0, 0x0307, 0x0001, 0x0001, 
                "HP",
                "CD-Writer+ CD-4e",
-               US_SC_8070, US_PR_USBAT, init_usbat, 0),
+               US_SC_8070, US_PR_USBAT, init_usbat_cd, 0),
 #endif
 
 /* Reported by Sebastian Kapfer <sebastian_kapfer@gmx.net>
@@ -393,7 +393,7 @@ UNUSUAL_DEV(  0x04fc, 0x80c2, 0x0100, 0x0100,
 UNUSUAL_DEV(  0x04e6, 0x1010, 0x0000, 0x9999,
                "Shuttle/SCM",
                "USBAT-02",
-               US_SC_SCSI, US_PR_USBAT, init_usbat,
+               US_SC_SCSI, US_PR_USBAT, init_usbat_probe,
                US_FL_SINGLE_LUN),
 #endif
 
@@ -797,7 +797,7 @@ UNUSUAL_DEV(  0x0781, 0x0002, 0x0009, 0x0009,
 UNUSUAL_DEV(  0x0781, 0x0005, 0x0005, 0x0005,
                "Sandisk",
                "ImageMate SDDR-05b",
-               US_SC_SCSI, US_PR_USBAT, init_usbat,
+               US_SC_SCSI, US_PR_USBAT, init_usbat_flash,
                US_FL_SINGLE_LUN ),
 #endif