summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sd.c
diff options
context:
space:
mode:
authorOliver Neukum <oneukum@suse.de>2007-02-08 09:04:48 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2007-02-16 15:32:19 -0800
commit61bf54b71d5abf767ee46284be19965d7253ddbf (patch)
tree04bda12e495bc19be2712dff9da35f5e3271691a /drivers/scsi/sd.c
parent5b06470816fb5e658e81db2a55b530ff2ba711c9 (diff)
downloadop-kernel-dev-61bf54b71d5abf767ee46284be19965d7253ddbf.zip
op-kernel-dev-61bf54b71d5abf767ee46284be19965d7253ddbf.tar.gz
USB Storage: indistinguishable devices with broken and unbroken firmware
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>
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r--drivers/scsi/sd.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 3f048bd..5a8f55f 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -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;
OpenPOWER on IntegriCloud