public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: James Bottomley <jbottomley@parallels.com>
Cc: linux-scsi@vger.kernel.org, Kay Sievers <kay@vrfy.org>,
	Hannes Reinecke <hare@suse.de>,
	Jeremy Linton <jlinton@tributary.com>,
	Doug Gilbert <dgilbert@interlog.com>,
	Kai Makisara <kai.makisara@kolumbus.fi>
Subject: Re: [PATCH][RFC] Add EVPD page 0x83 entries to sysfs
Date: Thu, 06 Feb 2014 14:12:18 +0100	[thread overview]
Message-ID: <52F38A32.8050003@suse.de> (raw)
In-Reply-To: <1391691878-61265-1-git-send-email-hare@suse.de>

On 02/06/2014 02:04 PM, Hannes Reinecke wrote:
> EVPD page 0x83 is used to uniquely identify the device.
> So instead of having each and every program issue a separate
> SG_IO call to retrieve this information it does make far more
> sense to display it in sysfs.
> 
> Cc: Jeremy Linton <jlinton@tributary.com>
> Cc: Doug Gilbert <dgilbert@interlog.com>
> Cc: Kai Makisara <kai.makisara@kolumbus.fi>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>  drivers/scsi/scsi_scan.c   |   3 +
>  drivers/scsi/scsi_sysfs.c  | 166 ++++++++++++++++++++++++++++++++++++++++++++-
>  include/scsi/scsi_device.h |   3 +
>  3 files changed, 171 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> index 307a811..073fb84 100644
> --- a/drivers/scsi/scsi_scan.c
> +++ b/drivers/scsi/scsi_scan.c
> @@ -929,6 +929,9 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
>  	if (*bflags & BLIST_SKIP_VPD_PAGES)
>  		sdev->skip_vpd_pages = 1;
>  
> +	if (sdev->scsi_level >= SCSI_3)
> +		scsi_attach_vpd_ident(sdev);
> +
>  	transport_configure_device(&sdev->sdev_gendev);
>  
>  	if (sdev->host->hostt->slave_configure) {
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index 9117d0b..ffe7cb5 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -725,8 +725,170 @@ show_queue_type_field(struct device *dev, struct device_attribute *attr,
>  
>  static DEVICE_ATTR(queue_type, S_IRUGO, show_queue_type_field, NULL);
>  
> +void scsi_attach_vpd_ident(struct scsi_device *sdev)
> +{
> +	int ret;
> +	int vpd_len = 255;
> +	unsigned char *buffer;
> +retry:
> +	buffer = kmalloc(vpd_len, GFP_KERNEL);
> +	if (buffer) {
> +		ret = scsi_get_vpd_page(sdev, 0x83, buffer, vpd_len);
> +		if (ret == 0) {
> +			vpd_len = (buffer[2] << 8) + buffer[3];
> +			if (vpd_len > 255) {
> +				kfree(buffer);
> +				goto retry;
> +			}
> +			sdev->vpd_ident_len = vpd_len;
> +			sdev->vpd_ident = buffer;
> +		}
> +	}
> +}
> +
Bummer. A missing kfree() if scsi_get_vpd_page() returns an error.
But this is just an RFC for now, so I'll be fixing it up once
it looks as if it would be moving forward...

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
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

  reply	other threads:[~2014-02-06 13:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-06 13:04 [PATCH][RFC] Add EVPD page 0x83 entries to sysfs Hannes Reinecke
2014-02-06 13:12 ` Hannes Reinecke [this message]
2014-02-06 19:14 ` Douglas Gilbert
2014-02-07 15:15   ` Hannes Reinecke
2014-02-12 15:41 ` James Bottomley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52F38A32.8050003@suse.de \
    --to=hare@suse.de \
    --cc=dgilbert@interlog.com \
    --cc=jbottomley@parallels.com \
    --cc=jlinton@tributary.com \
    --cc=kai.makisara@kolumbus.fi \
    --cc=kay@vrfy.org \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox