]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
USB Storage: indistinguishable devices with broken and unbroken firmware
authorOliver Neukum <oneukum@suse.de>
Thu, 8 Feb 2007 08:04:48 +0000 (09:04 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 16 Feb 2007 23:32:19 +0000 (15:32 -0800)
there's a USB mass storage device which exists in two version. One
reports the correct size and the other does not. Apart from that they
are identical and cannot be told apart. Here's a heuristic based on the
empirical finding that drives have even sizes.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/scsi/sd.c
drivers/usb/storage/scsiglue.c
drivers/usb/storage/unusual_devs.h
include/linux/usb_usual.h
include/scsi/scsi_device.h

index 3f048bd6326ddc5ff70b8f031e0ce1e1b4c06404..5a8f55fea5ff3da628eaed926786b0713d1a8565 100644 (file)
@@ -1269,9 +1269,18 @@ repeat:
 
        /* Some devices return the total number of sectors, not the
         * highest sector number.  Make the necessary adjustment. */
-       if (sdp->fix_capacity)
+       if (sdp->fix_capacity) {
                --sdkp->capacity;
 
+       /* Some devices have version which report the correct sizes
+        * and others which do not. We guess size according to a heuristic
+        * and err on the side of lowering the capacity. */
+       } else {
+               if (sdp->guess_capacity)
+                       if (sdkp->capacity & 0x01) /* odd sizes are odd */
+                               --sdkp->capacity;
+       }
+
 got_data:
        if (sector_size == 0) {
                sector_size = 512;
index 70234f5dbeeb473f60ab08da59e07438a1977033..e227f64d5641be64dc009c34da147be8c0a61a69 100644 (file)
@@ -153,6 +153,12 @@ static int slave_configure(struct scsi_device *sdev)
                if (us->flags & US_FL_FIX_CAPACITY)
                        sdev->fix_capacity = 1;
 
+               /* A few disks have two indistinguishable version, one of
+                * which reports the correct capacity and the other does not.
+                * The sd driver has to guess which is the case. */
+               if (us->flags & US_FL_CAPACITY_HEURISTICS)
+                       sdev->guess_capacity = 1;
+
                /* Some devices report a SCSI revision level above 2 but are
                 * unable to handle the REPORT LUNS command (for which
                 * support is mandatory at level 3).  Since we already have
index bab054b8d94f80943c59884f8257c43dc8229f3d..5683665697698c7daf032d5d7c34def37fde2e51 100644 (file)
@@ -1434,7 +1434,7 @@ UNUSUAL_DEV(  0xed06, 0x4500, 0x0001, 0x0001,
                "DataStor",
                "USB4500 FW1.04",
                US_SC_DEVICE, US_PR_DEVICE, NULL,
-               US_FL_FIX_CAPACITY),
+               US_FL_CAPACITY_HEURISTICS),
 
 /* Control/Bulk transport for all SubClass values */
 USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR),
index 2ae76fe52ff75e483806cd48c2f3e29fadfd89ac..1b792b9286bae2a499fd5aa46ff1b4ccc1a5aeec 100644 (file)
@@ -46,7 +46,9 @@
        US_FLAG(MAX_SECTORS_64, 0x00000400)                     \
                /* Sets max_sectors to 64    */                 \
        US_FLAG(IGNORE_DEVICE,  0x00000800)                     \
-               /* Don't claim device */
+               /* Don't claim device */                        \
+       US_FLAG(CAPACITY_HEURISTICS,    0x00001000)             \
+               /* sometimes sizes is too big */
 
 #define US_FLAG(name, value)   US_FL_##name = value ,
 enum { US_DO_ALL_FLAGS };
index ebf31b16dc49eee41786123bad30f36405faae20..9dd37e2f5a84df84deb91554f85372966cf2e6d8 100644 (file)
@@ -122,6 +122,7 @@ struct scsi_device {
        unsigned no_uld_attach:1; /* disable connecting to upper level drivers */
        unsigned select_no_atn:1;
        unsigned fix_capacity:1;        /* READ_CAPACITY is too high by 1 */
+       unsigned guess_capacity:1;      /* READ_CAPACITY might be too high by 1 */
        unsigned retry_hwerror:1;       /* Retry HARDWARE_ERROR */
 
        unsigned int device_blocked;    /* Device returned QUEUE_FULL. */