On Tue, 2015-12-01 at 10:16 +0100, Hannes Reinecke wrote: > Add a function scsi_vpd_lun_id() to return a unique device > identifcation based on the designation descriptors of > VPD page 0x83. > > As devices might implement several descriptors the order > of preference is: > - NAA IEE Registered Extended > - EUI-64 based 16-byte > - EUI-64 based 12-byte > - NAA IEEE Registered > - NAA IEEE Extended > A SCSI name string descriptor is preferred to all of them > if the identification is longer than 16 bytes. > > The returned unique device identification will be formatted > as a SCSI Name string to avoid clashes between different > designator types. > > Reviewed-by: Ewan Milne <emilne@xxxxxxxxxx> > Reviewed-by: Christoph Hellwig <hch@xxxxxx> > Signed-off-by: Hannes Reinecke <hare@xxxxxxx> > --- > drivers/scsi/scsi_lib.c | 140 > +++++++++++++++++++++++++++++++++++++++++++++ > include/scsi/scsi_device.h | 1 + > 2 files changed, 141 insertions(+) > > diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c > index dd8ad2a..5bd8a19 100644 > --- a/drivers/scsi/scsi_lib.c > +++ b/drivers/scsi/scsi_lib.c > @@ -3154,3 +3154,143 @@ void sdev_enable_disk_events(struct scsi_device > *sdev) > atomic_dec(&sdev->disk_events_disable_depth); > } > EXPORT_SYMBOL(sdev_enable_disk_events); Nitpick: kerneldoc comments start with /** > + > +/* > + * scsi_vpd_lun_id - return a unique device identification > + * @sdev: SCSI device > + * @id: buffer for the identification > + * @id_len: length of the buffer > + * > + * Copies a unique device identification into @id based > + * on the information in the VPD page 0x83 of the device. > + * The string will be formatted as a SCSI name string. > + * > + * Returns the length of the identification or error on failure. > + * If the identifier is longer than the supplied buffer the actual > + * identifier length is returned and the buffer is not zero-padded. > + */ > +int scsi_vpd_lun_id(struct scsi_device *sdev, char *id, size_t id_len) > +{ Otherwise Reviewed-by: Johannes Thumshirn <jthumshirn@xxxxxxx> -- 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