patch-2.2.13 linux/drivers/scsi/scsi.c

Next file: linux/drivers/scsi/sd.c
Previous file: linux/drivers/scsi/qlogicpti_asm.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.12/linux/drivers/scsi/scsi.c linux/drivers/scsi/scsi.c
@@ -104,14 +104,17 @@
  * lock up.
  */
 
-#define BLIST_NOLUN     0x01
-#define BLIST_FORCELUN  0x02
-#define BLIST_BORKEN    0x04
-#define BLIST_KEY       0x08
-#define BLIST_SINGLELUN 0x10
-#define BLIST_NOTQ	0x20
-#define BLIST_SPARSELUN 0x40
-#define BLIST_MAX5LUN	0x80
+#define BLIST_NOLUN     0x001
+#define BLIST_FORCELUN  0x002
+#define BLIST_BORKEN    0x004
+#define BLIST_KEY       0x008
+#define BLIST_SINGLELUN 0x010
+#define BLIST_NOTQ	0x020
+#define BLIST_SPARSELUN 0x040
+#define BLIST_MAX5LUN	0x080
+#define BLIST_ISDISK	0x100
+#define BLIST_ISROM	0x200
+#define BLIST_GHOST	0x400
 
 /*
  * Data declarations.
@@ -288,10 +291,13 @@
 {"CANON","IPUBJD","*", BLIST_SPARSELUN},
 {"nCipher","Fastness Crypto","*", BLIST_FORCELUN},
 {"NEC","PD-1 ODX654P","*", BLIST_FORCELUN | BLIST_SINGLELUN},
-{"MATSHITA","PD","*", BLIST_FORCELUN | BLIST_SINGLELUN},
+{"MATSHITA","PD-1","*", BLIST_FORCELUN | BLIST_SINGLELUN},
 {"YAMAHA","CDR100","1.00", BLIST_NOLUN},	/* Locks up if polled for lun != 0 */
 {"YAMAHA","CDR102","1.00", BLIST_NOLUN},	/* Locks up if polled for lun != 0 */
 {"iomega","jaz 1GB","J.86", BLIST_NOTQ | BLIST_NOLUN},
+{"CREATIVE","DVD-RAM RAM","*", BLIST_GHOST},
+{"MATSHITA","PD-2 LF-D100","*", BLIST_GHOST},
+{"TOSHIBA","CDROM","*", BLIST_ISROM},
 /*
  * Must be at end of list...
  */
@@ -654,6 +660,8 @@
   struct Scsi_Device_Template *sdtpnt;
   Scsi_Device * SDtail, *SDpnt=*SDpnt2;
   int bflags, type=-1;
+  static int ghost_channel=-1, ghost_dev=-1;
+  int org_lun = lun;
 
   SDpnt->host = shpnt;
   SDpnt->id = dev;
@@ -661,6 +669,12 @@
   SDpnt->channel = channel;
   SDpnt->online = TRUE;
 
+  if ((channel == ghost_channel) && (dev == ghost_dev) && (lun == 1)) {
+    SDpnt->lun = 0;
+  } else {
+    ghost_channel = ghost_dev = -1;
+  }
+
   /* Some low level driver could use device->type (DB) */
   SDpnt->type = -1;
 
@@ -753,26 +767,37 @@
     }
 
   /*
-   * It would seem some TOSHIBA CDROM gets things wrong
+   * Get any flags for this device.
    */
-  if (!strncmp (scsi_result + 8, "TOSHIBA", 7) &&
-      !strncmp (scsi_result + 16, "CD-ROM", 6) &&
-      scsi_result[0] == TYPE_DISK) {
-    scsi_result[0] = TYPE_ROM;
+  bflags = get_device_flags (scsi_result);
+
+  /* The Toshiba ROM was "gender-changed" here as an inline hack. 
+     This is now much more generic. 
+     This is a mess: What we really want is to leave the scsi_result
+     alone, and just change the SDpnt structure. And the SDpnt is what
+     we want print_inquiry to print.  -- REW
+  */
+  if (bflags & BLIST_ISDISK) {
+    scsi_result[0] = TYPE_DISK;
     scsi_result[1] |= 0x80;     /* removable */
   }
 
-  /*
-   * It would seem the Panasonic DVD-RAM is backwards too
-   * If DVD-RAM or PD media used, it seems to function
-   * as Direct-Access
-   */
-  if (!strncmp (scsi_result + 8, "MATSHITA", 7) &&
-      !strncmp (scsi_result + 16, "PD-2 LF-D100", 12)) {
-    scsi_result[0] = TYPE_DISK;
+  if (bflags & BLIST_ISROM) {
+    scsi_result[0] = TYPE_ROM;
     scsi_result[1] |= 0x80;     /* removable */
   }
 
+  if (bflags & BLIST_GHOST) {
+    if ((ghost_channel == channel) && (ghost_dev == dev) && (org_lun == 1)) {
+      lun=1;
+    } else {
+      ghost_channel = channel;
+      ghost_dev = dev;
+      scsi_result[0] = TYPE_MOD;
+      scsi_result[1] |= 0x80;     /* removable */
+    }
+  }
+
   memcpy (SDpnt->vendor, scsi_result + 8, 8);
   memcpy (SDpnt->model, scsi_result + 16, 16);
   memcpy (SDpnt->rev, scsi_result + 32, 4);
@@ -835,10 +860,6 @@
    */
   SDpnt->disconnect = 0;
 
-  /*
-   * Get any flags for this device.
-   */
-  bflags = get_device_flags (scsi_result);
 
   /*
    * Set the tagged_queue flag for SCSI-II devices that purport to support
@@ -961,6 +982,15 @@
    */
   if (bflags & BLIST_FORCELUN) {
     *max_dev_lun = 8;
+    return 1;
+  }
+
+  /*
+   * If this device is Ghosted, scan upto two luns. (It physically only
+   * has one). -- REW
+   */
+  if (bflags & BLIST_GHOST) {
+    *max_dev_lun = 2;
     return 1;
   }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)