diff mbox

[U-Boot,v4,1/3] usb:gadget:f_thor: code cleanup in function download_tail()

Message ID 1398704249-23533-1-git-send-email-p.marczak@samsung.com
State Accepted
Delegated to: Marek Vasut
Headers show

Commit Message

Przemyslaw Marczak April 28, 2014, 4:57 p.m. UTC
In thor's download_tail() function, dfu_get_entity() is called
before each dfu_write() call and the returned entity pointers
are the same. So dfu_get_entity() can be called just once and
this patch changes this.

Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Heiko Schocher <hs@denx.de>
Cc: Tom Rini <trini@ti.com>

---
Changes v2:
- separate fix and cleanup into two commits

Changes v3:
- download_tail(): add exit label

Changes v4:
- none
---
 drivers/usb/gadget/f_thor.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Przemyslaw Marczak May 6, 2014, 6:30 a.m. UTC | #1
Hello Heiko,

On 04/28/2014 06:57 PM, Przemyslaw Marczak wrote:
> In thor's download_tail() function, dfu_get_entity() is called
> before each dfu_write() call and the returned entity pointers
> are the same. So dfu_get_entity() can be called just once and
> this patch changes this.
>
> Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
> Cc: Lukasz Majewski <l.majewski@samsung.com>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Heiko Schocher <hs@denx.de>
> Cc: Tom Rini <trini@ti.com>
>
> ---
> Changes v2:
> - separate fix and cleanup into two commits
>
> Changes v3:
> - download_tail(): add exit label
>
> Changes v4:
> - none
> ---

Could you look at those changes, please?

Thank you
Przemyslaw Marczak May 9, 2014, 7:21 a.m. UTC | #2
Hello Marek,

On 04/28/2014 06:57 PM, Przemyslaw Marczak wrote:
> In thor's download_tail() function, dfu_get_entity() is called
> before each dfu_write() call and the returned entity pointers
> are the same. So dfu_get_entity() can be called just once and
> this patch changes this.
>
> Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
> Cc: Lukasz Majewski <l.majewski@samsung.com>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Heiko Schocher <hs@denx.de>
> Cc: Tom Rini <trini@ti.com>
>
> ---
> Changes v2:
> - separate fix and cleanup into two commits
>
> Changes v3:
> - download_tail(): add exit label
>
> Changes v4:
> - none

I've checked the u-boot-usb/master tree and I found that one commit of 
this patch set is missed, because it is v3 (there was only two commits).
Could you please apply the patch set version 4?

Thank you,
Ɓukasz Majewski May 9, 2014, 8:35 a.m. UTC | #3
Hi Przemyslaw, Marek,

> Hello Marek,
> 
> On 04/28/2014 06:57 PM, Przemyslaw Marczak wrote:
> > In thor's download_tail() function, dfu_get_entity() is called
> > before each dfu_write() call and the returned entity pointers
> > are the same. So dfu_get_entity() can be called just once and
> > this patch changes this.
> >
> > Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
> > Cc: Lukasz Majewski <l.majewski@samsung.com>
> > Cc: Marek Vasut <marex@denx.de>
> > Cc: Heiko Schocher <hs@denx.de>
> > Cc: Tom Rini <trini@ti.com>
> >
> > ---
> > Changes v2:
> > - separate fix and cleanup into two commits
> >
> > Changes v3:
> > - download_tail(): add exit label
> >
> > Changes v4:
> > - none
> 
> I've checked the u-boot-usb/master tree and I found that one commit
> of this patch set is missed, because it is v3 (there was only two
> commits). Could you please apply the patch set version 4?

I've discussed this issue with Przemek, and we agreed that Przemek will
prepare diff patch between version 3, which is already in mainline and
version 4.

Then, after ML review, I will pull them to u-boot-dfu branch.

Marek, does it work for you?

> 
> Thank you,
Marek Vasut May 10, 2014, 9:41 a.m. UTC | #4
On Friday, May 09, 2014 at 10:35:54 AM, Lukasz Majewski wrote:
> Hi Przemyslaw, Marek,
> 
> > Hello Marek,
> > 
> > On 04/28/2014 06:57 PM, Przemyslaw Marczak wrote:
> > > In thor's download_tail() function, dfu_get_entity() is called
> > > before each dfu_write() call and the returned entity pointers
> > > are the same. So dfu_get_entity() can be called just once and
> > > this patch changes this.
> > > 
> > > Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
> > > Cc: Lukasz Majewski <l.majewski@samsung.com>
> > > Cc: Marek Vasut <marex@denx.de>
> > > Cc: Heiko Schocher <hs@denx.de>
> > > Cc: Tom Rini <trini@ti.com>
> > > 
> > > ---
> > > Changes v2:
> > > - separate fix and cleanup into two commits
> > > 
> > > Changes v3:
> > > - download_tail(): add exit label
> > > 
> > > Changes v4:
> > > - none
> > 
> > I've checked the u-boot-usb/master tree and I found that one commit
> > of this patch set is missed, because it is v3 (there was only two
> > commits). Could you please apply the patch set version 4?
> 
> I've discussed this issue with Przemek, and we agreed that Przemek will
> prepare diff patch between version 3, which is already in mainline and
> version 4.
> 
> Then, after ML review, I will pull them to u-boot-dfu branch.
> 
> Marek, does it work for you?

Yes, thanks.

Best regards,
Marek Vasut
diff mbox

Patch

diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index f5c0224..1190c74 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -204,17 +204,17 @@  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;
+			goto exit;
 		}
 	}
 
@@ -225,11 +225,11 @@  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);
 
+exit:
 	return ret;
 }