All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v6 1/2] common: usb_storage: Make common function for usb_stor_read/usb_stor_write
Date: Thu, 16 Jun 2016 00:03:04 +0200	[thread overview]
Message-ID: <5761D098.5090603@denx.de> (raw)
In-Reply-To: <1465974004-25555-2-git-send-email-rajesh.bhagat@nxp.com>

On 06/15/2016 09:00 AM, Rajesh Bhagat wrote:
> Performs code cleanup by making common function for usb_stor_read/
> usb_stor_write. Currently only difference in these fucntions is call
> to usb_read_10/usb_write_10 scsi commands.
> 
> Signed-off-by: Rajesh Bhagat <rajesh.bhagat@nxp.com>
> ---
> Changes in v6:
>  - Removes USB_STOR_OP_TYPE macro and adds __func__ in debug prints
>  - Unifies usb_read_10/usb_write_10 functions to usb_read_write_10
> 
> Changes in v5:
>  - Converts USB_STOR_OPERATION_FUNC macro to a function
>  - Corrects the multi line comment accroding to coding style
>  - Renames variable to dev to remove code duplication
> 
> Changes in v4:
>  - Adds code to make common function for read/write
> 
>  common/usb_storage.c | 147 +++++++++++++--------------------------------------
>  1 file changed, 36 insertions(+), 111 deletions(-)
> 
> diff --git a/common/usb_storage.c b/common/usb_storage.c
> index 7e6e52d..41e5aa3 100644
> --- a/common/usb_storage.c
> +++ b/common/usb_storage.c
> @@ -1046,11 +1046,11 @@ static int usb_read_capacity(ccb *srb, struct us_data *ss)
>  	return -1;
>  }
>  
> -static int usb_read_10(ccb *srb, struct us_data *ss, unsigned long start,
> -		       unsigned short blocks)
> +static int usb_read_write_10(ccb *srb, struct us_data *ss, unsigned long start,
> +		       unsigned short blocks, bool is_write)
>  {
>  	memset(&srb->cmd[0], 0, 12);
> -	srb->cmd[0] = SCSI_READ10;
> +	srb->cmd[0] = is_write ? SCSI_WRITE10 : SCSI_READ10;
>  	srb->cmd[1] = srb->lun << 5;
>  	srb->cmd[2] = ((unsigned char) (start >> 24)) & 0xff;
>  	srb->cmd[3] = ((unsigned char) (start >> 16)) & 0xff;
> @@ -1059,28 +1059,10 @@ static int usb_read_10(ccb *srb, struct us_data *ss, unsigned long start,
>  	srb->cmd[7] = ((unsigned char) (blocks >> 8)) & 0xff;
>  	srb->cmd[8] = (unsigned char) blocks & 0xff;
>  	srb->cmdlen = 12;
> -	debug("read10: start %lx blocks %x\n", start, blocks);
> +	debug("%s: start %lx blocks %x\n", __func__, start, blocks);
>  	return ss->transport(srb, ss);
>  }
>  
> -static int usb_write_10(ccb *srb, struct us_data *ss, unsigned long start,
> -			unsigned short blocks)
> -{
> -	memset(&srb->cmd[0], 0, 12);
> -	srb->cmd[0] = SCSI_WRITE10;
> -	srb->cmd[1] = srb->lun << 5;
> -	srb->cmd[2] = ((unsigned char) (start >> 24)) & 0xff;
> -	srb->cmd[3] = ((unsigned char) (start >> 16)) & 0xff;
> -	srb->cmd[4] = ((unsigned char) (start >> 8)) & 0xff;
> -	srb->cmd[5] = ((unsigned char) (start)) & 0xff;
> -	srb->cmd[7] = ((unsigned char) (blocks >> 8)) & 0xff;
> -	srb->cmd[8] = (unsigned char) blocks & 0xff;
> -	srb->cmdlen = 12;
> -	debug("write10: start %lx blocks %x\n", start, blocks);
> -	return ss->transport(srb, ss);
> -}
> -

This stuff should be in a separate patch, otherwise it's not bisectable.
Looks pretty OK otherwise.

[...]

-- 
Best regards,
Marek Vasut

  reply	other threads:[~2016-06-15 22:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-15  7:00 [U-Boot] [PATCH v6 0/2] common: usb_storage : Implement logic to calculate optimal Rajesh Bhagat
2016-06-15  7:00 ` [U-Boot] [PATCH v6 1/2] common: usb_storage: Make common function for usb_stor_read/usb_stor_write Rajesh Bhagat
2016-06-15 22:03   ` Marek Vasut [this message]
2016-06-16  4:40     ` Rajesh Bhagat
2016-06-15  7:00 ` [U-Boot] [PATCH v6 2/2] common: usb_storage : Implement logic to calculate optimal usb maximum trasfer blocks Rajesh Bhagat

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=5761D098.5090603@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /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.