Skip to contentSkip to conversation

scsi: fix inconsistent usage of max_lun

PATCH New Ed Lin 1 participant 1 message Oct 9, 2009

Subsystems (2)
lore
Share & tools
lore

Ed Lin

author
#0 lore raw

PATCH 1/1 scsi: fix inconsistent usage of max_lun

max_lun in struct Scsi_Host is used as actual max lun plus 1 in scsi_sequential_lun_scan()(scsi_scan.c). However it is also used as actual max lun in some other cases.

According to the comment in the definition of struct Scsi_Host, max_lun should be set to 1 more than the actual max lun, just like max_id. Fix the problem according to this definition.

---

 drivers/scsi/3w-xxxx.c           |    2 +-
 drivers/scsi/scsi_scan.c         |    4 ++--
 drivers/scsi/scsi_transport_fc.c |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/scsi/3w-xxxx.c +1 -1
index faa0fcf..4e91650 100644
@@ -2321,7 +2321,7 @@ static int __devinit tw_probe(struct pci_dev *pdev, const struct pci_device_id *
 	host->max_cmd_len = TW_MAX_CDB_LEN;
 
 	/* Luns and channels aren't supported by adapter */
-	host->max_lun = 0;
+	host->max_lun = 1;
 	host->max_channel = 0;
 
 	/* Register the card with the kernel SCSI layer */
drivers/scsi/scsi_scan.c +2 -2
index c447838..cb6338f 100644
@@ -1468,7 +1468,7 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
 			for (i = 0; i < sizeof(struct scsi_lun); i++)
 				printk("%02x", data[i]);
 			printk(" has a LUN larger than currently supported.\n");
-		} else if (lun > sdev->host->max_lun) {
+		} else if (lun >= sdev->host->max_lun) {
 			printk(KERN_WARNING "scsi: %s lun%d has a LUN larger"
 			       " than allowed by the host adapter\n",
 			       devname, lun);
@@ -1681,7 +1681,7 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
 
 	if (((channel != SCAN_WILD_CARD) && (channel > shost->max_channel)) ||
 	    ((id != SCAN_WILD_CARD) && (id >= shost->max_id)) ||
-	    ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun)))
+	    ((lun != SCAN_WILD_CARD) && (lun >= shost->max_lun)))
 		return -EINVAL;
 
 	mutex_lock(&shost->scan_mutex);
drivers/scsi/scsi_transport_fc.c +1 -1
index b98885d..e7518a2 100644
@@ -1992,7 +1992,7 @@ fc_user_scan(struct Scsi_Host *shost, uint channel, uint id, uint lun)
 
 	if (((channel != SCAN_WILD_CARD) && (channel > shost->max_channel)) ||
 	    ((id != SCAN_WILD_CARD) && (id >= shost->max_id)) ||
-	    ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun)))
+	    ((lun != SCAN_WILD_CARD) && (lun >= shost->max_lun)))
 		return -EINVAL;
 
 	if (channel == SCAN_WILD_CARD) {