diff options
author | Peter Chen <peter.chen@freescale.com> | 2011-03-22 17:27:17 +0800 |
---|---|---|
committer | Andy Voltz <andy.voltz@timesys.com> | 2011-06-01 13:21:08 -0400 |
commit | 59a1bff384a3766cda82bb185ac3d604a1b4ce51 (patch) | |
tree | 93ad6b2cc80ca148d7834b2819bf4e1dddc4e77b | |
parent | 45622833bb38dec3bac38f55632ebe7f7e1869eb (diff) |
ENGR00140950 mfg: fix the bug that ubiformat utility breaks utp protocol
ubiformat includes command, data, command periods,
it breaks utp protocol for PUT commands. So we add two operations to fix it.
One is sending busy to host before the data periods begins.
The second is adding a new command to waiting ubiformat's command period.
Signed-off-by: Li Xingyu <b02754@freescale.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
-rw-r--r-- | drivers/usb/gadget/fsl_updater.c | 32 | ||||
-rw-r--r-- | drivers/usb/gadget/fsl_updater.h | 3 |
2 files changed, 24 insertions, 11 deletions
diff --git a/drivers/usb/gadget/fsl_updater.c b/drivers/usb/gadget/fsl_updater.c index cd8ba2480f6e..e0705b8d9c66 100644 --- a/drivers/usb/gadget/fsl_updater.c +++ b/drivers/usb/gadget/fsl_updater.c @@ -1,7 +1,7 @@ /* * Freescale UUT driver * - * Copyright 2008-2010 Freescale Semiconductor, Inc. + * Copyright 2008-2011 Freescale Semiconductor, Inc. * Copyright 2008-2009 Embedded Alley Solutions, Inc All Rights Reserved. */ @@ -377,13 +377,22 @@ static void utp_poll(struct fsg_dev *fsg) printk(KERN_WARNING "%s: exit with status %d\n", __func__, uud->data.status); UTP_SS_EXIT(fsg, uud->data.status); + } else if (uud->data.flags & UTP_FLAG_REPORT_BUSY) { + UTP_SS_BUSY(fsg, --ctx->counter); } else { - pr_debug("%s: pass\n", __func__); + printk("%s: pass returned.\n", __func__); UTP_SS_PASS(fsg); } utp_user_data_free(uud); } else { - pr_debug("%s: still busy...\n", __func__); + if (utp_context.cur_state & UTP_FLAG_DATA) { + if (count_list(&ctx->read) < 7) { + pr_debug("%s: pass returned in POLL stage. \n", __func__); + UTP_SS_PASS(fsg); + utp_context.cur_state = 0; + return; + } + } UTP_SS_BUSY(fsg, --ctx->counter); } } @@ -396,6 +405,7 @@ static int utp_exec(struct fsg_dev *fsg, struct utp_user_data *uud = NULL, *uud2r; struct utp_context *ctx = UTP_CTX(fsg); + ctx->counter = 0xFFFF; uud2r = utp_user_data_alloc(cmdsize + 1); uud2r->data.flags = UTP_FLAG_COMMAND; uud2r->data.payload = payload; @@ -436,14 +446,13 @@ static int utp_exec(struct fsg_dev *fsg, memcpy(ctx->buffer, uud->data.data, uud->data.bufsize); UTP_SS_SIZE(fsg, uud->data.bufsize); } else if (uud->data.flags & UTP_FLAG_REPORT_BUSY) { - ctx->counter = 0xFFFF; UTP_SS_BUSY(fsg, ctx->counter); } else if (uud->data.flags & UTP_FLAG_STATUS) { printk(KERN_WARNING "%s: exit with status %d\n", __func__, uud->data.status); UTP_SS_EXIT(fsg, uud->data.status); } else { - pr_debug("%s: pass\n", __func__); + pr_debug("%s: pass returned in EXEC stage. \n", __func__); UTP_SS_PASS(fsg); } utp_user_data_free(uud); @@ -531,8 +540,9 @@ static int utp_handle_message(struct fsg_dev *fsg, r = utp_do_read(fsg, UTP_CTX(fsg)->buffer, fsg->data_size); UTP_SS_PASS(fsg); break; - case UTP_PUT: /* data from host to device */ - pr_debug("%s: PUT, %d bytes\n", __func__, fsg->data_size); + case UTP_PUT: + utp_context.cur_state = UTP_FLAG_DATA; + pr_debug("%s: PUT, Received %d bytes\n", __func__, fsg->data_size);/* data from host to device */ uud2r = utp_user_data_alloc(fsg->data_size); uud2r->data.bufsize = fsg->data_size; uud2r->data.flags = UTP_FLAG_DATA; @@ -573,10 +583,12 @@ static int utp_handle_message(struct fsg_dev *fsg, UTP_SS_PASS(fsg); } #endif - UTP_SS_PASS(fsg); + if (count_list(&UTP_CTX(fsg)->read) < 7) { + utp_context.cur_state = 0; + UTP_SS_PASS(fsg); + } else + UTP_SS_BUSY(fsg, UTP_CTX(fsg)->counter); - wait_event_interruptible(UTP_CTX(fsg)->list_full_wq, - count_list(&UTP_CTX(fsg)->read) < 7); break; } diff --git a/drivers/usb/gadget/fsl_updater.h b/drivers/usb/gadget/fsl_updater.h index 1662f9d83ec6..9c276a8f3a92 100644 --- a/drivers/usb/gadget/fsl_updater.h +++ b/drivers/usb/gadget/fsl_updater.h @@ -1,7 +1,7 @@ /* * Freescale UUT driver * - * Copyright 2008-2010 Freescale Semiconductor, Inc. + * Copyright 2008-2011 Freescale Semiconductor, Inc. * Copyright 2008-2009 Embedded Alley Solutions, Inc All Rights Reserved. */ @@ -98,6 +98,7 @@ static struct utp_context { u8 *buffer; u32 counter; u64 utp_version; + u32 cur_state; } utp_context; static const struct file_operations utp_fops = { |