This patch implements US_PR_DEVICE and US_SC_DEVICE, which have the meaning
'use the device's value -- no override'.  This should make maintance
easier, and also allow for those few devices that change their descriptors
depending on what they are connected to.

This will also print a message to help us identify entries that can be
pruned.

Finally, it removes a couple of dead flags.

Greg, please apply.

Matt

# This is a BitKeeper generated patch for the following project:
# Project Name: greg k-h's linux 2.5 USB kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#                  ChangeSet    1.1962  -> 1.1963 
#       drivers/usb/storage/usb.h       1.38    -> 1.39   
#       drivers/usb/storage/protocol.h  1.3     -> 1.4    
#       drivers/usb/storage/transport.h 1.38    -> 1.39   
#       drivers/usb/storage/unusual_devs.h      1.46    -> 1.47   
#       drivers/usb/storage/usb.c       1.89    -> 1.90   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/06/15      [EMAIL PROTECTED]       1.1963
# Remove dead flags, and implement US_{PR|SC}_DEVICE values which do not
# override the device's advertised settings.
# --------------------------------------------
#
diff -Nru a/drivers/usb/storage/protocol.h b/drivers/usb/storage/protocol.h
--- a/drivers/usb/storage/protocol.h    Sun Jun 15 16:23:52 2003
+++ b/drivers/usb/storage/protocol.h    Sun Jun 15 16:23:52 2003
@@ -57,6 +57,8 @@
 #define US_SC_MIN      US_SC_RBC
 #define US_SC_MAX      US_SC_ISD200
 
+#define US_SC_DEVICE   0xff            /* Use device's value */
+
 extern void usb_stor_ATAPI_command(Scsi_Cmnd*, struct us_data*);
 extern void usb_stor_qic157_command(Scsi_Cmnd*, struct us_data*);
 extern void usb_stor_ufi_command(Scsi_Cmnd*, struct us_data*);
diff -Nru a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h
--- a/drivers/usb/storage/transport.h   Sun Jun 15 16:23:52 2003
+++ b/drivers/usb/storage/transport.h   Sun Jun 15 16:23:52 2003
@@ -63,16 +63,18 @@
 #define US_PR_DPCM_USB  0xf0           /* Combination CB/SDDR09 */
 
 #ifdef CONFIG_USB_STORAGE_FREECOM
-#define US_PR_FREECOM   0xf1       /* Freecom */
+#define US_PR_FREECOM   0xf1           /* Freecom */
 #endif
 
 #ifdef CONFIG_USB_STORAGE_DATAFAB
-#define US_PR_DATAFAB   0xf2       /* Datafab chipsets */
+#define US_PR_DATAFAB   0xf2           /* Datafab chipsets */
 #endif
 
 #ifdef CONFIG_USB_STORAGE_JUMPSHOT
-#define US_PR_JUMPSHOT  0xf3       /* Lexar Jumpshot */
+#define US_PR_JUMPSHOT  0xf3           /* Lexar Jumpshot */
 #endif
+
+#define US_PR_DEVICE   0xff            /* Use device's value */
 
 /*
  * Bulk only data structures
diff -Nru a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
--- a/drivers/usb/storage/unusual_devs.h        Sun Jun 15 16:23:52 2003
+++ b/drivers/usb/storage/unusual_devs.h        Sun Jun 15 16:23:52 2003
@@ -75,28 +75,26 @@
 
 /* Deduced by Jonathan Woithe <[EMAIL PROTECTED]>
  * Entry needed for flags: US_FL_FIX_INQUIRY because initial inquiry message
- * always fails and confuses drive; without US_FL_START_STOP, drive accesses
- * (read or write) all fail.
+ * always fails and confuses drive.
  */
 UNUSUAL_DEV(  0x0411, 0x001c, 0x0113, 0x0113,
                "Buffalo",
                "DUB-P40G HDD",
-               US_SC_SCSI, US_PR_BULK, NULL,
-               US_FL_FIX_INQUIRY | US_FL_START_STOP),
+               US_SC_DEVICE, US_PR_DEVICE, NULL,
+               US_FL_FIX_INQUIRY ),
 
 #ifdef CONFIG_USB_STORAGE_DPCM
 UNUSUAL_DEV(  0x0436, 0x0005, 0x0100, 0x0100,
                "Microtech",
                "CameraMate (DPCM_USB)",
-               US_SC_SCSI, US_PR_DPCM_USB, NULL,
-               US_FL_START_STOP ),
+               US_SC_SCSI, US_PR_DPCM_USB, NULL, 0 ),
 #endif
 
 /* Made with the help of Edd Dumbill <[EMAIL PROTECTED]> */
 UNUSUAL_DEV(  0x0451, 0x5409, 0x0001, 0x0001,
                "Frontier Labs",
                "Nex II Digital",
-               US_SC_SCSI, US_PR_BULK, NULL, US_FL_START_STOP),
+               US_SC_SCSI, US_PR_BULK, NULL, 0),
 
 /* Patch submitted by Philipp Friedrich <[EMAIL PROTECTED]> */
 UNUSUAL_DEV(  0x0482, 0x0100, 0x0100, 0x0100,
@@ -124,15 +122,6 @@
                "785EPX Storage",
                US_SC_SCSI, US_PR_BULK, NULL, US_FL_SINGLE_LUN),
 
-/* Reported by Jan Willamowius <[EMAIL PROTECTED]>
- * The device needs the flags only.
- */
-UNUSUAL_DEV(  0x04c8, 0x0723, 0x0000, 0x9999,
-               "Konica",
-               "KD-200Z",
-               US_SC_SCSI, US_PR_BULK, NULL,
-               US_FL_START_STOP),
-
 UNUSUAL_DEV(  0x04cb, 0x0100, 0x0000, 0x2210,
                "Fujifilm",
                "FinePix 1400Zoom",
@@ -144,7 +133,7 @@
 UNUSUAL_DEV(  0x04ce, 0x0002, 0x0074, 0x0074,
                "ScanLogic",
                "SL11R-IDE",
-               US_SC_SCSI, US_PR_BULK, NULL,
+               US_SC_DEVICE, US_PR_DEVICE, NULL,
                US_FL_FIX_INQUIRY),
 
 /* Reported by Kriston Fincher <[EMAIL PROTECTED]>
@@ -183,14 +172,14 @@
                "Sandisk",
                "ImageMate SDDR09",
                US_SC_SCSI, US_PR_EUSB_SDDR09, NULL,
-               US_FL_SINGLE_LUN | US_FL_START_STOP ),
+               US_FL_SINGLE_LUN ),
 
 /* This entry is from [EMAIL PROTECTED] */
 UNUSUAL_DEV(  0x04e6, 0x0005, 0x0100, 0x0208,
                "SCM Microsystems",
                "eUSB SmartMedia / CompactFlash Adapter",
                US_SC_SCSI, US_PR_DPCM_USB, sddr09_init, 
-               US_FL_START_STOP), 
+               0), 
 #endif
 
 UNUSUAL_DEV(  0x04e6, 0x0006, 0x0100, 0x0205, 
@@ -247,40 +236,40 @@
                "Iomega",
                "USB Clik! 40",
                US_SC_8070, US_PR_BULK, NULL,
-               US_FL_FIX_INQUIRY | US_FL_START_STOP ),
+               US_FL_FIX_INQUIRY ),
 
 /* This entry is needed because the device reports Sub=ff */
 UNUSUAL_DEV(  0x054c, 0x0010, 0x0106, 0x0450, 
                "Sony",
                "DSC-S30/S70/S75/505V/F505/F707/F717/P8", 
                US_SC_SCSI, US_PR_CB, NULL,
-               US_FL_SINGLE_LUN | US_FL_START_STOP | US_FL_MODE_XLATE ),
+               US_FL_SINGLE_LUN | US_FL_MODE_XLATE ),
 
 /* Reported by [EMAIL PROTECTED] */
 UNUSUAL_DEV(  0x054c, 0x0025, 0x0100, 0x0100, 
                "Sony",
                "Memorystick NW-MS7",
                US_SC_UFI, US_PR_CB, NULL,
-               US_FL_SINGLE_LUN | US_FL_START_STOP ),
+               US_FL_SINGLE_LUN ),
 
 UNUSUAL_DEV(  0x054c, 0x002d, 0x0100, 0x0100, 
                "Sony",
                "Memorystick MSAC-US1",
                US_SC_UFI, US_PR_CB, NULL,
-               US_FL_SINGLE_LUN | US_FL_START_STOP ),
+               US_FL_SINGLE_LUN ),
 
 /* Submitted by Klaus Mueller <[EMAIL PROTECTED]> */
 UNUSUAL_DEV(  0x054c, 0x002e, 0x0106, 0x0310, 
                "Sony",
                "Handycam",
                US_SC_SCSI, US_PR_CB, NULL,
-               US_FL_SINGLE_LUN | US_FL_START_STOP | US_FL_MODE_XLATE),
+               US_FL_SINGLE_LUN | US_FL_MODE_XLATE),
 
 UNUSUAL_DEV(  0x054c, 0x0032, 0x0000, 0x9999,
                "Sony",
                "Memorystick MSC-U01N",
                US_SC_UFI, US_PR_CB, NULL,
-               US_FL_SINGLE_LUN | US_FL_START_STOP ),
+               US_FL_SINGLE_LUN ),
                
 /* Submitted by Nathan Babb <[EMAIL PROTECTED]> */
 UNUSUAL_DEV(  0x054c, 0x006d, 0x0000, 0x9999,
@@ -316,7 +305,7 @@
 UNUSUAL_DEV( 0x0a17, 0x0004, 0x1000, 0x1000,
                 "Pentax",
                 "Optio 2/3/400",
-                US_SC_8070, US_PR_CBI, NULL,
+                US_SC_DEVICE, US_PR_DEVICE, NULL,
                 US_FL_FIX_INQUIRY ),
 
 /* Submitted by Per Winkvist <[EMAIL PROTECTED]> */
@@ -380,7 +369,7 @@
 UNUSUAL_DEV(  0x05e3, 0x0700, 0x0000, 0xffff,
                "SIIG",
                "CompactFlash Card Reader",
-               US_SC_SCSI, US_PR_BULK, NULL,
+               US_SC_DEVICE, US_PR_DEVICE, NULL,
                US_FL_FIX_INQUIRY ),
 
 /* Reported by Peter Marks <[EMAIL PROTECTED]>
@@ -393,7 +382,7 @@
 UNUSUAL_DEV(  0x05e3, 0x0702, 0x0000, 0x0001,
                "EagleTec",
                "External Hard Disk",
-               US_SC_SCSI, US_PR_BULK, NULL,
+               US_SC_DEVICE, US_PR_DEVICE, NULL,
                US_FL_FIX_INQUIRY ),
 
 UNUSUAL_DEV(  0x05e3, 0x0700, 0x0000, 0x9999,
@@ -412,25 +401,9 @@
                "Olympus",
                "Camedia MAUSB-2",
                US_SC_SCSI, US_PR_EUSB_SDDR09, NULL,
-               US_FL_SINGLE_LUN | US_FL_START_STOP ),
+               US_FL_SINGLE_LUN ),
 #endif
 
-/* Submitted by [EMAIL PROTECTED]
- * Needed for START_STOP flag, but that is unconfirmed */
-UNUSUAL_DEV( 0x0686, 0x4006, 0x0001, 0x0001,
-               "Minolta",
-               "Dimage S304",
-               US_SC_SCSI, US_PR_BULK, NULL,
-               US_FL_START_STOP ),
-
-/* Submitted by [EMAIL PROTECTED]
- * Needed for START_STOP flag */
-UNUSUAL_DEV( 0x0686, 0x4007, 0x0001, 0x0001,
-               "Minolta",
-               "Dimage S304",
-               US_SC_SCSI, US_PR_BULK, NULL,
-               US_FL_START_STOP ),
-
 UNUSUAL_DEV(  0x0693, 0x0002, 0x0100, 0x0100, 
                "Hagiwara",
                "FlashGate SmartMedia",
@@ -445,13 +418,12 @@
                "Sandisk",
                "ImageMate SDDR-05a",
                US_SC_SCSI, US_PR_CB, NULL,
-               US_FL_SINGLE_LUN | US_FL_START_STOP),
+               US_FL_SINGLE_LUN ),
 
 UNUSUAL_DEV(  0x0781, 0x0002, 0x0009, 0x0009, 
                "Sandisk",
                "ImageMate SDDR-31",
-               US_SC_SCSI, US_PR_BULK, NULL,
-               US_FL_IGNORE_SER),
+               US_SC_SCSI, US_PR_BULK, NULL, 0 ),
 
 UNUSUAL_DEV(  0x0781, 0x0100, 0x0100, 0x0100,
                "Sandisk",
@@ -464,7 +436,7 @@
                "Sandisk",
                "ImageMate SDDR-09",
                US_SC_SCSI, US_PR_EUSB_SDDR09, NULL,
-               US_FL_SINGLE_LUN | US_FL_START_STOP ),
+               US_FL_SINGLE_LUN ),
 #endif
 
 #ifdef CONFIG_USB_STORAGE_FREECOM
@@ -490,8 +462,7 @@
 UNUSUAL_DEV(  0x07af, 0x0006, 0x0100, 0x0100,
                "Microtech",
                "CameraMate (DPCM_USB)",
-               US_SC_SCSI, US_PR_DPCM_USB, NULL,
-               US_FL_START_STOP ),
+               US_SC_SCSI, US_PR_DPCM_USB, NULL, 0 ),
 #endif
 
 #ifdef CONFIG_USB_STORAGE_DATAFAB
@@ -568,7 +539,7 @@
 UNUSUAL_DEV(  0x07c4, 0xa400, 0x0000, 0xffff,
                "Datafab",
                "KECF-USB",
-               US_SC_SCSI, US_PR_BULK, NULL,
+               US_SC_DEVICE, US_PR_DEVICE, NULL,
                US_FL_FIX_INQUIRY ),
 
 /* Casio QV 2x00/3x00/4000/8000 digital still cameras are not conformant
@@ -629,20 +600,7 @@
                "Global Channel Solutions",
                "EasyDisk EDxxxx",
                US_SC_SCSI, US_PR_BULK, NULL,
-               US_FL_MODE_XLATE | US_FL_START_STOP | US_FL_FIX_INQUIRY ),
-
-/* Submitted by Brian Hall <[EMAIL PROTECTED]>
- * Needed for START_STOP flag */
-UNUSUAL_DEV(  0x0c76, 0x0003, 0x0100, 0x0100,
-               "JMTek",
-               "USBDrive",
-               US_SC_SCSI, US_PR_BULK, NULL,
-               US_FL_START_STOP ),
-UNUSUAL_DEV(  0x0c76, 0x0005, 0x0100, 0x0100,
-               "JMTek",
-               "USBDrive",
-               US_SC_SCSI, US_PR_BULK, NULL,
-               US_FL_START_STOP ),
+               US_FL_MODE_XLATE | US_FL_FIX_INQUIRY ),
 
 /* Reported by Dan Pilone <[EMAIL PROTECTED]>
  * The device needs the flags only.
@@ -652,8 +610,8 @@
 UNUSUAL_DEV(  0x1065, 0x2136, 0x0000, 0x9999,
                "CCYU TECHNOLOGY",
                "EasyDisk Portable Device",
-               US_SC_SCSI, US_PR_BULK, NULL,
-               US_FL_MODE_XLATE | US_FL_START_STOP),
+               US_SC_DEVICE, US_PR_DEVICE, NULL,
+               US_FL_MODE_XLATE ),
 
 #ifdef CONFIG_USB_STORAGE_SDDR55
 UNUSUAL_DEV(  0x55aa, 0xa103, 0x0000, 0x9999, 
@@ -670,5 +628,5 @@
        "AIPTEK",
        "PocketCAM 3Mega",
        US_SC_SCSI, US_PR_BULK, NULL,
-       US_FL_MODE_XLATE | US_FL_START_STOP),
+       US_FL_MODE_XLATE ),
 
diff -Nru a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
--- a/drivers/usb/storage/usb.c Sun Jun 15 16:23:52 2003
+++ b/drivers/usb/storage/usb.c Sun Jun 15 16:23:52 2003
@@ -102,8 +102,6 @@
 /* The entries in this table, except for final ones here
  * (USB_MASS_STORAGE_CLASS and the empty entry), correspond,
  * line for line with the entries of us_unsuaul_dev_list[].
- * For now, we duplicate idVendor and idProduct in us_unsual_dev_list,
- * just to avoid alignment bugs.
  */
 
 #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
@@ -353,7 +351,7 @@
                 */
                else if (us->srb->device->id && 
                                !(us->flags & US_FL_SCM_MULT_TARG)) {
-                       US_DEBUGP("Bad target number (%d/%d)\n",
+                       US_DEBUGP("Bad target number (%d:%d)\n",
                                  us->srb->device->id, us->srb->device->lun);
                        us->srb->result = DID_BAD_TARGET << 16;
                }
@@ -424,10 +422,13 @@
  ***********************************************************************/
 
 /* Get the unusual_devs entries and the string descriptors */
-static void get_device_info(struct us_data *us,
-                       struct us_unusual_dev *unusual_dev)
+static void get_device_info(struct us_data *us, int id_index)
 {
        struct usb_device *dev = us->pusb_dev;
+       struct usb_host_interface *altsetting =
+               &us->pusb_intf->altsetting[us->pusb_intf->act_altsetting];
+       struct us_unusual_dev *unusual_dev = &us_unusual_dev_list[id_index];
+       struct usb_device_id *id = &storage_usb_ids[id_index];
 
        if (unusual_dev->vendorName)
                US_DEBUGP("Vendor: %s\n", unusual_dev->vendorName);
@@ -436,10 +437,40 @@
 
        /* Store the entries */
        us->unusual_dev = unusual_dev;
-       us->subclass = unusual_dev->useProtocol;
-       us->protocol = unusual_dev->useTransport;
+       us->subclass = (unusual_dev->useProtocol == US_SC_DEVICE) ?
+                       altsetting->desc.bInterfaceSubClass :
+                       unusual_dev->useProtocol;
+       us->protocol = (unusual_dev->useTransport == US_PR_DEVICE) ?
+                       altsetting->desc.bInterfaceProtocol :
+                       unusual_dev->useTransport;
        us->flags = unusual_dev->flags;
 
+       /* Log a message if a non-generic unusual_dev entry contains an
+        * unnecessary subclass or protocol override.  This may stimulate
+        * reports from users that will help us remove unneeded entries
+        * from the unusual_devs.h table.
+        */
+       if (id->idVendor || id->idProduct) {
+               static char *msgs[3] = {
+                       "an unneeded SubClass entry",
+                       "an unneeded Protocol entry",
+                       "unneeded SubClass and Protocol entries"};
+               int msg = -1;
+
+               if (unusual_dev->useProtocol != US_SC_DEVICE &&
+                       us->subclass == altsetting->desc.bInterfaceSubClass)
+                       msg += 1;
+               if (unusual_dev->useTransport != US_PR_DEVICE &&
+                       us->protocol == altsetting->desc.bInterfaceProtocol)
+                       msg += 2;
+               if (msg >= 0)
+                       printk(KERN_NOTICE USB_STORAGE "This device "
+                               "(%04x,%04x) has %s in unusual_devs.h\n"
+                               "   Please send a copy of this message to "
+                               "<[EMAIL PROTECTED]>\n",
+                               id->idVendor, id->idProduct, msgs[msg]);
+       }
+
        /* Read the device's string descriptors */
        if (dev->descriptor.iManufacturer)
                usb_string(dev, dev->descriptor.iManufacturer, 
@@ -843,7 +874,7 @@
         * of the match from the usb_device_id table, so we can find the
         * corresponding entry in the private table.
         */
-       get_device_info(us, &us_unusual_dev_list[id_index]);
+       get_device_info(us, id_index);
 
 #ifdef CONFIG_USB_STORAGE_SDDR09
        if (us->protocol == US_PR_EUSB_SDDR09 ||
diff -Nru a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
--- a/drivers/usb/storage/usb.h Sun Jun 15 16:23:52 2003
+++ b/drivers/usb/storage/usb.h Sun Jun 15 16:23:52 2003
@@ -71,8 +71,6 @@
 #define US_FL_SINGLE_LUN      0x00000001 /* allow access to only LUN 0     */
 #define US_FL_MODE_XLATE      0x00000002 /* translate _6 to _10 commands for
                                                    Win/MacOS compatibility */
-#define US_FL_START_STOP      0x00000004 /* ignore START_STOP commands     */
-#define US_FL_IGNORE_SER      0x00000010 /* Ignore the serial number given  */
 #define US_FL_SCM_MULT_TARG   0x00000020 /* supports multiple targets      */
 #define US_FL_FIX_INQUIRY     0x00000040 /* INQUIRY response needs fixing   */
 #define US_FL_FIX_CAPACITY    0x00000080 /* READ CAPACITY response too big  */
-- 
Matthew Dharm                              Home: [EMAIL PROTECTED] 
Maintainer, Linux USB Mass Storage Driver

Somebody call an exorcist!
                                        -- Dust Puppy
User Friendly, 5/16/1998

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to