From: Sean Anderson <sean.anderson@linux.dev>
To: Lukasz Majewski <lukma@denx.de>,
Mattijs Korpershoek <mkorpershoek@kernel.org>,
u-boot@lists.denx.de
Cc: Sean Anderson <sean.anderson@linux.dev>
Subject: [PATCH] dfu: Report error codes
Date: Tue, 6 Jan 2026 17:22:11 -0500 [thread overview]
Message-ID: <20260106222212.744823-1-sean.anderson@linux.dev> (raw)
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
next reply other threads:[~2026-01-06 22:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-06 22:22 Sean Anderson [this message]
2026-01-14 11:20 ` [PATCH] dfu: Report error codes Mattijs Korpershoek
2026-01-15 8:25 ` Mattijs Korpershoek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260106222212.744823-1-sean.anderson@linux.dev \
--to=sean.anderson@linux.dev \
--cc=lukma@denx.de \
--cc=mkorpershoek@kernel.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox