Commit 6d877688 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by James Bottomley

[SCSI] Clean up scsi_add_lun a bit

This patch tidies up scsi_add_lun a bit.  I rewrote the kerneldoc to match
the actual parameters, moved the check for RBC and MMC REPORT_LUN devices
away from the switch(), changed the setup of sdev->type to account for
BLIST_ISROM, moved the check for BLIST_NO_ULD_ATTACH further down in
the function, removed a bogus comment and fixed some whitespace issues.
Signed-off-by: default avatarMatthew Wilcox <matthew@wil.cx>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 0cba35e4
...@@ -694,16 +694,14 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, ...@@ -694,16 +694,14 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
/** /**
* scsi_add_lun - allocate and fully initialze a scsi_device * scsi_add_lun - allocate and fully initialze a scsi_device
* @sdevscan: holds information to be stored in the new scsi_device * @sdev: holds information to be stored in the new scsi_device
* @sdevnew: store the address of the newly allocated scsi_device
* @inq_result: holds the result of a previous INQUIRY to the LUN * @inq_result: holds the result of a previous INQUIRY to the LUN
* @bflags: black/white list flag * @bflags: black/white list flag
* @async: 1 if this device is being scanned asynchronously
* *
* Description: * Description:
* Allocate and initialize a scsi_device matching sdevscan. Optionally * Initialize the scsi_device @sdev. Optionally set fields based
* set fields based on values in *@bflags. If @sdevnew is not * on values in *@bflags.
* NULL, store the address of the new scsi_device in *@sdevnew (needed
* when scanning a particular LUN).
* *
* Return: * Return:
* SCSI_SCAN_NO_RESPONSE: could not allocate or setup a scsi_device * SCSI_SCAN_NO_RESPONSE: could not allocate or setup a scsi_device
...@@ -743,25 +741,15 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, ...@@ -743,25 +741,15 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
sdev->rev = (char *) (sdev->inquiry + 32); sdev->rev = (char *) (sdev->inquiry + 32);
if (*bflags & BLIST_ISROM) { if (*bflags & BLIST_ISROM) {
/* sdev->type = TYPE_ROM;
* It would be better to modify sdev->type, and set sdev->removable = 1;
* sdev->removable; this can now be done since } else {
* print_inquiry has gone away. sdev->type = (inq_result[0] & 0x1f);
*/ sdev->removable = (inq_result[1] & 0x80) >> 7;
inq_result[0] = TYPE_ROM; }
inq_result[1] |= 0x80; /* removable */
} else if (*bflags & BLIST_NO_ULD_ATTACH)
sdev->no_uld_attach = 1;
switch (sdev->type = (inq_result[0] & 0x1f)) { switch (sdev->type) {
case TYPE_RBC: case TYPE_RBC:
/* RBC devices can return SCSI-3 compliance and yet
* still not support REPORT LUNS, so make them act as
* BLIST_NOREPORTLUN unless BLIST_REPORTLUN2 is
* specifically set */
if ((*bflags & BLIST_REPORTLUN2) == 0)
*bflags |= BLIST_NOREPORTLUN;
/* fall through */
case TYPE_TAPE: case TYPE_TAPE:
case TYPE_DISK: case TYPE_DISK:
case TYPE_PRINTER: case TYPE_PRINTER:
...@@ -775,13 +763,6 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, ...@@ -775,13 +763,6 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
sdev->writeable = 1; sdev->writeable = 1;
break; break;
case TYPE_ROM: case TYPE_ROM:
/* MMC devices can return SCSI-3 compliance and yet
* still not support REPORT LUNS, so make them act as
* BLIST_NOREPORTLUN unless BLIST_REPORTLUN2 is
* specifically set */
if ((*bflags & BLIST_REPORTLUN2) == 0)
*bflags |= BLIST_NOREPORTLUN;
/* fall through */
case TYPE_WORM: case TYPE_WORM:
sdev->writeable = 0; sdev->writeable = 0;
break; break;
...@@ -789,6 +770,15 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, ...@@ -789,6 +770,15 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
printk(KERN_INFO "scsi: unknown device type %d\n", sdev->type); printk(KERN_INFO "scsi: unknown device type %d\n", sdev->type);
} }
if (sdev->type == TYPE_RBC || sdev->type == TYPE_ROM) {
/* RBC and MMC devices can return SCSI-3 compliance and yet
* still not support REPORT LUNS, so make them act as
* BLIST_NOREPORTLUN unless BLIST_REPORTLUN2 is
* specifically set */
if ((*bflags & BLIST_REPORTLUN2) == 0)
*bflags |= BLIST_NOREPORTLUN;
}
/* /*
* For a peripheral qualifier (PQ) value of 1 (001b), the SCSI * For a peripheral qualifier (PQ) value of 1 (001b), the SCSI
* spec says: The device server is capable of supporting the * spec says: The device server is capable of supporting the
...@@ -806,12 +796,11 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, ...@@ -806,12 +796,11 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
*/ */
sdev->inq_periph_qual = (inq_result[0] >> 5) & 7; sdev->inq_periph_qual = (inq_result[0] >> 5) & 7;
sdev->removable = (0x80 & inq_result[1]) >> 7;
sdev->lockable = sdev->removable; sdev->lockable = sdev->removable;
sdev->soft_reset = (inq_result[7] & 1) && ((inq_result[3] & 7) == 2); sdev->soft_reset = (inq_result[7] & 1) && ((inq_result[3] & 7) == 2);
if (sdev->scsi_level >= SCSI_3 || (sdev->inquiry_len > 56 && if (sdev->scsi_level >= SCSI_3 ||
inq_result[56] & 0x04)) (sdev->inquiry_len > 56 && inq_result[56] & 0x04))
sdev->ppr = 1; sdev->ppr = 1;
if (inq_result[7] & 0x60) if (inq_result[7] & 0x60)
sdev->wdtr = 1; sdev->wdtr = 1;
...@@ -824,13 +813,10 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, ...@@ -824,13 +813,10 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
sdev->inq_periph_qual, inq_result[2] & 0x07, sdev->inq_periph_qual, inq_result[2] & 0x07,
(inq_result[3] & 0x0f) == 1 ? " CCS" : ""); (inq_result[3] & 0x0f) == 1 ? " CCS" : "");
/*
* End sysfs code.
*/
if ((sdev->scsi_level >= SCSI_2) && (inq_result[7] & 2) && if ((sdev->scsi_level >= SCSI_2) && (inq_result[7] & 2) &&
!(*bflags & BLIST_NOTQ)) !(*bflags & BLIST_NOTQ))
sdev->tagged_supported = 1; sdev->tagged_supported = 1;
/* /*
* Some devices (Texel CD ROM drives) have handshaking problems * Some devices (Texel CD ROM drives) have handshaking problems
* when used with the Seagate controllers. borken is initialized * when used with the Seagate controllers. borken is initialized
...@@ -839,6 +825,9 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, ...@@ -839,6 +825,9 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
if ((*bflags & BLIST_BORKEN) == 0) if ((*bflags & BLIST_BORKEN) == 0)
sdev->borken = 0; sdev->borken = 0;
if (*bflags & BLIST_NO_ULD_ATTACH)
sdev->no_uld_attach = 1;
/* /*
* Apparently some really broken devices (contrary to the SCSI * Apparently some really broken devices (contrary to the SCSI
* standards) need to be selected without asserting ATN * standards) need to be selected without asserting ATN
...@@ -863,7 +852,6 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, ...@@ -863,7 +852,6 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
if (*bflags & BLIST_SINGLELUN) if (*bflags & BLIST_SINGLELUN)
sdev->single_lun = 1; sdev->single_lun = 1;
sdev->use_10_for_rw = 1; sdev->use_10_for_rw = 1;
if (*bflags & BLIST_MS_SKIP_PAGE_08) if (*bflags & BLIST_MS_SKIP_PAGE_08)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment