All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Matthew Wilcox <matthew@wil.cx>
Cc: linux-scsi@vger.kernel.org, Matthew Wilcox <willy@linux.intel.com>
Subject: Re: [PATCH] ses: Use new scsi VPD helper
Date: Wed, 31 Dec 2008 12:59:38 -0600	[thread overview]
Message-ID: <1230749978.3408.128.camel@localhost.localdomain> (raw)
In-Reply-To: <1230747167-31677-2-git-send-email-matthew@wil.cx>

On Wed, 2008-12-31 at 13:12 -0500, Matthew Wilcox wrote:
> SES had its own code to retrieve VPD from devices; convert it to use the
> new scsi_get_vpd_page helper.
> 
> Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
> ---
>  drivers/scsi/ses.c |   29 +++--------------------------
>  1 files changed, 3 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
> index 7f0df29..95e48ad 100644
> --- a/drivers/scsi/ses.c
> +++ b/drivers/scsi/ses.c
> @@ -345,44 +345,21 @@ static int ses_enclosure_find_by_addr(struct enclosure_device *edev,
>  	return 0;
>  }
>  
> -#define VPD_INQUIRY_SIZE 36
> -
>  static void ses_match_to_enclosure(struct enclosure_device *edev,
>  				   struct scsi_device *sdev)
>  {
> -	unsigned char *buf = kmalloc(VPD_INQUIRY_SIZE, GFP_KERNEL);
> +	unsigned char *buf;
>  	unsigned char *desc;
>  	u16 vpd_len;
>  	struct efd efd = {
>  		.addr = 0,
>  	};
> -	unsigned char cmd[] = {
> -		INQUIRY,
> -		1,
> -		0x83,
> -		VPD_INQUIRY_SIZE >> 8,
> -		VPD_INQUIRY_SIZE & 0xff,
> -		0
> -	};
>  
> +	buf = scsi_get_vpd_page(sdev, 0x83);
>  	if (!buf)
>  		return;
>  
> -	if (scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf,
> -			     VPD_INQUIRY_SIZE, NULL, SES_TIMEOUT, SES_RETRIES,
> -			     NULL))
> -		goto free;
> -
> -	vpd_len = (buf[2] << 8) + buf[3];
> -	kfree(buf);
> -	buf = kmalloc(vpd_len, GFP_KERNEL);
> -	if (!buf)
> -		return;
> -	cmd[3] = vpd_len >> 8;
> -	cmd[4] = vpd_len & 0xff;
> -	if (scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf,
> -			     vpd_len, NULL, SES_TIMEOUT, SES_RETRIES, NULL))
> -		goto free;
> +	vpd_len = (buf[2] << 8) | buf[3];

This was actually wrong in the original code.  It should be

pd_len = (buf[2] << 8) | buf[3] + 4;

to account for the header offset in the returned data length.

James



  reply	other threads:[~2008-12-31 18:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-31 18:12 [PATCH] scsi: Add VPD helper Matthew Wilcox
2008-12-31 18:12 ` [PATCH] ses: Use new scsi " Matthew Wilcox
2008-12-31 18:59   ` James Bottomley [this message]
2008-12-31 19:11     ` Matthew Wilcox
2009-01-01  9:19 ` [PATCH] scsi: Add " Boaz Harrosh
2009-01-01 13:38   ` Matthew Wilcox
2009-01-10 18:53 ` 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=1230749978.3408.128.camel@localhost.localdomain \
    --to=james.bottomley@hansenpartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=matthew@wil.cx \
    --cc=willy@linux.intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.