This is patch as422 from Alan Stern. This is the second half of the two-part patch to move the fix_capacity functionality up into the sd driver. James Bottomley has applied the SCSI half, so now the usb-storage part is ready to go.
In short, the patch removes the fix_capacity routine and in its place,
sets a device flag to tell sd that the reported capacity is one sector too
high. It's a simple change and shouldn't cause any problems.
Greg, please apply.
Matt
Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
Signed-off-by: Matthew Dharm <[EMAIL PROTECTED]>
===== drivers/usb/storage/protocol.c 1.25 vs edited =====
--- 1.25/drivers/usb/storage/protocol.c 2004-10-20 12:38:15 -04:00
+++ edited/drivers/usb/storage/protocol.c 2004-11-08 15:37:22 -05:00
@@ -54,39 +54,6 @@
#include "transport.h"
/***********************************************************************
- * Helper routines
- ***********************************************************************/
-
-/*
- * Fix-up the return data from a READ CAPACITY command. My Feiya reader
- * returns a value that is 1 too large.
- */
-static void fix_read_capacity(struct scsi_cmnd *srb)
-{
- unsigned int index, offset;
- __be32 c;
- unsigned long capacity;
-
- /* verify that it's a READ CAPACITY command */
- if (srb->cmnd[0] != READ_CAPACITY)
- return;
-
- index = offset = 0;
- if (usb_stor_access_xfer_buf((unsigned char *) &c, 4, srb,
- &index, &offset, FROM_XFER_BUF) != 4)
- return;
-
- capacity = be32_to_cpu(c);
- US_DEBUGP("US: Fixing capacity: from %ld to %ld\n",
- capacity+1, capacity);
- c = cpu_to_be32(capacity - 1);
-
- index = offset = 0;
- usb_stor_access_xfer_buf((unsigned char *) &c, 4, srb,
- &index, &offset, TO_XFER_BUF);
-}
-
-/***********************************************************************
* Protocol routines
***********************************************************************/
@@ -174,12 +141,6 @@
{
/* send the command to the transport layer */
usb_stor_invoke_transport(srb, us);
-
- if (srb->result == SAM_STAT_GOOD) {
- /* Fix the READ CAPACITY result if necessary */
- if (us->flags & US_FL_FIX_CAPACITY)
- fix_read_capacity(srb);
- }
}
/***********************************************************************
===== drivers/usb/storage/scsiglue.c 1.87 vs edited =====
--- 1.87/drivers/usb/storage/scsiglue.c 2004-11-01 13:59:21 -05:00
+++ edited/drivers/usb/storage/scsiglue.c 2004-11-08 15:43:05 -05:00
@@ -149,6 +149,11 @@
sdev->skip_ms_page_3f = 1;
#endif
+ /* Some disks return the total number blocks in response
+ * to READ CAPACITY rather than the highest block number.
+ * If this device makes that mistake, tell the sd driver. */
+ if (us->flags & US_FL_FIX_CAPACITY)
+ sdev->fix_capacity = 1;
} else {
/* Non-disk-type devices don't need to blacklist any pages
--
Matthew Dharm Home: [EMAIL PROTECTED]
Maintainer, Linux USB Mass Storage Driver
Type "format c:" That should fix everything.
-- Greg
User Friendly, 12/18/1997
pgpcsofDekLNf.pgp
Description: PGP signature
