Patchwork [U-Boot] usb, dfu gadget: switch to dfu mode in dfu_bind

login
register
mail settings
Submitter Heiko Schocher
Date June 25, 2013, 11:59 a.m.
Message ID <1372161569-1753-1-git-send-email-hs@denx.de>
Download mbox | patch
Permalink /patch/254130/
State Awaiting Upstream
Delegated to: Marek Vasut
Headers show

Comments

Heiko Schocher - June 25, 2013, 11:59 a.m.
- set in to_dfu_mode() f_dfu->dfu_state = DFU_STATE_dfuIDLE
  as after every to_dfu_mode call this is done, so move
  this into to_dfu_mode
- switch in dfu_bind() into dfu mode:
  This fixes wrong "dfu-util -l" output, when calling
  "dfu-util -l" after a board reset, without doing a
  download before. See also discussion here:

http://lists.denx.de/pipermail/u-boot/2013-June/157272.html

Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
Cc: Tom Rini <trini@ti.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Samuel Egli <samuel.egli@siemens.com>
---
 drivers/usb/gadget/f_dfu.c | 4 +++-
 1 Datei geändert, 3 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
Łukasz Majewski - June 25, 2013, 1 p.m.
Hi Heiko,

> - set in to_dfu_mode() f_dfu->dfu_state = DFU_STATE_dfuIDLE
>   as after every to_dfu_mode call this is done, so move
>   this into to_dfu_mode
> - switch in dfu_bind() into dfu mode:
>   This fixes wrong "dfu-util -l" output, when calling
>   "dfu-util -l" after a board reset, without doing a
>   download before. See also discussion here:
> 
> http://lists.denx.de/pipermail/u-boot/2013-June/157272.html
> 

Acked-by: Lukasz Majewski <l.majewski@samsung.com>

Tested-by: Lukasz Majewski <l.majewski@samsung.com>
Test HW: Exynos4210 - Trats target

> Signed-off-by: Heiko Schocher <hs@denx.de>
> Cc: Lukasz Majewski <l.majewski@samsung.com>
> Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
> Cc: Tom Rini <trini@ti.com>
> Cc: Kyungmin Park <kyungmin.park@samsung.com>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Samuel Egli <samuel.egli@siemens.com>
> ---
>  drivers/usb/gadget/f_dfu.c | 4 +++-
>  1 Datei geändert, 3 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
> 
> diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
> index a322ae5..178a004 100644
> --- a/drivers/usb/gadget/f_dfu.c
> +++ b/drivers/usb/gadget/f_dfu.c
> @@ -183,6 +183,7 @@ static inline void to_dfu_mode(struct f_dfu
> *f_dfu) {
>  	f_dfu->usb_function.strings = dfu_strings;
>  	f_dfu->usb_function.hs_descriptors = f_dfu->function;
> +	f_dfu->dfu_state = DFU_STATE_dfuIDLE;
>  }
>  
>  static inline void to_runtime_mode(struct f_dfu *f_dfu)
> @@ -233,7 +234,6 @@ static int state_app_idle(struct f_dfu *f_dfu,
>  	case USB_REQ_DFU_DETACH:
>  		f_dfu->dfu_state = DFU_STATE_appDETACH;
>  		to_dfu_mode(f_dfu);
> -		f_dfu->dfu_state = DFU_STATE_dfuIDLE;
>  		value = RET_ZLP;
>  		break;
>  	default:
> @@ -653,6 +653,8 @@ static int dfu_bind(struct usb_configuration *c,
> struct usb_function *f) ->iInterface = id;
>  	}
>  
> +	to_dfu_mode(f_dfu);
> +
>  	stringtab_dfu.strings = f_dfu->strings;
>  
>  	cdev->req->context = f_dfu;

Patch

diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
index a322ae5..178a004 100644
--- a/drivers/usb/gadget/f_dfu.c
+++ b/drivers/usb/gadget/f_dfu.c
@@ -183,6 +183,7 @@  static inline void to_dfu_mode(struct f_dfu *f_dfu)
 {
 	f_dfu->usb_function.strings = dfu_strings;
 	f_dfu->usb_function.hs_descriptors = f_dfu->function;
+	f_dfu->dfu_state = DFU_STATE_dfuIDLE;
 }
 
 static inline void to_runtime_mode(struct f_dfu *f_dfu)
@@ -233,7 +234,6 @@  static int state_app_idle(struct f_dfu *f_dfu,
 	case USB_REQ_DFU_DETACH:
 		f_dfu->dfu_state = DFU_STATE_appDETACH;
 		to_dfu_mode(f_dfu);
-		f_dfu->dfu_state = DFU_STATE_dfuIDLE;
 		value = RET_ZLP;
 		break;
 	default:
@@ -653,6 +653,8 @@  static int dfu_bind(struct usb_configuration *c, struct usb_function *f)
 			->iInterface = id;
 	}
 
+	to_dfu_mode(f_dfu);
+
 	stringtab_dfu.strings = f_dfu->strings;
 
 	cdev->req->context = f_dfu;