Skip to contentSkip to conversation

usb_storage : scan all interfaces to find a storage device

PATCH New franck.jullien at gmail.com 2 participants 4 messages Mar 3, 2015 – Mar 4, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb_storage : scan all interfaces to find a storage device

From: Franck Jullien <[email protected]>

Mass storage is not necessary present on interface 0. This patch allow usb_stor_scan to look in every available interface.

---
 common/usb_storage.c |   32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)
common/usb_storage.c +17 -15
index 1411737..a9160fd 100644
@@ -215,7 +215,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,20 +241,22 @@ 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++) {
+			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++;
+					}
 				}
 			}
 		}
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 usb_storage : scan all interfaces to find a storage device

Quoted 6 lines · franck.jullien at gmail.com

From: Franck Jullien <[email protected]>

Mass storage is not necessary present on interface 0. This patch allow usb_stor_scan to look in every available interface.

Hi!

Do you happen to have such a device which isn't present on interface 0?

Also, can you please rework the patch such that level of indentation would be reasonably low? Possibly by factoring some code into a separate function? I see that the code already has some really nasty indent and your patch even adds to that.

Thank you!

Best regards,
Marek Vasut

#2 lore raw

PATCH 1/1 usb_storage : scan all interfaces to find a storage device

2015-03-03 23:28 GMT+01:00 Marek Vasut <[email protected]>:

Quoted 17 lines · franck.jullien at gmail.com
Quoted 6 lines

From: Franck Jullien <[email protected]>

Mass storage is not necessary present on interface 0. This patch allow usb_stor_scan to look in every available interface.

Hi!

Do you happen to have such a device which isn't present on interface 0?

Also, can you please rework the patch such that level of indentation would be reasonably low? Possibly by factoring some code into a separate function? I see that the code already has some really nasty indent and your patch even adds to that.

Quoted 4 lines

Thank you!

Best regards,
Marek Vasut

I do have such a device. However, that's a custom one. For some reasons we couldn't put the mass storage device to interface 0.

I was wondering about the level of indentation. You confirmed I need to work on it.

Thanks for your comments, I'll send a v2 soon.

Franck.

#3 lore raw

PATCH 1/1 usb_storage : scan all interfaces to find a storage device

Quoted 18 lines · Franck Jullien

2015-03-03 23:28 GMT+01:00 Marek Vasut <[email protected]>:

Quoted 17 lines · franck.jullien at gmail.com
Quoted 6 lines

From: Franck Jullien <[email protected]>

Mass storage is not necessary present on interface 0. This patch allow usb_stor_scan to look in every available interface.

Hi!

Do you happen to have such a device which isn't present on interface 0?

Also, can you please rework the patch such that level of indentation would be reasonably low? Possibly by factoring some code into a separate function? I see that the code already has some really nasty indent and your patch even adds to that.

Quoted 7 lines
Quoted 4 lines

Thank you!

Best regards,
Marek Vasut

I do have such a device. However, that's a custom one. For some reasons we couldn't put the mass storage device to interface 0.

Is that something custom you cannot even name ? Possibly an FPGA on USB ?

Quoted 2 lines

I was wondering about the level of indentation. You confirmed I need to work on it.

Thank _you_ for working on it and keeping up with my ramblings :)

Best regards,
Marek Vasut