* [PATCH 1/4] USB gadget: at91: return error when no udc is registered
2014-02-13 9:42 USB gadget / dfu fixes Sascha Hauer
@ 2014-02-13 9:42 ` Sascha Hauer
2014-02-13 9:42 ` [PATCH 2/4] dfu command: check return values Sascha Hauer
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2014-02-13 9:42 UTC (permalink / raw)
To: barebox
When no udc is registered it is clearly an error when usb_gadget_poll
is called. Let the upper layers know that.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/usb/gadget/at91_udc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 6eeef7d..8ef1ad0 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1327,7 +1327,7 @@ int usb_gadget_poll(void)
u32 value;
if (!udc->udp_baseaddr)
- return 0;
+ return -ENODEV;
value = gpio_get_value(udc->board.vbus_pin);
value ^= udc->board.vbus_active_low;
--
1.8.5.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/4] dfu command: check return values
2014-02-13 9:42 USB gadget / dfu fixes Sascha Hauer
2014-02-13 9:42 ` [PATCH 1/4] USB gadget: at91: return error when no udc is registered Sascha Hauer
@ 2014-02-13 9:42 ` Sascha Hauer
2014-02-13 9:42 ` [PATCH 3/4] USB gadget: fsl: Bail out if no udc exists Sascha Hauer
2014-02-13 9:42 ` [PATCH 4/4] USB gadget: dfu: propagate error from usb_gadget_poll Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2014-02-13 9:42 UTC (permalink / raw)
To: barebox
Check the return value of usb_dfu_register and bail out
with an error if it fails. Also return successfully if it succeeds
instead of returning 1 unconditionally.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/dfu.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/commands/dfu.c b/commands/dfu.c
index ec1197a..6bd43e4 100644
--- a/commands/dfu.c
+++ b/commands/dfu.c
@@ -101,7 +101,7 @@ static int do_dfu(int argc, char *argv[])
char *manufacturer = "barebox";
const char *productname = barebox_get_model();
u16 idVendor = 0, idProduct = 0;
-
+ int ret;
while((opt = getopt(argc, argv, "m:p:V:P:")) > 0) {
switch(opt) {
@@ -134,6 +134,7 @@ static int do_dfu(int argc, char *argv[])
dfu_alts = xrealloc(dfu_alts, sizeof(*dfu_alts) * (n + 1));
if (dfu_do_parse_one(argstr, &endptr, &dfu_alts[n])) {
printf("parse error\n");
+ ret = -EINVAL;
goto out;
}
argstr = endptr;
@@ -147,7 +148,7 @@ static int do_dfu(int argc, char *argv[])
pdata.idVendor = idVendor;
pdata.idProduct = idProduct;
- usb_dfu_register(&pdata);
+ ret = usb_dfu_register(&pdata);
out:
while (n) {
@@ -155,8 +156,10 @@ out:
free(dfu_alts[n].name);
free(dfu_alts[n].dev);
};
+
free(dfu_alts);
- return 1;
+
+ return ret;
}
BAREBOX_CMD_HELP_START(dfu)
--
1.8.5.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/4] USB gadget: fsl: Bail out if no udc exists
2014-02-13 9:42 USB gadget / dfu fixes Sascha Hauer
2014-02-13 9:42 ` [PATCH 1/4] USB gadget: at91: return error when no udc is registered Sascha Hauer
2014-02-13 9:42 ` [PATCH 2/4] dfu command: check return values Sascha Hauer
@ 2014-02-13 9:42 ` Sascha Hauer
2014-02-13 9:42 ` [PATCH 4/4] USB gadget: dfu: propagate error from usb_gadget_poll Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2014-02-13 9:42 UTC (permalink / raw)
To: barebox
When there is no udc registered bail out in usb_gadget_poll
instead of crashing the system.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/usb/gadget/fsl_udc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c
index 993c7eb..50bae78 100644
--- a/drivers/usb/gadget/fsl_udc.c
+++ b/drivers/usb/gadget/fsl_udc.c
@@ -1938,6 +1938,9 @@ int usb_gadget_poll(void)
u32 irq_src;
int status = 0;
+ if (!udc)
+ return -ENODEV;
+
/* Disable ISR for OTG host mode */
if (udc->stopped)
return -EIO;
--
1.8.5.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 4/4] USB gadget: dfu: propagate error from usb_gadget_poll
2014-02-13 9:42 USB gadget / dfu fixes Sascha Hauer
` (2 preceding siblings ...)
2014-02-13 9:42 ` [PATCH 3/4] USB gadget: fsl: Bail out if no udc exists Sascha Hauer
@ 2014-02-13 9:42 ` Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2014-02-13 9:42 UTC (permalink / raw)
To: barebox
So that the dfu command can bail out with an error when usb_gadget_poll
fails.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/usb/gadget/dfu.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/dfu.c b/drivers/usb/gadget/dfu.c
index e15fc41..5d6d400 100644
--- a/drivers/usb/gadget/dfu.c
+++ b/drivers/usb/gadget/dfu.c
@@ -682,6 +682,8 @@ static struct usb_composite_driver dfu_driver = {
int usb_dfu_register(struct usb_dfu_pdata *pdata)
{
+ int ret;
+
dfu_devs = pdata->alts;
dfu_num_alt = pdata->num_alts;
dfu_dev_descriptor.idVendor = pdata->idVendor;
@@ -692,7 +694,10 @@ int usb_dfu_register(struct usb_dfu_pdata *pdata)
usb_composite_register(&dfu_driver);
while (1) {
- usb_gadget_poll();
+ ret = usb_gadget_poll();
+ if (ret < 0)
+ return ret;
+
if (ctrlc() || dfudetach)
goto out;
}
--
1.8.5.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread