public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] usb_storage : scan all interfaces to find a storage device
Date: Wed, 4 Mar 2015 13:35:17 +0100	[thread overview]
Message-ID: <201503041335.17576.marex@denx.de> (raw)
In-Reply-To: <1425468362-2560-1-git-send-email-franck.jullien@gmail.com>

On Wednesday, March 04, 2015 at 12:26:02 PM, franck.jullien at gmail.com wrote:
> From: Franck Jullien <franck.jullien@gmail.com>
> 
> Mass storage is not necessary present on interface 0. This
> patch allow usb_stor_scan to look in every available interface.
> 
> Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
> ---
> 
> v2: create a new function to improve indentation

Hi!

>  common/usb_storage.c |   45 ++++++++++++++++++++++++++++-----------------
>  1 files changed, 28 insertions(+), 17 deletions(-)
> 
> diff --git a/common/usb_storage.c b/common/usb_storage.c
> index 1411737..8a490d3 100644
> --- a/common/usb_storage.c
> +++ b/common/usb_storage.c
> @@ -208,6 +208,30 @@ static unsigned int usb_get_max_lun(struct us_data
> *us) return (len > 0) ? *result : 0;
>  }
> 
> +static int usb_storage_register(struct usb_device *dev, unsigned char
> iface) +{
> +	int lun, max_lun, start = usb_max_devs;
> +	int nb_dev = 0;
> +
> +	if (usb_storage_probe(dev, iface, &usb_stor[usb_max_devs])) {

In case you invert this condition here, you can even trim the indent
further. Like this:

if (!usb..........)
	return nb_dev;

/*
 * OK, it's..........
 .........
return nb_dev;
}

> +		/* OK, it's a storage device.  Iterate over its LUNs
> +		 * and populate `usb_dev_desc'.
> +		 */

Please fix the comment so that it matches the coding style for multiline
comments, like this.
/*
 * foo
 * bar
 */

> +		max_lun = usb_get_max_lun(&usb_stor[usb_max_devs]);
> +		for (lun = 0;
> +		     lun <= max_lun && usb_max_devs < USB_MAX_STOR_DEV;
> +		     lun++) {

You should be able to put this for () on a single line once you invert
the condition above :)

> +			usb_dev_desc[usb_max_devs].lun = lun;
> +			if (usb_stor_get_info(dev, &usb_stor[start],
> +			    &usb_dev_desc[usb_max_devs]) == 1) {
> +				nb_dev++;
> +			}
> +		}
> +	}
> +
> +	return nb_dev;
> +}

Sorry for pushing you some more, I believe V3 will be the final one.

Thank you!

      reply	other threads:[~2015-03-04 12:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-04 11:26 [U-Boot] [PATCH v2] usb_storage : scan all interfaces to find a storage device franck.jullien at gmail.com
2015-03-04 12:35 ` Marek Vasut [this message]

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=201503041335.17576.marex@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox