* [PATCH] dfu: Report error codes
@ 2026-01-06 22:22 Sean Anderson
2026-01-14 11:20 ` Mattijs Korpershoek
2026-01-15 8:25 ` Mattijs Korpershoek
0 siblings, 2 replies; 3+ messages in thread
From: Sean Anderson @ 2026-01-06 22:22 UTC (permalink / raw)
To: Lukasz Majewski, Mattijs Korpershoek, u-boot; +Cc: Sean Anderson
A lot of things can go wrong while parsing dfu_alt_info. Make sure to
pass the real error codes all the way up instead of replacing them with
an unhelpful -1.
Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
---
drivers/dfu/dfu.c | 52 ++++++++++++++++++++++++++---------------------
1 file changed, 29 insertions(+), 23 deletions(-)
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index eefdf44ec87..90d8b45ce8a 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -185,7 +185,7 @@ int dfu_init_env_entities(char *interface, char *devstr)
ret = dfu_config_entities(env_bkp, interface, devstr);
if (ret) {
- pr_err("DFU entities configuration failed!\n");
+ pr_err("DFU entities configuration failed: %d\n", ret);
pr_err("(partition table does not match dfu_alt_info?)\n");
goto done;
}
@@ -518,7 +518,7 @@ static int dfu_fill_entity(struct dfu_entity *dfu, char *s, int alt,
char *interface, char *devstr)
{
char *argv[DFU_MAX_ENTITY_ARGS];
- int argc;
+ int argc, ret;
char *st;
debug("%s: %s interface: %s dev: %s\n", __func__, s, interface, devstr);
@@ -547,30 +547,37 @@ static int dfu_fill_entity(struct dfu_entity *dfu, char *s, int alt,
/* Specific for mmc device */
if (strcmp(interface, "mmc") == 0) {
- if (dfu_fill_entity_mmc(dfu, devstr, argv, argc))
- return -1;
+ ret = dfu_fill_entity_mmc(dfu, devstr, argv, argc);
+ if (ret)
+ return ret;
} else if (strcmp(interface, "mtd") == 0) {
- if (dfu_fill_entity_mtd(dfu, devstr, argv, argc))
- return -1;
+ ret = dfu_fill_entity_mtd(dfu, devstr, argv, argc);
+ if (ret)
+ return ret;
} else if (strcmp(interface, "nand") == 0) {
- if (dfu_fill_entity_nand(dfu, devstr, argv, argc))
- return -1;
+ ret = dfu_fill_entity_nand(dfu, devstr, argv, argc);
+ if (ret)
+ return ret;
} else if (strcmp(interface, "ram") == 0) {
- if (dfu_fill_entity_ram(dfu, devstr, argv, argc))
- return -1;
+ ret = dfu_fill_entity_ram(dfu, devstr, argv, argc);
+ if (ret)
+ return ret;
} else if (strcmp(interface, "sf") == 0) {
- if (dfu_fill_entity_sf(dfu, devstr, argv, argc))
- return -1;
+ ret = dfu_fill_entity_sf(dfu, devstr, argv, argc);
+ if (ret)
+ return ret;
} else if (strcmp(interface, "virt") == 0) {
- if (dfu_fill_entity_virt(dfu, devstr, argv, argc))
- return -1;
+ ret = dfu_fill_entity_virt(dfu, devstr, argv, argc);
+ if (ret)
+ return ret;
} else if (strcmp(interface, "scsi") == 0) {
- if (dfu_fill_entity_scsi(dfu, devstr, argv, argc))
- return -1;
+ ret = dfu_fill_entity_scsi(dfu, devstr, argv, argc);
+ if (ret)
+ return ret;
} else {
printf("%s: Device %s not (yet) supported!\n",
__func__, interface);
- return -1;
+ return -EOPNOTSUPP;
}
dfu_get_buf(dfu);
@@ -624,12 +631,12 @@ int dfu_alt_add(struct dfu_entity *dfu, char *interface, char *devstr, char *s)
int ret;
if (alt_num_cnt >= dfu_alt_num)
- return -1;
+ return -EINVAL;
p_dfu = &dfu[alt_num_cnt];
ret = dfu_fill_entity(p_dfu, s, alt_num_cnt, interface, devstr);
if (ret)
- return -1;
+ return ret;
list_add_tail(&p_dfu->list, &dfu_list);
alt_num_cnt++;
@@ -645,16 +652,15 @@ int dfu_config_entities(char *env, char *interface, char *devstr)
ret = dfu_alt_init(dfu_find_alt_num(env), &dfu);
if (ret)
- return -1;
+ return ret;
for (i = 0; i < dfu_alt_num; i++) {
s = strsep(&env, ";");
s = skip_spaces(s);
ret = dfu_alt_add(dfu, interface, devstr, s);
- if (ret) {
+ if (ret)
/* We will free "dfu" in dfu_free_entities() */
- return -1;
- }
+ return ret;
}
return 0;
--
2.35.1.1320.gc452695387.dirty
base-commit: 38ace442b630c5ddf049af83e8db229c012ed355
branch: dfu_err
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] dfu: Report error codes
2026-01-06 22:22 [PATCH] dfu: Report error codes Sean Anderson
@ 2026-01-14 11:20 ` Mattijs Korpershoek
2026-01-15 8:25 ` Mattijs Korpershoek
1 sibling, 0 replies; 3+ messages in thread
From: Mattijs Korpershoek @ 2026-01-14 11:20 UTC (permalink / raw)
To: Sean Anderson, Lukasz Majewski, Mattijs Korpershoek, u-boot; +Cc: Sean Anderson
Hi Sean,
Thank you for the patch.
On Tue, Jan 06, 2026 at 17:22, Sean Anderson <sean.anderson@linux.dev> wrote:
> A lot of things can go wrong while parsing dfu_alt_info. Make sure to
> pass the real error codes all the way up instead of replacing them with
> an unhelpful -1.
>
> Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
This is a nice improvement! I'm happy to pick this up.
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
> ---
>
> drivers/dfu/dfu.c | 52 ++++++++++++++++++++++++++---------------------
> 1 file changed, 29 insertions(+), 23 deletions(-)
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dfu: Report error codes
2026-01-06 22:22 [PATCH] dfu: Report error codes Sean Anderson
2026-01-14 11:20 ` Mattijs Korpershoek
@ 2026-01-15 8:25 ` Mattijs Korpershoek
1 sibling, 0 replies; 3+ messages in thread
From: Mattijs Korpershoek @ 2026-01-15 8:25 UTC (permalink / raw)
To: Lukasz Majewski, u-boot, Sean Anderson
Hi,
On Tue, 06 Jan 2026 17:22:11 -0500, Sean Anderson wrote:
> A lot of things can go wrong while parsing dfu_alt_info. Make sure to
> pass the real error codes all the way up instead of replacing them with
> an unhelpful -1.
>
>
Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu (u-boot-dfu)
[1/1] dfu: Report error codes
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/3f9765672ce424300b6d9fb95d8b01313df9dff7
--
Mattijs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-15 8:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-06 22:22 [PATCH] dfu: Report error codes Sean Anderson
2026-01-14 11:20 ` Mattijs Korpershoek
2026-01-15 8:25 ` Mattijs Korpershoek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox