diff mbox

[U-Boot] usb: storage: Show number of storage devices detected for DM_USB

Message ID eb5d51633a391de4e17cce81957983841b6c739c.1482309306.git.michal.simek@xilinx.com
State Accepted
Commit b984700ca4b98597825fbc79c47e7a621889adaf
Delegated to: Marek Vasut
Headers show

Commit Message

Michal Simek Dec. 21, 2016, 8:35 a.m. UTC
By enabling DM_USB information about number of storage devices
was lost.
Get this information back simply by printing number of devices detected
via BLK uclass.

For example:
scanning bus 0 for devices... 7 USB Device(s) found
       scanning usb for storage devices... 3 Storage Device(s) found
       scanning usb for ethernet devices... 0 Ethernet Device(s) found

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 cmd/usb.c            | 2 +-
 common/usb_storage.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

Comments

Marek Vasut Dec. 21, 2016, 2:11 p.m. UTC | #1
On 12/21/2016 09:35 AM, Michal Simek wrote:
> By enabling DM_USB information about number of storage devices
> was lost.
> Get this information back simply by printing number of devices detected
> via BLK uclass.
> 
> For example:
> scanning bus 0 for devices... 7 USB Device(s) found
>        scanning usb for storage devices... 3 Storage Device(s) found
>        scanning usb for ethernet devices... 0 Ethernet Device(s) found
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
>  cmd/usb.c            | 2 +-
>  common/usb_storage.c | 8 ++++----
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/cmd/usb.c b/cmd/usb.c
> index 455127c844b9..4fa456e31834 100644
> --- a/cmd/usb.c
> +++ b/cmd/usb.c
> @@ -571,11 +571,11 @@ static void do_usb_start(void)
>  		return;
>  
>  	/* Driver model will probe the devices as they are found */
> -#ifndef CONFIG_DM_USB
>  # ifdef CONFIG_USB_STORAGE
>  	/* try to recognize storage devices immediately */
>  	usb_stor_curr_dev = usb_stor_scan(1);
>  # endif
> +#ifndef CONFIG_DM_USB
>  # ifdef CONFIG_USB_KEYBOARD
>  	drv_usb_kbd_init();
>  # endif
> diff --git a/common/usb_storage.c b/common/usb_storage.c
> index 0345aa22eff5..b524a15e2bf9 100644
> --- a/common/usb_storage.c
> +++ b/common/usb_storage.c
> @@ -303,7 +303,6 @@ void usb_stor_reset(void)
>  	usb_max_devs = 0;
>  }
>  
> -#ifndef CONFIG_DM_USB
>  /*******************************************************************************
>   * scan the usb and reports device info
>   * to the user if mode = 1
> @@ -311,11 +310,12 @@ void usb_stor_reset(void)
>   */
>  int usb_stor_scan(int mode)
>  {
> -	unsigned char i;
> -
>  	if (mode == 1)
>  		printf("       scanning usb for storage devices... ");
>  
> +#ifndef CONFIG_DM_USB
> +	unsigned char i;

Won't this complain about mixing variables and code ? I think it will.
You can use __maybe_unused if you want to avoid excess ifdeffery.

>  	usb_disable_asynch(1); /* asynch transfer not allowed */
>  
>  	usb_stor_reset();
> @@ -329,12 +329,12 @@ int usb_stor_scan(int mode)
>  	} /* for */
>  
>  	usb_disable_asynch(0); /* asynch transfer allowed */
> +#endif
>  	printf("%d Storage Device(s) found\n", usb_max_devs);
>  	if (usb_max_devs > 0)
>  		return 0;
>  	return -1;
>  }
> -#endif
>  
>  static int usb_stor_irq(struct usb_device *dev)
>  {
>
Michal Simek Dec. 21, 2016, 2:38 p.m. UTC | #2
On 21.12.2016 15:11, Marek Vasut wrote:
> On 12/21/2016 09:35 AM, Michal Simek wrote:
>> By enabling DM_USB information about number of storage devices
>> was lost.
>> Get this information back simply by printing number of devices detected
>> via BLK uclass.
>>
>> For example:
>> scanning bus 0 for devices... 7 USB Device(s) found
>>        scanning usb for storage devices... 3 Storage Device(s) found
>>        scanning usb for ethernet devices... 0 Ethernet Device(s) found
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> ---
>>
>>  cmd/usb.c            | 2 +-
>>  common/usb_storage.c | 8 ++++----
>>  2 files changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/cmd/usb.c b/cmd/usb.c
>> index 455127c844b9..4fa456e31834 100644
>> --- a/cmd/usb.c
>> +++ b/cmd/usb.c
>> @@ -571,11 +571,11 @@ static void do_usb_start(void)
>>  		return;
>>  
>>  	/* Driver model will probe the devices as they are found */
>> -#ifndef CONFIG_DM_USB
>>  # ifdef CONFIG_USB_STORAGE
>>  	/* try to recognize storage devices immediately */
>>  	usb_stor_curr_dev = usb_stor_scan(1);
>>  # endif
>> +#ifndef CONFIG_DM_USB
>>  # ifdef CONFIG_USB_KEYBOARD
>>  	drv_usb_kbd_init();
>>  # endif
>> diff --git a/common/usb_storage.c b/common/usb_storage.c
>> index 0345aa22eff5..b524a15e2bf9 100644
>> --- a/common/usb_storage.c
>> +++ b/common/usb_storage.c
>> @@ -303,7 +303,6 @@ void usb_stor_reset(void)
>>  	usb_max_devs = 0;
>>  }
>>  
>> -#ifndef CONFIG_DM_USB
>>  /*******************************************************************************
>>   * scan the usb and reports device info
>>   * to the user if mode = 1
>> @@ -311,11 +310,12 @@ void usb_stor_reset(void)
>>   */
>>  int usb_stor_scan(int mode)
>>  {
>> -	unsigned char i;
>> -
>>  	if (mode == 1)
>>  		printf("       scanning usb for storage devices... ");
>>  
>> +#ifndef CONFIG_DM_USB
>> +	unsigned char i;
> 
> Won't this complain about mixing variables and code ? I think it will.
> You can use __maybe_unused if you want to avoid excess ifdeffery.

I didn't see this issue on my PC. But I will use travis to validate this
https://travis-ci.org/michalsimek-test/u-boot/builds/185787335

Thanks,
Michal
Michal Simek Dec. 22, 2016, 6:43 a.m. UTC | #3
On 21.12.2016 15:38, Michal Simek wrote:
> On 21.12.2016 15:11, Marek Vasut wrote:
>> On 12/21/2016 09:35 AM, Michal Simek wrote:
>>> By enabling DM_USB information about number of storage devices
>>> was lost.
>>> Get this information back simply by printing number of devices detected
>>> via BLK uclass.
>>>
>>> For example:
>>> scanning bus 0 for devices... 7 USB Device(s) found
>>>        scanning usb for storage devices... 3 Storage Device(s) found
>>>        scanning usb for ethernet devices... 0 Ethernet Device(s) found
>>>
>>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>>> ---
>>>
>>>  cmd/usb.c            | 2 +-
>>>  common/usb_storage.c | 8 ++++----
>>>  2 files changed, 5 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/cmd/usb.c b/cmd/usb.c
>>> index 455127c844b9..4fa456e31834 100644
>>> --- a/cmd/usb.c
>>> +++ b/cmd/usb.c
>>> @@ -571,11 +571,11 @@ static void do_usb_start(void)
>>>  		return;
>>>  
>>>  	/* Driver model will probe the devices as they are found */
>>> -#ifndef CONFIG_DM_USB
>>>  # ifdef CONFIG_USB_STORAGE
>>>  	/* try to recognize storage devices immediately */
>>>  	usb_stor_curr_dev = usb_stor_scan(1);
>>>  # endif
>>> +#ifndef CONFIG_DM_USB
>>>  # ifdef CONFIG_USB_KEYBOARD
>>>  	drv_usb_kbd_init();
>>>  # endif
>>> diff --git a/common/usb_storage.c b/common/usb_storage.c
>>> index 0345aa22eff5..b524a15e2bf9 100644
>>> --- a/common/usb_storage.c
>>> +++ b/common/usb_storage.c
>>> @@ -303,7 +303,6 @@ void usb_stor_reset(void)
>>>  	usb_max_devs = 0;
>>>  }
>>>  
>>> -#ifndef CONFIG_DM_USB
>>>  /*******************************************************************************
>>>   * scan the usb and reports device info
>>>   * to the user if mode = 1
>>> @@ -311,11 +310,12 @@ void usb_stor_reset(void)
>>>   */
>>>  int usb_stor_scan(int mode)
>>>  {
>>> -	unsigned char i;
>>> -
>>>  	if (mode == 1)
>>>  		printf("       scanning usb for storage devices... ");
>>>  
>>> +#ifndef CONFIG_DM_USB
>>> +	unsigned char i;
>>
>> Won't this complain about mixing variables and code ? I think it will.
>> You can use __maybe_unused if you want to avoid excess ifdeffery.
> 
> I didn't see this issue on my PC. But I will use travis to validate this
> https://travis-ci.org/michalsimek-test/u-boot/builds/185787335

Just a note. Travis is not reporting any issue.

Thanks,
Michal
Simon Glass Dec. 26, 2016, 5:24 a.m. UTC | #4
On 22 December 2016 at 19:43, Michal Simek <michal.simek@xilinx.com> wrote:
> On 21.12.2016 15:38, Michal Simek wrote:
>> On 21.12.2016 15:11, Marek Vasut wrote:
>>> On 12/21/2016 09:35 AM, Michal Simek wrote:
>>>> By enabling DM_USB information about number of storage devices
>>>> was lost.
>>>> Get this information back simply by printing number of devices detected
>>>> via BLK uclass.
>>>>
>>>> For example:
>>>> scanning bus 0 for devices... 7 USB Device(s) found
>>>>        scanning usb for storage devices... 3 Storage Device(s) found
>>>>        scanning usb for ethernet devices... 0 Ethernet Device(s) found
>>>>
>>>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>>>> ---
>>>>
>>>>  cmd/usb.c            | 2 +-
>>>>  common/usb_storage.c | 8 ++++----
>>>>  2 files changed, 5 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/cmd/usb.c b/cmd/usb.c
>>>> index 455127c844b9..4fa456e31834 100644
>>>> --- a/cmd/usb.c
>>>> +++ b/cmd/usb.c
>>>> @@ -571,11 +571,11 @@ static void do_usb_start(void)
>>>>             return;
>>>>
>>>>     /* Driver model will probe the devices as they are found */
>>>> -#ifndef CONFIG_DM_USB
>>>>  # ifdef CONFIG_USB_STORAGE
>>>>     /* try to recognize storage devices immediately */
>>>>     usb_stor_curr_dev = usb_stor_scan(1);
>>>>  # endif
>>>> +#ifndef CONFIG_DM_USB
>>>>  # ifdef CONFIG_USB_KEYBOARD
>>>>     drv_usb_kbd_init();
>>>>  # endif
>>>> diff --git a/common/usb_storage.c b/common/usb_storage.c
>>>> index 0345aa22eff5..b524a15e2bf9 100644
>>>> --- a/common/usb_storage.c
>>>> +++ b/common/usb_storage.c
>>>> @@ -303,7 +303,6 @@ void usb_stor_reset(void)
>>>>     usb_max_devs = 0;
>>>>  }
>>>>
>>>> -#ifndef CONFIG_DM_USB
>>>>  /*******************************************************************************
>>>>   * scan the usb and reports device info
>>>>   * to the user if mode = 1
>>>> @@ -311,11 +310,12 @@ void usb_stor_reset(void)
>>>>   */
>>>>  int usb_stor_scan(int mode)
>>>>  {
>>>> -   unsigned char i;
>>>> -
>>>>     if (mode == 1)
>>>>             printf("       scanning usb for storage devices... ");
>>>>
>>>> +#ifndef CONFIG_DM_USB
>>>> +   unsigned char i;
>>>
>>> Won't this complain about mixing variables and code ? I think it will.
>>> You can use __maybe_unused if you want to avoid excess ifdeffery.
>>
>> I didn't see this issue on my PC. But I will use travis to validate this
>> https://travis-ci.org/michalsimek-test/u-boot/builds/185787335
>
> Just a note. Travis is not reporting any issue.

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox

Patch

diff --git a/cmd/usb.c b/cmd/usb.c
index 455127c844b9..4fa456e31834 100644
--- a/cmd/usb.c
+++ b/cmd/usb.c
@@ -571,11 +571,11 @@  static void do_usb_start(void)
 		return;
 
 	/* Driver model will probe the devices as they are found */
-#ifndef CONFIG_DM_USB
 # ifdef CONFIG_USB_STORAGE
 	/* try to recognize storage devices immediately */
 	usb_stor_curr_dev = usb_stor_scan(1);
 # endif
+#ifndef CONFIG_DM_USB
 # ifdef CONFIG_USB_KEYBOARD
 	drv_usb_kbd_init();
 # endif
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 0345aa22eff5..b524a15e2bf9 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -303,7 +303,6 @@  void usb_stor_reset(void)
 	usb_max_devs = 0;
 }
 
-#ifndef CONFIG_DM_USB
 /*******************************************************************************
  * scan the usb and reports device info
  * to the user if mode = 1
@@ -311,11 +310,12 @@  void usb_stor_reset(void)
  */
 int usb_stor_scan(int mode)
 {
-	unsigned char i;
-
 	if (mode == 1)
 		printf("       scanning usb for storage devices... ");
 
+#ifndef CONFIG_DM_USB
+	unsigned char i;
+
 	usb_disable_asynch(1); /* asynch transfer not allowed */
 
 	usb_stor_reset();
@@ -329,12 +329,12 @@  int usb_stor_scan(int mode)
 	} /* for */
 
 	usb_disable_asynch(0); /* asynch transfer allowed */
+#endif
 	printf("%d Storage Device(s) found\n", usb_max_devs);
 	if (usb_max_devs > 0)
 		return 0;
 	return -1;
 }
-#endif
 
 static int usb_stor_irq(struct usb_device *dev)
 {