From: Minkyu Kang Date: Tue, 21 Dec 2010 07:24:06 +0000 (+0900) Subject: usbd: add normal mode at cancel the downloading X-Git-Tag: v0.2~129 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0693c345a7453fb69be5cf360c3a4218a565a96f;p=kernel%2Fu-boot.git usbd: add normal mode at cancel the downloading Signed-off-by: Minkyu Kang --- diff --git a/arch/arm/cpu/armv7/s5p-common/usb_downloader.c b/arch/arm/cpu/armv7/s5p-common/usb_downloader.c index f83964f..a93b4fb 100644 --- a/arch/arm/cpu/armv7/s5p-common/usb_downloader.c +++ b/arch/arm/cpu/armv7/s5p-common/usb_downloader.c @@ -210,10 +210,16 @@ static void down_cancel(int mode) fb_clear(120); } #endif - if (mode) - run_command("usbdown", 0); - else + switch (mode) { + case END_BOOT: run_command("run bootcmd", 0); + break; + case END_RETRY: + run_command("usbdown", 0); + break; + default: + break; + } } /* diff --git a/common/cmd_usbd.c b/common/cmd_usbd.c index 23e8e5e..ec407d1 100644 --- a/common/cmd_usbd.c +++ b/common/cmd_usbd.c @@ -1112,7 +1112,7 @@ static int process_data(struct usbd_ops *usbd) recvlen = usbd->recv_data(); if (recvlen < 0) { send_ack(usbd, STATUS_ERROR); - return 0; + return -1; } else if (recvlen < len) { printf("Error: wrong image size -> %d/%d\n", (int)recvlen, (int)len); @@ -1328,7 +1328,7 @@ static int process_data(struct usbd_ops *usbd) /* Stop USB */ usbd->usb_stop(); - return 0; + return -1; case COMMAND_RAM_BOOT: usbd->usb_stop(); @@ -1390,7 +1390,7 @@ static int process_data(struct usbd_ops *usbd) if (ret < 0) { send_ack(usbd, STATUS_ERROR); - return 0; + return -1; } else if (ret) { /* Retry this commad */ send_ack(usbd, STATUS_RETRY); @@ -1449,7 +1449,7 @@ int do_usbd_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) /* init the usb controller */ if (!usbd->usb_init()) { - usbd->down_cancel(0); + usbd->down_cancel(END_BOOT); return 0; } mmc = find_mmc_device(usbd->mmc_dev); @@ -1472,10 +1472,10 @@ int do_usbd_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; } } else if (ret < 0) { - usbd->down_cancel(1); + usbd->down_cancel(END_RETRY); return 0; } else { - usbd->down_cancel(0); + usbd->down_cancel(END_BOOT); return 0; } @@ -1488,15 +1488,19 @@ int do_usbd_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ret = usbd->recv_data(); if (ret > 0) { - if (process_data(usbd) == 0) { - usbd->down_cancel(1); + ret = process_data(usbd); + if (ret < 0) { + usbd->down_cancel(END_RETRY); + return 0; + } else if (ret == 0) { + usbd->down_cancel(END_NORMAL); return 0; } } else if (ret < 0) { - usbd->down_cancel(1); + usbd->down_cancel(END_RETRY); return 0; } else { - usbd->down_cancel(0); + usbd->down_cancel(END_BOOT); return 0; } } diff --git a/include/usbd.h b/include/usbd.h index 7db07f8..44e1483 100644 --- a/include/usbd.h +++ b/include/usbd.h @@ -95,6 +95,12 @@ enum { MODE_FORCE, }; +/* end mode */ +enum { + END_BOOT = 0, + END_RETRY, + END_NORMAL, +}; /* * USB Downloader Operations * All functions and valuable are mandatory