Patchwork [U-Boot,4/4] dfu: Extract common DFU code to handle "dfu_alt_info" environment variable

login
register
mail settings
Submitter Łukasz Majewski
Date Sept. 10, 2013, 1:29 p.m.
Message ID <1378819765-20159-5-git-send-email-l.majewski@samsung.com>
Download mbox | patch
Permalink /patch/273876/
State Superseded
Delegated to: Marek Vasut
Headers show

Comments

Łukasz Majewski - Sept. 10, 2013, 1:29 p.m.
New dfu_init_env_entities() function has been extracted from cmd_dfu.c and
stored at dfu core.

This is a dfu centric code, so it shall be processed in the core.

Change-Id: I756c5de922fa31399d8804eaadc004ee98844ec2
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 common/cmd_dfu.c  |   16 ++--------------
 drivers/dfu/dfu.c |   23 +++++++++++++++++++++++
 include/dfu.h     |    1 +
 3 files changed, 26 insertions(+), 14 deletions(-)
Heiko Schocher - Sept. 11, 2013, 4:39 a.m.
Hello Lukasz,

Am 10.09.2013 15:29, schrieb Lukasz Majewski:
> New dfu_init_env_entities() function has been extracted from cmd_dfu.c and
> stored at dfu core.
>
> This is a dfu centric code, so it shall be processed in the core.
>
> Change-Id: I756c5de922fa31399d8804eaadc004ee98844ec2
> Signed-off-by: Lukasz Majewski<l.majewski@samsung.com>
> ---
>   common/cmd_dfu.c  |   16 ++--------------
>   drivers/dfu/dfu.c |   23 +++++++++++++++++++++++
>   include/dfu.h     |    1 +
>   3 files changed, 26 insertions(+), 14 deletions(-)

Tested on the dxr2 and rut board, so:

Tested-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
Marek Vasut - Sept. 11, 2013, 7:19 a.m.
Dear Lukasz Majewski,

> New dfu_init_env_entities() function has been extracted from cmd_dfu.c and
> stored at dfu core.
> 
> This is a dfu centric code, so it shall be processed in the core.
> 
> Change-Id: I756c5de922fa31399d8804eaadc004ee98844ec2
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>

This does not apply for some reason, I applied 1/2 and 2/2 and pushed u-boot-
usb/master

Best regards,
Marek Vasut
Łukasz Majewski - Sept. 11, 2013, 9:09 a.m.
Hi Marek,

> Dear Lukasz Majewski,
> 
> > New dfu_init_env_entities() function has been extracted from
> > cmd_dfu.c and stored at dfu core.
> > 
> > This is a dfu centric code, so it shall be processed in the core.
> > 
> > Change-Id: I756c5de922fa31399d8804eaadc004ee98844ec2
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> 
> This does not apply for some reason, I applied 1/2 and 2/2 and pushed
> u-boot- usb/master

Marek, please test if it works for you:

1. Fetch u-boot-denx-usb/master -> Patch 1 and 2 applied on top
2. Use download mbox from patchwork:
http://patchwork.ozlabs.org/patch/273876/
3. Apply the patch:
git am -3
U-Boot-4-4-dfu-Extract-common-DFU-code-to-handle-dfu_alt_info-environment-variable.patch

I'm using git - version 1.7.10.4

> 
> Best regards,
> Marek Vasut
Marek Vasut - Sept. 11, 2013, 10:04 a.m.
Dear Lukasz Majewski,

> Hi Marek,
> 
> > Dear Lukasz Majewski,
> > 
> > > New dfu_init_env_entities() function has been extracted from
> > > cmd_dfu.c and stored at dfu core.
> > > 
> > > This is a dfu centric code, so it shall be processed in the core.
> > > 
> > > Change-Id: I756c5de922fa31399d8804eaadc004ee98844ec2
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > 
> > This does not apply for some reason, I applied 1/2 and 2/2 and pushed
> > u-boot- usb/master
> 
> Marek, please test if it works for you:
> 
> 1. Fetch u-boot-denx-usb/master -> Patch 1 and 2 applied on top
> 2. Use download mbox from patchwork:
> http://patchwork.ozlabs.org/patch/273876/
> 3. Apply the patch:
> git am -3
> U-Boot-4-4-dfu-Extract-common-DFU-code-to-handle-dfu_alt_info-environment-v
> ariable.patch
> 
> I'm using git - version 1.7.10.4

No and it cannot:

$ git am /tmp/U-Boot-4-4-dfu-Extract-common-DFU-code-to-handle-dfu_alt_info-
environment-variable.patch
Applying: dfu: Extract common DFU code to handle "dfu_alt_info" environment 
variable                                                                                        
error: patch failed: include/dfu.h:114                                                                                                                                      
error: include/dfu.h: patch does not apply                                                                                                                                  
Patch failed at 0001 dfu: Extract common DFU code to handle "dfu_alt_info" 
environment variable                                                                             
When you have resolved this problem run "git am --resolved".                                                                                                                
If you would prefer to skip this patch, instead run "git am --skip".                                                                                                        
To restore the original branch and stop patching run "git am --abort".

Best regards,
Marek Vasut
Łukasz Majewski - Sept. 11, 2013, 11:30 a.m.
On Wed, 11 Sep 2013 12:04:26 +0200 Marek Vasut marex@denx.de wrote,
> Dear Lukasz Majewski,
> 
> > Hi Marek,
> > 
> > > Dear Lukasz Majewski,
> > > 
> > > > New dfu_init_env_entities() function has been extracted from
> > > > cmd_dfu.c and stored at dfu core.
> > > > 
> > > > This is a dfu centric code, so it shall be processed in the
> > > > core.
> > > > 
> > > > Change-Id: I756c5de922fa31399d8804eaadc004ee98844ec2
> > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > 
> > > This does not apply for some reason, I applied 1/2 and 2/2 and
> > > pushed u-boot- usb/master
> > 
> > Marek, please test if it works for you:
> > 
> > 1. Fetch u-boot-denx-usb/master -> Patch 1 and 2 applied on top
> > 2. Use download mbox from patchwork:
> > http://patchwork.ozlabs.org/patch/273876/
> > 3. Apply the patch:
> > git am -3
> > U-Boot-4-4-dfu-Extract-common-DFU-code-to-handle-dfu_alt_info-environment-v
> > ariable.patch
> > 
> > I'm using git - version 1.7.10.4
> 
> No and it cannot:
> 
> $ git am 

I'm using git am -3 (three way merge).

Can you test it with it?

> /tmp/U-Boot-4-4-dfu-Extract-common-DFU-code-to-handle-dfu_alt_info-
> environment-variable.patch Applying: dfu: Extract common DFU code to
> handle "dfu_alt_info" environment
> variable error: patch failed:
> include/dfu.h:114 error: include/dfu.h: patch does not
> apply Patch failed at 0001 dfu: Extract common DFU code to handle
> "dfu_alt_info" environment
> variable When you have resolved this problem run "git am
> --resolved". If you would prefer to skip this patch, instead run "git
> am --skip". To restore the original branch and stop patching run "git
> am --abort".
> 
> Best regards,
> Marek Vasut
Marek Vasut - Sept. 11, 2013, 11:52 a.m.
Dear Lukasz Majewski,

> On Wed, 11 Sep 2013 12:04:26 +0200 Marek Vasut marex@denx.de wrote,
> 
> > Dear Lukasz Majewski,
> > 
> > > Hi Marek,
> > > 
> > > > Dear Lukasz Majewski,
> > > > 
> > > > > New dfu_init_env_entities() function has been extracted from
> > > > > cmd_dfu.c and stored at dfu core.
> > > > > 
> > > > > This is a dfu centric code, so it shall be processed in the
> > > > > core.
> > > > > 
> > > > > Change-Id: I756c5de922fa31399d8804eaadc004ee98844ec2
> > > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > 
> > > > This does not apply for some reason, I applied 1/2 and 2/2 and
> > > > pushed u-boot- usb/master
> > > 
> > > Marek, please test if it works for you:
> > > 
> > > 1. Fetch u-boot-denx-usb/master -> Patch 1 and 2 applied on top
> > > 2. Use download mbox from patchwork:
> > > http://patchwork.ozlabs.org/patch/273876/
> > > 3. Apply the patch:
> > > git am -3
> > > U-Boot-4-4-dfu-Extract-common-DFU-code-to-handle-dfu_alt_info-environme
> > > nt-v ariable.patch
> > > 
> > > I'm using git - version 1.7.10.4
> > 
> > No and it cannot:
> > 
> > $ git am
> 
> I'm using git am -3 (three way merge).
> 
> Can you test it with it?

As you can clearly see in the patch and compared to dfu.h , the patch cannot be 
applied. The hunk in dfu.h just doesn't match up.

Best regards,
Marek Vasut

Patch

diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c
index 793c422..d3658cf 100644
--- a/common/cmd_dfu.c
+++ b/common/cmd_dfu.c
@@ -17,26 +17,15 @@ 
 
 static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	const char *str_env;
 	char *s = "dfu";
 	int ret, i = 0;
-	char *env_bkp;
 
 	if (argc < 3)
 		return CMD_RET_USAGE;
 
-	str_env = getenv("dfu_alt_info");
-	if (str_env == NULL) {
-		printf("%s: \"dfu_alt_info\" env variable not defined!\n",
-		       __func__);
-		return CMD_RET_FAILURE;
-	}
-
-	env_bkp = strdup(str_env);
-	ret = dfu_config_entities(env_bkp, argv[1],
-			    (int)simple_strtoul(argv[2], NULL, 10));
+	ret = dfu_init_env_entities(argv[1], simple_strtoul(argv[2], NULL, 10));
 	if (ret)
-		return CMD_RET_FAILURE;
+		return ret;
 
 	if (argc > 3 && strcmp(argv[3], "list") == 0) {
 		dfu_show_entities();
@@ -67,7 +56,6 @@  exit:
 	g_dnl_unregister();
 done:
 	dfu_free_entities();
-	free(env_bkp);
 
 	if (dfu_reset())
 		run_command("reset", 0);
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 180d083..8eca5db 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -41,6 +41,29 @@  static int dfu_find_alt_num(const char *s)
 	return ++i;
 }
 
+int dfu_init_env_entities(char *interface, int dev)
+{
+	const char *str_env;
+	char *env_bkp;
+	int ret;
+
+	str_env = getenv("dfu_alt_info");
+	if (!str_env) {
+		error("\"dfu_alt_info\" env variable not defined!\n");
+		return -EINVAL;
+	}
+
+	env_bkp = strdup(str_env);
+	ret = dfu_config_entities(env_bkp, interface, dev);
+	if (ret) {
+		error("DFU entities configuration failed!\n");
+		return ret;
+	}
+
+	free(env_bkp);
+	return 0;
+}
+
 static unsigned char *dfu_buf;
 static unsigned long dfu_buf_size = CONFIG_SYS_DFU_DATA_BUF_SIZE;
 
diff --git a/include/dfu.h b/include/dfu.h
index 8838f9c..58db1ef 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -114,6 +114,7 @@  char *dfu_extract_token(char** e, int *n);
 void dfu_trigger_reset(void);
 int dfu_get_alt(const char *name);
 bool dfu_reset(void);
+int dfu_init_env_entities(char *interface, int dev);
 
 int dfu_read(struct dfu_entity *de, void *buf, int size, int blk_seq_num);
 int dfu_write(struct dfu_entity *de, void *buf, int size, int blk_seq_num);