Message ID | 20151028220601.5323.62936.stgit@brunhilda (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
On 28.10.2015 23:06, Don Brace wrote: > use an index into vpd data for SAS/SATA drives > > Reviewed-by: Scott Teel <scott.teel@pmcs.com> > Reviewed-by: Justin Lindley <justin.lindley@pmcs.com> > Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com> > Signed-off-by: Don Brace <don.brace@pmcs.com> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Tomas -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> On Oct 28, 2015, at 5:06 PM, Don Brace <don.brace@pmcs.com> wrote: > > use an index into vpd data for SAS/SATA drives > > Reviewed-by: Scott Teel <scott.teel@pmcs.com> > Reviewed-by: Justin Lindley <justin.lindley@pmcs.com> > Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com> > Signed-off-by: Don Brace <don.brace@pmcs.com> > --- > drivers/scsi/hpsa.c | 23 ++++++++++++++++++++--- > 1 file changed, 20 insertions(+), 3 deletions(-) > > diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c > index c1b053f..1361414 100644 > --- a/drivers/scsi/hpsa.c > +++ b/drivers/scsi/hpsa.c > @@ -3137,7 +3137,7 @@ out: > > /* Get the device id from inquiry page 0x83 */ > 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; > unsigned char *buf; > @@ -3149,8 +3149,10 @@ static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr, > return -ENOMEM; > rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | 0x83, buf, 64); > if (rc == 0) > - memcpy(device_id, &buf[8], buflen); > + memcpy(device_id, &buf[index], buflen); > + > kfree(buf); > + > return rc != 0; > } > > @@ -3379,6 +3381,18 @@ static int hpsa_device_supports_aborts(struct ctlr_info *h, > 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 = ' '; > + } > +} > + Perhaps in a future commit the version in scsi_scan can be exported and this duplication can be eliminated. Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com> -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 10/28/2015 11:06 PM, Don Brace wrote: > use an index into vpd data for SAS/SATA drives > > Reviewed-by: Scott Teel <scott.teel@pmcs.com> > Reviewed-by: Justin Lindley <justin.lindley@pmcs.com> > Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com> > Signed-off-by: Don Brace <don.brace@pmcs.com> > --- > drivers/scsi/hpsa.c | 23 ++++++++++++++++++++--- > 1 file changed, 20 insertions(+), 3 deletions(-) > > diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c > index c1b053f..1361414 100644 > --- a/drivers/scsi/hpsa.c > +++ b/drivers/scsi/hpsa.c > @@ -3137,7 +3137,7 @@ out: > > /* Get the device id from inquiry page 0x83 */ > 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; > unsigned char *buf; > @@ -3149,8 +3149,10 @@ static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr, > return -ENOMEM; > rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | 0x83, buf, 64); > if (rc == 0) > - memcpy(device_id, &buf[8], buflen); > + memcpy(device_id, &buf[index], buflen); > + > kfree(buf); > + > return rc != 0; > } > > @@ -3379,6 +3381,18 @@ static int hpsa_device_supports_aborts(struct ctlr_info *h, > 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, > unsigned char scsi3addr[], struct hpsa_scsi_dev_t *this_device, > unsigned char *is_OBDR_device) I would prefer to have the function from scsi_scan.c to be exported. Hardly a point to duplicate it. Cheers, Hannes
On 10/30/2015 03:08 AM, Hannes Reinecke wrote: > On 10/28/2015 11:06 PM, Don Brace wrote: >> use an index into vpd data for SAS/SATA drives >> >> Reviewed-by: Scott Teel <scott.teel@pmcs.com> >> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com> >> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com> >> Signed-off-by: Don Brace <don.brace@pmcs.com> >> --- >> drivers/scsi/hpsa.c | 23 ++++++++++++++++++++--- >> 1 file changed, 20 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c >> index c1b053f..1361414 100644 >> --- a/drivers/scsi/hpsa.c >> +++ b/drivers/scsi/hpsa.c >> @@ -3137,7 +3137,7 @@ out: >> >> /* Get the device id from inquiry page 0x83 */ >> 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; >> unsigned char *buf; >> @@ -3149,8 +3149,10 @@ static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr, >> return -ENOMEM; >> rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | 0x83, buf, 64); >> if (rc == 0) >> - memcpy(device_id, &buf[8], buflen); >> + memcpy(device_id, &buf[index], buflen); >> + >> kfree(buf); >> + >> return rc != 0; >> } >> >> @@ -3379,6 +3381,18 @@ static int hpsa_device_supports_aborts(struct ctlr_info *h, >> 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, >> unsigned char scsi3addr[], struct hpsa_scsi_dev_t *this_device, >> unsigned char *is_OBDR_device) > I would prefer to have the function from scsi_scan.c to be exported. > Hardly a point to duplicate it. > > Cheers, > > Hannes I can submit a patch to change it. Can it be in a later patch? -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index c1b053f..1361414 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -3137,7 +3137,7 @@ out: /* Get the device id from inquiry page 0x83 */ 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; unsigned char *buf; @@ -3149,8 +3149,10 @@ static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr, return -ENOMEM; rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | 0x83, buf, 64); if (rc == 0) - memcpy(device_id, &buf[8], buflen); + memcpy(device_id, &buf[index], buflen); + kfree(buf); + return rc != 0; } @@ -3379,6 +3381,18 @@ static int hpsa_device_supports_aborts(struct ctlr_info *h, 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, unsigned char scsi3addr[], struct hpsa_scsi_dev_t *this_device, unsigned char *is_OBDR_device) @@ -3409,6 +3423,9 @@ static int hpsa_update_device_info(struct ctlr_info *h, goto bail_out; } + sanitize_inquiry_string(&inq_buff[8], 8); + sanitize_inquiry_string(&inq_buff[16], 16); + this_device->devtype = (inq_buff[0] & 0x1f); memcpy(this_device->scsi3addr, scsi3addr, 8); memcpy(this_device->vendor, &inq_buff[8], @@ -3417,7 +3434,7 @@ static int hpsa_update_device_info(struct ctlr_info *h, sizeof(this_device->model)); memset(this_device->device_id, 0, 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)); if (this_device->devtype == TYPE_DISK &&