scsi: fix the type for well known LUs
authorSubhash Jadavani <subhashj@codeaurora.org>
Thu, 25 Sep 2014 12:32:19 +0000 (15:32 +0300)
committerChristoph Hellwig <hch@lst.de>
Wed, 1 Oct 2014 11:11:03 +0000 (13:11 +0200)
Some devices may respond with wrong type for well-known logical units.
This patch forces well-known type for devices which doesn't report it
correct.

Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/scsi/scsi_scan.c
include/scsi/scsi.h

index f84c4018847816ddb5fa2a24cadfd70696cb9e22..dde0c542e0b1b98fa42e38dfb18d19743a1263e2 100644 (file)
@@ -815,6 +815,19 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
        } else {
                sdev->type = (inq_result[0] & 0x1f);
                sdev->removable = (inq_result[1] & 0x80) >> 7;
+
+               /*
+                * some devices may respond with wrong type for
+                * well-known logical units. Force well-known type
+                * to enumerate them correctly.
+                */
+               if (scsi_is_wlun(sdev->lun) && sdev->type != TYPE_WLUN) {
+                       sdev_printk(KERN_WARNING, sdev,
+                               "%s: correcting incorrect peripheral device type 0x%x for W-LUN 0x%16xhN\n",
+                               __func__, sdev->type, (unsigned int)sdev->lun);
+                       sdev->type = TYPE_WLUN;
+               }
+
        }
 
        if (sdev->type == TYPE_RBC || sdev->type == TYPE_ROM) {
index 261e708010da70174785c7a62b4f51f31f0a4164..d17178e6fcdd738a6e178d4e7ea226895a815827 100644 (file)
@@ -333,6 +333,7 @@ static inline int scsi_status_is_good(int status)
 #define TYPE_RBC           0x0e
 #define TYPE_OSD            0x11
 #define TYPE_ZBC            0x14
+#define TYPE_WLUN           0x1e    /* well-known logical unit */
 #define TYPE_NO_LUN         0x7f
 
 /* SCSI protocols; these are taken from SPC-3 section 7.5 */