]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/usb/gadget/storage_common.c
Merge branch 'master' into tk71
[mv-sheeva.git] / drivers / usb / gadget / storage_common.c
index 484acfb1a7c5a999e9b2ef5f48c4ab54d1c0a549..b015561fd602a526d6c76aa52cff3a04f94d026e 100644 (file)
@@ -26,7 +26,6 @@
  * be defined (each of type pointer to char):
  *  - fsg_string_manufacturer -- name of the manufacturer
  *  - fsg_string_product      -- name of the product
- *  - fsg_string_serial       -- product's serial
  *  - fsg_string_config       -- name of the configuration
  *  - fsg_string_interface    -- name of the interface
  * The first four are only needed when FSG_DESCRIPTORS_DEVICE_STRINGS
@@ -54,6 +53,8 @@
  */
 
 
+#include <linux/usb/storage.h>
+#include <scsi/scsi.h>
 #include <asm/unaligned.h>
 
 
 
 /*-------------------------------------------------------------------------*/
 
-/* SCSI device types */
-#define TYPE_DISK      0x00
-#define TYPE_CDROM     0x05
-
-/* USB protocol value = the transport method */
-#define USB_PR_CBI     0x00            /* Control/Bulk/Interrupt */
-#define USB_PR_CB      0x01            /* Control/Bulk w/o interrupt */
-#define USB_PR_BULK    0x50            /* Bulk-only */
-
-/* USB subclass value = the protocol encapsulation */
-#define USB_SC_RBC     0x01            /* Reduced Block Commands (flash) */
-#define USB_SC_8020    0x02            /* SFF-8020i, MMC-2, ATAPI (CD-ROM) */
-#define USB_SC_QIC     0x03            /* QIC-157 (tape) */
-#define USB_SC_UFI     0x04            /* UFI (floppy) */
-#define USB_SC_8070    0x05            /* SFF-8070i (removable) */
-#define USB_SC_SCSI    0x06            /* Transparent SCSI */
-
 /* Bulk-only data structures */
 
 /* Command Block Wrapper */
@@ -221,33 +205,6 @@ struct interrupt_data {
 /* Length of a SCSI Command Data Block */
 #define MAX_COMMAND_SIZE       16
 
-/* SCSI commands that we recognize */
-#define SC_FORMAT_UNIT                 0x04
-#define SC_INQUIRY                     0x12
-#define SC_MODE_SELECT_6               0x15
-#define SC_MODE_SELECT_10              0x55
-#define SC_MODE_SENSE_6                        0x1a
-#define SC_MODE_SENSE_10               0x5a
-#define SC_PREVENT_ALLOW_MEDIUM_REMOVAL        0x1e
-#define SC_READ_6                      0x08
-#define SC_READ_10                     0x28
-#define SC_READ_12                     0xa8
-#define SC_READ_CAPACITY               0x25
-#define SC_READ_FORMAT_CAPACITIES      0x23
-#define SC_READ_HEADER                 0x44
-#define SC_READ_TOC                    0x43
-#define SC_RELEASE                     0x17
-#define SC_REQUEST_SENSE               0x03
-#define SC_RESERVE                     0x16
-#define SC_SEND_DIAGNOSTIC             0x1d
-#define SC_START_STOP_UNIT             0x1b
-#define SC_SYNCHRONIZE_CACHE           0x35
-#define SC_TEST_UNIT_READY             0x00
-#define SC_VERIFY                      0x2f
-#define SC_WRITE_6                     0x0a
-#define SC_WRITE_10                    0x2a
-#define SC_WRITE_12                    0xaa
-
 /* SCSI Sense Key/Additional Sense Code/ASC Qualifier values */
 #define SS_NO_SENSE                            0
 #define SS_COMMUNICATION_FAILURE               0x040800
@@ -552,7 +509,7 @@ static struct usb_string            fsg_strings[] = {
 #ifndef FSG_NO_DEVICE_STRINGS
        {FSG_STRING_MANUFACTURER,       fsg_string_manufacturer},
        {FSG_STRING_PRODUCT,            fsg_string_product},
-       {FSG_STRING_SERIAL,             fsg_string_serial},
+       {FSG_STRING_SERIAL,             ""},
        {FSG_STRING_CONFIG,             fsg_string_config},
 #endif
        {FSG_STRING_INTERFACE,          fsg_string_interface},
@@ -586,7 +543,7 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
        ro = curlun->initially_ro;
        if (!ro) {
                filp = filp_open(filename, O_RDWR | O_LARGEFILE, 0);
-               if (-EROFS == PTR_ERR(filp))
+               if (PTR_ERR(filp) == -EROFS || PTR_ERR(filp) == -EACCES)
                        ro = 1;
        }
        if (ro)
@@ -601,10 +558,7 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
 
        if (filp->f_path.dentry)
                inode = filp->f_path.dentry->d_inode;
-       if (inode && S_ISBLK(inode->i_mode)) {
-               if (bdev_read_only(inode->i_bdev))
-                       ro = 1;
-       } else if (!inode || !S_ISREG(inode->i_mode)) {
+       if (!inode || (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))) {
                LINFO(curlun, "invalid file type: %s\n", filename);
                goto out;
        }