From: Sha Zhengju <handai.szj@xxxxxxxxxx> As per Doug Gilbert's suggestion, introduce a new variable to represent the resp[2] of standard INQUIRY data. For different scsi devices, the linux scsi_level is computed based on the resp[2] value. This will make the code more easier to understand. Signed-off-by: Sha Zhengju <handai.szj@xxxxxxxxxx> --- drivers/scsi/scsi_scan.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 307a811..421d162 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -546,6 +546,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, int response_len = 0; int pass, count, result; struct scsi_sense_hdr sshdr; + char inquiry_version; *bflags = 0; @@ -705,10 +706,16 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, * device is attached at LUN 0 (SCSI_SCAN_TARGET_PRESENT) so * non-zero LUNs can be scanned. */ - sdev->scsi_level = inq_result[2] & 0x07; - if (sdev->scsi_level >= 2 || - (sdev->scsi_level == 1 && (inq_result[3] & 0x0f) == 1)) - sdev->scsi_level++; + /* For SCSI devices that equal or after SCSI_2, or is SCSI_1_CCS, + * its scsi_level is (inquiry_version + 1). + */ + inquiry_version = inq_result[2] & 0x07; + if (inquiry_version >= 2 || + (inquiry_version == 1 && (inq_result[3] & 0x0f) == 1)) + sdev->scsi_level = inquiry_version + 1; + else + sdev->scsi_level = inquiry_version; /* SCSI_1 */ + sdev->sdev_target->scsi_level = sdev->scsi_level; return 0; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html