diff mbox

[U-Boot] cmd: dfu: Add error handling for board_usb_init

Message ID a70b9dad0ffcb4e3f275f0ebd722bad5956a04c7.1472563105.git.michal.simek@xilinx.com
State Superseded
Delegated to: Michal Simek
Headers show

Commit Message

Michal Simek Aug. 30, 2016, 1:18 p.m. UTC
board_usb_init() can failed and error should be handled properly.

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

 common/dfu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Heiko Schocher Aug. 31, 2016, 4:29 a.m. UTC | #1
Hello Michal,

Am 30.08.2016 um 15:18 schrieb Michal Simek:
> board_usb_init() can failed and error should be handled properly.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
>   common/dfu.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/dfu.c b/common/dfu.c
> index 4c529f7c36f9..e384873f66ed 100644
> --- a/common/dfu.c
> +++ b/common/dfu.c
> @@ -24,7 +24,11 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
>   	bool dfu_reset = false;
>   	int ret, i = 0;
>
> -	board_usb_init(usbctrl_index, USB_INIT_DEVICE);
> +	ret = board_usb_init(usbctrl_index, USB_INIT_DEVICE);
> +	if (ret) {
> +		error("board usb init failed\n");
> +		return CMD_REG_FAILURE;
> +	}
>   	g_dnl_clear_detach();
>   	ret = g_dnl_register(usb_dnl_gadget);
>   	if (ret) {
>
diff mbox

Patch

diff --git a/common/dfu.c b/common/dfu.c
index 4c529f7c36f9..e384873f66ed 100644
--- a/common/dfu.c
+++ b/common/dfu.c
@@ -24,7 +24,11 @@  int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
 	bool dfu_reset = false;
 	int ret, i = 0;
 
-	board_usb_init(usbctrl_index, USB_INIT_DEVICE);
+	ret = board_usb_init(usbctrl_index, USB_INIT_DEVICE);
+	if (ret) {
+		error("board usb init failed\n");
+		return CMD_REG_FAILURE;
+	}
 	g_dnl_clear_detach();
 	ret = g_dnl_register(usb_dnl_gadget);
 	if (ret) {