Commit 75d23d89 authored by Don Brace's avatar Don Brace Committed by Martin K. Petersen

hpsa: enhance hpsa_get_device_id

use an index into vpd data for SAS/SATA drives
Reviewed-by: default avatarScott Teel <scott.teel@pmcs.com>
Reviewed-by: default avatarJustin Lindley <justin.lindley@pmcs.com>
Reviewed-by: default avatarKevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: default avatarTomas Henzl <thenzl@redhat.com>
Reviewed-by: default avatarMatthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: default avatarDon Brace <don.brace@pmcs.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent f3f01730
...@@ -3128,7 +3128,7 @@ static void hpsa_get_ioaccel_status(struct ctlr_info *h, ...@@ -3128,7 +3128,7 @@ static void hpsa_get_ioaccel_status(struct ctlr_info *h,
/* Get the device id from inquiry page 0x83 */ /* Get the device id from inquiry page 0x83 */
static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr, static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr,
unsigned char *device_id, int buflen) unsigned char *device_id, int index, int buflen)
{ {
int rc; int rc;
unsigned char *buf; unsigned char *buf;
...@@ -3140,8 +3140,10 @@ static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr, ...@@ -3140,8 +3140,10 @@ static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr,
return -ENOMEM; return -ENOMEM;
rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | 0x83, buf, 64); rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | 0x83, buf, 64);
if (rc == 0) if (rc == 0)
memcpy(device_id, &buf[8], buflen); memcpy(device_id, &buf[index], buflen);
kfree(buf); kfree(buf);
return rc != 0; return rc != 0;
} }
...@@ -3370,6 +3372,18 @@ static int hpsa_device_supports_aborts(struct ctlr_info *h, ...@@ -3370,6 +3372,18 @@ static int hpsa_device_supports_aborts(struct ctlr_info *h,
return rc; return rc;
} }
static void sanitize_inquiry_string(unsigned char *s, int len)
{
bool terminated = false;
for (; len > 0; (--len, ++s)) {
if (*s == 0)
terminated = true;
if (terminated || *s < 0x20 || *s > 0x7e)
*s = ' ';
}
}
static int hpsa_update_device_info(struct ctlr_info *h, static int hpsa_update_device_info(struct ctlr_info *h,
unsigned char scsi3addr[], struct hpsa_scsi_dev_t *this_device, unsigned char scsi3addr[], struct hpsa_scsi_dev_t *this_device,
unsigned char *is_OBDR_device) unsigned char *is_OBDR_device)
...@@ -3400,6 +3414,9 @@ static int hpsa_update_device_info(struct ctlr_info *h, ...@@ -3400,6 +3414,9 @@ static int hpsa_update_device_info(struct ctlr_info *h,
goto bail_out; goto bail_out;
} }
sanitize_inquiry_string(&inq_buff[8], 8);
sanitize_inquiry_string(&inq_buff[16], 16);
this_device->devtype = (inq_buff[0] & 0x1f); this_device->devtype = (inq_buff[0] & 0x1f);
memcpy(this_device->scsi3addr, scsi3addr, 8); memcpy(this_device->scsi3addr, scsi3addr, 8);
memcpy(this_device->vendor, &inq_buff[8], memcpy(this_device->vendor, &inq_buff[8],
...@@ -3408,7 +3425,7 @@ static int hpsa_update_device_info(struct ctlr_info *h, ...@@ -3408,7 +3425,7 @@ static int hpsa_update_device_info(struct ctlr_info *h,
sizeof(this_device->model)); sizeof(this_device->model));
memset(this_device->device_id, 0, memset(this_device->device_id, 0,
sizeof(this_device->device_id)); sizeof(this_device->device_id));
hpsa_get_device_id(h, scsi3addr, this_device->device_id, hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8,
sizeof(this_device->device_id)); sizeof(this_device->device_id));
if (this_device->devtype == TYPE_DISK && if (this_device->devtype == TYPE_DISK &&
......
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