[U-Boot-Users] [PATCH] USB Storage, add meaningful return value

Markus Klotzbücher mk at denx.de
Wed Mar 26 19:14:52 CET 2008


Aras Vaichas <arasv at magtech.com.au> writes:

> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email 
> ______________________________________________________________________--- a/include/usb.h	2008-03-19 13:47:18.000000000 +1100

Its my fault for not paying attention correctly, but this line
essentially broke git-am so that this chunk didn't get applied
correctly.

> -void usb_stor_info(void)
> +int usb_stor_info(void)
>  {
>  	int i;
>  
> -	if (usb_max_devs > 0)
> +	if (usb_max_devs > 0) {
>  		for (i = 0; i < usb_max_devs; i++) {
>  			printf ("  Device %d: ", i);
>  			dev_print(&usb_dev_desc[i]);
> +			return 0;
>  		}

Returning here will result in only the first of all storage devices to
be printed.

> -	else
> +	} else {
>  		printf("No storage devices, perhaps not 'usb start'ed..?\n");
> +		return 1;
> +	}
>  }
>  
>  /*********************************************************************************

I committed the following patch to fix this

diff --git a/common/usb_storage.c b/common/usb_storage.c
index 81d2f92..d263b6c 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -196,12 +196,12 @@ int usb_stor_info(void)
 		for (i = 0; i < usb_max_devs; i++) {
 			printf ("  Device %d: ", i);
 			dev_print(&usb_dev_desc[i]);
-			return 0;
 		}
-	} else {
-		printf("No storage devices, perhaps not 'usb start'ed..?\n");
-		return 1;
+		return 0;
 	}
+	
+	printf("No storage devices, perhaps not 'usb start'ed..?\n");
+	return 1;
 }
 
 /*********************************************************************************


Best regards

     Markus

--
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de






More information about the U-Boot mailing list