ChangeSet 1.2020.1.14, 2005/03/07 22:21:00-08:00, [EMAIL PROTECTED]

[PATCH] USB Storage: devices which don't process PREVENT-ALLOW MEDIUM REMOVAL

This patch started life as as423, and has been re-generated against the
current tip.

Some storage devices don't like PREVENT-ALLOW MEDIUM REMOVAL commands;
rather than returning an Invalid Command ASC they just die or imagine that
the medium has actually been removed.  Until now people have been relying
on the SCSI blacklist table, which can be updated at runtime, to mark
devices which shouldn't receive these commands.  However it will be more
efficient and easier to do it from within usb-storage, particularly since
many of these devices share the same USB Vendor and Product IDs (while
having different INQUIRY product strings).

*sigh* We really should be trying to push as much of this as possible onto
hotplug.  It's easier to update userspace tools than the kernel to support
a new device.

The relevant devices already have unusual_devs entries; this patch just
adds the new flag to those entries and uses it to set a corresponding flag
in the scsi_device structure.

Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
Signed-off-by: Matthew Dharm <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>


 drivers/usb/storage/scsiglue.c     |    5 +++++
 drivers/usb/storage/unusual_devs.h |   10 +++-------
 drivers/usb/storage/usb.h          |    1 +
 3 files changed, 9 insertions(+), 7 deletions(-)


diff -Nru a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
--- a/drivers/usb/storage/scsiglue.c    2005-03-08 16:55:23 -08:00
+++ b/drivers/usb/storage/scsiglue.c    2005-03-08 16:55:23 -08:00
@@ -162,6 +162,11 @@
                sdev->use_10_for_ms = 1;
        }
 
+       /* Some devices choke when they receive a PREVENT-ALLOW MEDIUM
+        * REMOVAL command, so suppress those commands. */
+       if (us->flags & US_FL_NOT_LOCKABLE)
+               sdev->lockable = 0;
+
        /* this is to satisfy the compiler, tho I don't think the 
         * return code is ever checked anywhere. */
        return 0;
diff -Nru a/drivers/usb/storage/unusual_devs.h 
b/drivers/usb/storage/unusual_devs.h
--- a/drivers/usb/storage/unusual_devs.h        2005-03-08 16:55:23 -08:00
+++ b/drivers/usb/storage/unusual_devs.h        2005-03-08 16:55:23 -08:00
@@ -171,15 +171,12 @@
                "CD-R/RW Drive",
                US_SC_8070, US_PR_CB, NULL, 0),
 
-/* Reported by Adriaan Penning <[EMAIL PROTECTED]>
- * Note that these cameras report "Medium not present" after
- * ALLOW_MEDIUM_REMOVAL, so they also need to be marked
- * NOT_LOCKABLE in the SCSI blacklist (and the vendor is MATSHITA). */
+/* Reported by Adriaan Penning <[EMAIL PROTECTED]> */
 UNUSUAL_DEV(  0x04da, 0x2372, 0x0000, 0x9999,
                "Panasonic",
                "DMC-LCx Camera",
                US_SC_DEVICE, US_PR_DEVICE, NULL,
-               US_FL_FIX_CAPACITY ),
+               US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ),
 
 /* Most of the following entries were developed with the help of
  * Shuttle/SCM directly.
@@ -332,12 +329,11 @@
                US_SC_DEVICE, US_PR_DEVICE, NULL,
                US_FL_IGNORE_RESIDUE ),
 
-/* 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_DEVICE, NULL,
-               US_FL_SINGLE_LUN ),
+               US_FL_SINGLE_LUN | US_FL_NOT_LOCKABLE ),
 
 /* This entry is needed because the device reports Sub=ff */
 UNUSUAL_DEV(  0x054c, 0x0010, 0x0500, 0x0500, 
diff -Nru a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
--- a/drivers/usb/storage/usb.h 2005-03-08 16:55:23 -08:00
+++ b/drivers/usb/storage/usb.h 2005-03-08 16:55:23 -08:00
@@ -75,6 +75,7 @@
 #define US_FL_FIX_CAPACITY    0x00000080 /* READ CAPACITY response too big  */
 #define US_FL_IGNORE_RESIDUE  0x00000100 /* reported residue is wrong      */
 #define US_FL_BULK32          0x00000200 /* Uses 32-byte CBW length         */
+#define US_FL_NOT_LOCKABLE    0x00000400 /* PREVENT/ALLOW not supported     */
 
 /* Dynamic flag definitions: used in set_bit() etc. */
 #define US_FLIDX_URB_ACTIVE    18  /* 0x00040000  current_urb is in use  */



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to