dfu: Report error codes
PATCH 1/1 dfu: Report error codes
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 <[email protected]>
---
drivers/dfu/dfu.c | 52 ++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 23 deletions(-)
drivers/dfu/dfu.c +29 -23
@@ -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 ;
Signature · 4 lines
2.35.1.1320.gc452695387.dirty base-commit: 38ace442b630c5ddf049af83e8db229c012ed355 branch: dfu_err
Hi Sean,
Thank you for the patch.
Quoted 5 lines · 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 <[email protected]>
This is a nice improvement! I'm happy to pick this up.
Reviewed-by Mattijs Korpershoek <[email protected]>
Quoted 5 lines
---
drivers/dfu/dfu.c | 52 ++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 23 deletions(-)
Hi,
Quoted 5 lines · 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.
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