From: Christoph Hellwig <hch@infradead.org>
To: Hannes Reinecke <hare@suse.de>
Cc: James Bottomley <jbottomley@parallels.com>,
linux-scsi@vger.kernel.org, Christoph Hellwig <hch@infradead.org>,
Jeremy Linton <jlinton@tributary.com>, Kay Sievers <kay@vrfy.org>,
Doug Gilbert <dgilbert@interlog.com>,
Kai Makisara <kai.makisara@kolumbus.fi>
Subject: Re: [PATCH 2/3] Add EVPD page 0x83 to sysfs
Date: Fri, 28 Feb 2014 09:01:31 -0800 [thread overview]
Message-ID: <20140228170131.GA31510@infradead.org> (raw)
In-Reply-To: <1392286032-85036-3-git-send-email-hare@suse.de>
On Thu, Feb 13, 2014 at 11:07:11AM +0100, 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.
This just shows binary data from the protocol, so shouldn't it be a
binary sysfs attribute?
In general I have to I prefer the actual text attributes, but this is
still better than having to do all the SG_IO inquirys.
> - * Returns 0 on success or a negative error number.
> + * Returns size of the vpg page on success or a negative error number.
> */
> static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
> u8 page, unsigned len)
> @@ -962,6 +962,9 @@ static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
> int result;
> unsigned char cmd[16];
>
> + if (len < 4)
> + return -EINVAL;
Seems the change in calling conventions for these existing functions
should be split into a separate patch?
> /**
> + * scsi_attach_vpd - Attach Vital Product Data to a SCSI device structure
> + * @sdev: The device to ask
> + *
> + * Attach the 'Device Identification' VPD page (0x83) to a SCSI device
> + * structure. This information can be used to identify the device
> + * uniquely.
> + */
> +void scsi_attach_vpd(struct scsi_device *sdev)
> +{
> + int result, i;
> + int vpd_len = 255;
> + int pg83_supported = 0;
> + unsigned char *vpd_buf;
> +
> + if (sdev->skip_vpd_pages)
> + return;
> +retry_pg0:
> + vpd_buf = kmalloc(vpd_len, GFP_KERNEL);
> + if (!vpd_buf)
> + return;
> +
> + /* Ask for all the pages supported by this device */
> + result = scsi_vpd_inquiry(sdev, vpd_buf, 0, vpd_len);
> + if (result < 0) {
> + kfree(vpd_buf);
> + return;
> + }
> + if (result > vpd_len) {
> + vpd_len = result;
> + kfree(vpd_buf);
> + goto retry_pg0;
> + }
> +
> + for (i = 4; i < result; i++) {
> + if (vpd_buf[i] == 0x83) {
> + pg83_supported = 1;
> + }
> + }
> + kfree(vpd_buf);
Given how many checks all over the place we have which EVPD pages are
suppored shouldn't we have query for evpd 0, and then set flags in the
scsi device which are present?
Either way I think the call to query evpd 0 should be a separate
function, so even if we don't store the information it's abstracted out.
Also the ses code has another query for 0x83, which now could use the
one attached to the scsi_device.
next prev parent reply other threads:[~2014-02-28 17:01 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-13 10:07 [PATCHv7 0/3] Display EVPD pages in sysfs Hannes Reinecke
2014-02-13 10:07 ` [PATCH 1/3] scsi_sysfs: Implement 'is_visible' callback Hannes Reinecke
2014-02-13 10:07 ` [PATCH 2/3] Add EVPD page 0x83 to sysfs Hannes Reinecke
2014-02-28 17:01 ` Christoph Hellwig [this message]
2014-03-05 7:38 ` Hannes Reinecke
2014-03-05 19:42 ` Christoph Hellwig
2014-03-06 9:01 ` Hannes Reinecke
2014-03-07 10:11 ` Christoph Hellwig
2014-03-07 10:35 ` Hannes Reinecke
2014-03-07 10:44 ` Christoph Hellwig
2014-03-07 10:39 ` James Bottomley
2014-03-07 10:51 ` Hannes Reinecke
2014-03-07 11:01 ` James Bottomley
2014-03-07 11:18 ` Douglas Gilbert
2014-03-07 13:39 ` Hannes Reinecke
2014-03-07 10:40 ` James Bottomley
2014-03-07 10:43 ` Christoph Hellwig
2014-03-07 10:57 ` James Bottomley
2014-02-13 10:07 ` [PATCH 3/3] Add EVPD page 0x80 " Hannes Reinecke
-- strict thread matches above, loose matches on Subject: below --
2014-02-13 10:27 [PATCHv7 0/3][Resend] Display EVPD pages in sysfs Hannes Reinecke
2014-02-13 10:28 ` [PATCH 2/3] Add EVPD page 0x83 to sysfs Hannes Reinecke
2014-03-02 8:34 ` Bart Van Assche
2014-03-05 7:56 ` Hannes Reinecke
2014-03-02 8:36 ` Bart Van Assche
2014-03-05 7:56 ` Hannes Reinecke
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=20140228170131.GA31510@infradead.org \
--to=hch@infradead.org \
--cc=dgilbert@interlog.com \
--cc=hare@suse.de \
--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