* [U-Boot] [PATCH v3] usb_storage : scan all interfaces to find a storage device
@ 2015-03-04 20:07 franck.jullien at gmail.com
2015-03-05 13:52 ` Marek Vasut
2015-04-17 16:33 ` Simon Glass
0 siblings, 2 replies; 6+ messages in thread
From: franck.jullien at gmail.com @ 2015-03-04 20:07 UTC (permalink / raw)
To: u-boot
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
v3: more indentation improvement
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..05c96a8 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]))
+ return nb_dev;
+
+ /*
+ * OK, it's a storage device. Iterate over its LUNs
+ * and populate `usb_dev_desc'.
+ */
+ 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++) {
+ 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;
+}
+
/*******************************************************************************
* scan the usb and reports device info
* to the user if mode = 1
@@ -215,7 +239,7 @@ static unsigned int usb_get_max_lun(struct us_data *us)
*/
int usb_stor_scan(int mode)
{
- unsigned char i;
+ unsigned char i, iface;
struct usb_device *dev;
if (mode == 1)
@@ -241,23 +265,10 @@ int usb_stor_scan(int mode)
if (dev == NULL)
break; /* no more devices available */
- if (usb_storage_probe(dev, 0, &usb_stor[usb_max_devs])) {
- /* OK, it's a storage device. Iterate over its LUNs
- * and populate `usb_dev_desc'.
- */
- int lun, max_lun, start = usb_max_devs;
-
- 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++) {
- usb_dev_desc[usb_max_devs].lun = lun;
- if (usb_stor_get_info(dev, &usb_stor[start],
- &usb_dev_desc[usb_max_devs]) == 1) {
- usb_max_devs++;
- }
- }
+ for (iface = 0; iface < dev->config.no_of_if; iface++) {
+ usb_max_devs += usb_storage_register(dev, iface);
}
+
/* if storage device */
if (usb_max_devs == USB_MAX_STOR_DEV) {
printf("max USB Storage Device reached: %d stopping\n",
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v3] usb_storage : scan all interfaces to find a storage device
2015-03-04 20:07 [U-Boot] [PATCH v3] usb_storage : scan all interfaces to find a storage device franck.jullien at gmail.com
@ 2015-03-05 13:52 ` Marek Vasut
2015-03-05 14:11 ` Franck Jullien
2015-04-17 16:33 ` Simon Glass
1 sibling, 1 reply; 6+ messages in thread
From: Marek Vasut @ 2015-03-05 13:52 UTC (permalink / raw)
To: u-boot
On Wednesday, March 04, 2015 at 09:07:00 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>
Thanks!
Acked-by: Marek Vasut <marex@denx.de>
Are you OK if I apply this for -next (that is, after 2015.04 is out) ?
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v3] usb_storage : scan all interfaces to find a storage device
2015-03-05 13:52 ` Marek Vasut
@ 2015-03-05 14:11 ` Franck Jullien
2015-03-05 15:19 ` Marek Vasut
0 siblings, 1 reply; 6+ messages in thread
From: Franck Jullien @ 2015-03-05 14:11 UTC (permalink / raw)
To: u-boot
2015-03-05 14:52 GMT+01:00 Marek Vasut <marex@denx.de>:
> On Wednesday, March 04, 2015 at 09:07:00 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>
>
> Thanks!
>
> Acked-by: Marek Vasut <marex@denx.de>
>
> Are you OK if I apply this for -next (that is, after 2015.04 is out) ?
>
> Best regards,
> Marek Vasut
Sure, there is no hurry.
Franck.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v3] usb_storage : scan all interfaces to find a storage device
2015-03-05 14:11 ` Franck Jullien
@ 2015-03-05 15:19 ` Marek Vasut
0 siblings, 0 replies; 6+ messages in thread
From: Marek Vasut @ 2015-03-05 15:19 UTC (permalink / raw)
To: u-boot
On Thursday, March 05, 2015 at 03:11:25 PM, Franck Jullien wrote:
> 2015-03-05 14:52 GMT+01:00 Marek Vasut <marex@denx.de>:
> > On Wednesday, March 04, 2015 at 09:07:00 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>
> >
> > Thanks!
> >
> > Acked-by: Marek Vasut <marex@denx.de>
> >
> > Are you OK if I apply this for -next (that is, after 2015.04 is out) ?
> >
> > Best regards,
> > Marek Vasut
>
> Sure, there is no hurry.
Applied for -next , thanks!
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v3] usb_storage : scan all interfaces to find a storage device
2015-03-04 20:07 [U-Boot] [PATCH v3] usb_storage : scan all interfaces to find a storage device franck.jullien at gmail.com
2015-03-05 13:52 ` Marek Vasut
@ 2015-04-17 16:33 ` Simon Glass
2015-04-17 21:09 ` Franck Jullien
1 sibling, 1 reply; 6+ messages in thread
From: Simon Glass @ 2015-04-17 16:33 UTC (permalink / raw)
To: u-boot
+Tom
Hi Franck,
On 4 March 2015 at 13:07, <franck.jullien@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
>
> v3: more indentation improvement
>
> 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..05c96a8 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]))
> + return nb_dev;
> +
> + /*
> + * OK, it's a storage device. Iterate over its LUNs
> + * and populate `usb_dev_desc'.
> + */
> + 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++) {
> + 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++;
Should start or usb_max_devs increase here? This will use the same
block_dev_desc_t for each device, won't it?
> + }
> + }
> +
> + return nb_dev;
> +}
> +
> /*******************************************************************************
> * scan the usb and reports device info
> * to the user if mode = 1
> @@ -215,7 +239,7 @@ static unsigned int usb_get_max_lun(struct us_data *us)
> */
> int usb_stor_scan(int mode)
> {
> - unsigned char i;
> + unsigned char i, iface;
> struct usb_device *dev;
>
> if (mode == 1)
> @@ -241,23 +265,10 @@ int usb_stor_scan(int mode)
> if (dev == NULL)
> break; /* no more devices available */
>
> - if (usb_storage_probe(dev, 0, &usb_stor[usb_max_devs])) {
> - /* OK, it's a storage device. Iterate over its LUNs
> - * and populate `usb_dev_desc'.
> - */
> - int lun, max_lun, start = usb_max_devs;
> -
> - 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++) {
> - usb_dev_desc[usb_max_devs].lun = lun;
> - if (usb_stor_get_info(dev, &usb_stor[start],
> - &usb_dev_desc[usb_max_devs]) == 1) {
> - usb_max_devs++;
> - }
> - }
> + for (iface = 0; iface < dev->config.no_of_if; iface++) {
> + usb_max_devs += usb_storage_register(dev, iface);
> }
> +
> /* if storage device */
> if (usb_max_devs == USB_MAX_STOR_DEV) {
> printf("max USB Storage Device reached: %d stopping\n",
> --
> 1.7.1
>
Regards,
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v3] usb_storage : scan all interfaces to find a storage device
2015-04-17 16:33 ` Simon Glass
@ 2015-04-17 21:09 ` Franck Jullien
0 siblings, 0 replies; 6+ messages in thread
From: Franck Jullien @ 2015-04-17 21:09 UTC (permalink / raw)
To: u-boot
Hi Simon,
2015-04-17 18:33 GMT+02:00 Simon Glass <sjg@chromium.org>:
> +Tom
>
> Hi Franck,
>
> On 4 March 2015 at 13:07, <franck.jullien@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
>>
>> v3: more indentation improvement
>>
>> 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..05c96a8 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]))
>> + return nb_dev;
>> +
>> + /*
>> + * OK, it's a storage device. Iterate over its LUNs
>> + * and populate `usb_dev_desc'.
>> + */
>> + 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++) {
>> + 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++;
>
> Should start or usb_max_devs increase here? This will use the same
> block_dev_desc_t for each device, won't it?
>
Good catch. I'll write a patch when I have some time (or someone can do that).
However, I won't be able to test it on hardware because I don't have
access to it anymore.
We could also revert this patch. Sorry for my mistake.
Franck.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-04-17 21:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-04 20:07 [U-Boot] [PATCH v3] usb_storage : scan all interfaces to find a storage device franck.jullien at gmail.com
2015-03-05 13:52 ` Marek Vasut
2015-03-05 14:11 ` Franck Jullien
2015-03-05 15:19 ` Marek Vasut
2015-04-17 16:33 ` Simon Glass
2015-04-17 21:09 ` Franck Jullien
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox