mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Eric Bénard" <eric@eukrea.com>
To: barebox@lists.infradead.org
Subject: [PATCH v4 2/5] dfu: fill bwPollTimeout and better handle detach
Date: Wed,  4 Jan 2012 10:36:46 +0100	[thread overview]
Message-ID: <1325669809-32637-2-git-send-email-eric@eukrea.com> (raw)
In-Reply-To: <1325669809-32637-1-git-send-email-eric@eukrea.com>

- bwPollTimeout is set to 10 ms, from the DFU spec, this
is the minimum time, in milliseconds, that the host should
wait before sending a subsequent DFU_GETSTATUS request.
Without this, I get 25 seconds value and dfu-util waits twice 25s
during download
- when in IDLE and receiving DETACH, first return 0 to make
dfu-util happy, then use a dfudetach variable to exit dfu
(without an USB reset as per the comment on line 425) and
return to runtime mode.
- tested on i.MX25 & i.MX35 & usb-a926x

Signed-off-by: Eric Bénard <eric@eukrea.com>
Tested-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/usb/gadget/dfu.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/gadget/dfu.c b/drivers/usb/gadget/dfu.c
index 0a0d244..f26c1e4 100644
--- a/drivers/usb/gadget/dfu.c
+++ b/drivers/usb/gadget/dfu.c
@@ -67,6 +67,7 @@ static int dfualt;
 static int dfufd = -EINVAL;;
 static struct usb_dfu_dev *dfu_devs;
 static int dfu_num_alt;
+static int dfudetach;
 
 /* USB DFU functional descriptor */
 static struct usb_dfu_func_descriptor usb_dfu_func = {
@@ -204,6 +205,9 @@ static int dfu_status(struct usb_function *f, const struct usb_ctrlrequest *ctrl
 	dstat->bStatus = dfu->dfu_status;
 	dstat->bState  = dfu->dfu_state;
 	dstat->iString = 0;
+	dstat->bwPollTimeout[0] = 10;
+	dstat->bwPollTimeout[1] = 0;
+	dstat->bwPollTimeout[2] = 0;
 
 	return sizeof(*dstat);
 }
@@ -425,6 +429,8 @@ static int dfu_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
 			 * least the Linux USB stack likes to send a number of resets
 			 * in a row :( */
 			dfu->dfu_state = DFU_STATE_dfuMANIFEST_WAIT_RST;
+			value = 0;
+			dfudetach = 1;
 			break;
 		default:
 			dfu->dfu_state = DFU_STATE_dfuERROR;
@@ -690,11 +696,12 @@ int usb_dfu_register(struct usb_dfu_pdata *pdata)
 
 	while (1) {
 		usb_gadget_poll();
-		if (ctrlc())
+		if (ctrlc() || dfudetach)
 			goto out;
 	}
 
 out:
+	dfudetach = 0;
 	usb_composite_unregister(&dfu_driver);
 
 	return 0;
-- 
1.7.7.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-01-04  9:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-04  9:36 [PATCH v4 1/5] fsl_udc: update and fix Eric Bénard
2012-01-04  9:36 ` Eric Bénard [this message]
2012-01-04  9:36 ` [PATCH v4 3/5] serial gadget: enable/disable on request Eric Bénard
2012-01-04  9:36 ` [PATCH v4 4/5] timeout: add poller_call Eric Bénard
2012-01-04 10:47   ` Jean-Christophe PLAGNIOL-VILLARD
2012-01-04 11:10     ` Eric Bénard
2012-01-04 11:44       ` Jean-Christophe PLAGNIOL-VILLARD
2012-01-04 13:32         ` Eric Bénard
2012-01-04 15:31     ` Eric Bénard
2012-01-04  9:36 ` [PATCH v4 5/5] eukrea_cpuimx35: fix compilation when CONFIG_USB_GADGET is enabled Eric Bénard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1325669809-32637-2-git-send-email-eric@eukrea.com \
    --to=eric@eukrea.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox