[U-Boot] [PATCH] usb:gadget:f_thor: fix write to filesystem by add dfu_flush()

Marek Vasut marex at denx.de
Thu Apr 17 20:11:28 CEST 2014


On Thursday, April 17, 2014 at 07:31:00 PM, Przemyslaw Marczak wrote:
> Since dfu read/write operations needs to be flushed manually,
> writing to filesystem on MMC by thor was broken. MMC raw write
> actually is working fine because current dfu_flush() function
> writes filesystem only. This commit adds dfu_flush() to f_thor
> and now filesystem write is working.
> 
> This change was tested on Trats2 board.
> 
> Signed-off-by: Przemyslaw Marczak <p.marczak at samsung.com>
> Cc: Lukasz Majewski <l.majewski at samsung.com>
> Cc: Marek Vasut <marex at denx.de>
> Cc: Heiko Schocher <hs at denx.de>
> Cc: Tom Rini <trini at ti.com>
> ---
>  drivers/usb/gadget/f_thor.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
> index f5c0224..ba47945 100644
> --- a/drivers/usb/gadget/f_thor.c
> +++ b/drivers/usb/gadget/f_thor.c
> @@ -204,14 +204,14 @@ static long long int download_head(unsigned long long
> total,
> 
>  static int download_tail(long long int left, int cnt)
>  {
> +	struct dfu_entity *dfu_entity = dfu_get_entity(alt_setting_num);
>  	void *transfer_buffer = dfu_get_buf();
>  	int ret;
> 
>  	debug("%s: left: %llu cnt: %d\n", __func__, left, cnt);
> 
>  	if (left) {
> -		ret = dfu_write(dfu_get_entity(alt_setting_num),
> -				transfer_buffer, left, cnt++);
> +		ret = dfu_write(dfu_entity, transfer_buffer, left, cnt++);
>  		if (ret) {
>  			error("DFU write failed [%d]: left: %llu", ret, left);
>  			return ret;
> @@ -225,11 +225,16 @@ static int download_tail(long long int left, int cnt)
>  	 * This also frees memory malloc'ed by dfu_get_buf(), so no explicit
>  	 * need fo call dfu_free_buf() is needed.
>  	 */
> -	ret = dfu_write(dfu_get_entity(alt_setting_num),
> -			transfer_buffer, 0, cnt);
> +	ret = dfu_write(dfu_entity, transfer_buffer, 0, cnt);
>  	if (ret)
>  		error("DFU write failed [%d] cnt: %d", ret, cnt);

Please split this into two patches, one which does cleanup (that's the part 
above) and one which fixes the functionality (that's the part below).

> +	ret = dfu_flush(dfu_entity, transfer_buffer, 0, cnt);
> +	if (ret) {
> +		error("DFU flush failed!");
> +		return ret;
> +	}
> +
>  	return ret;
>  }

Best regards,
Marek Vasut


More information about the U-Boot mailing list