aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Delaunay <patrick.delaunay@foss.st.com>2023-06-08 17:16:39 +0200
committerPatrice Chotard <patrice.chotard@foss.st.com>2023-06-16 11:01:16 +0200
commit28d3439f1b343f1299c8e92a673ceca2d9296baa (patch)
tree9468c0c2caa8ba9bd7faecaa089457dfd5916856
parent163c5f60ebb492eb3bab75e299cb43e6d022653d (diff)
downloadu-boot-28d3439f1b343f1299c8e92a673ceca2d9296baa.zip
u-boot-28d3439f1b343f1299c8e92a673ceca2d9296baa.tar.gz
u-boot-28d3439f1b343f1299c8e92a673ceca2d9296baa.tar.bz2
dfu: mtd: remove direct call of mtdparts_init function
With MTD support in driver model, the direct call of mtdparts_init should be avoided and replaced by mtd_probe_devices. With the modificaton when MTDIDS/MTDPARTS are empty the OF fallback with partition describe in device tree is correctly performed, introduced by commit dc339bf784f0 ("mtd: add support for parsing partitions defined in OF"). With this patch the dependency with CONFIG_CMD_MTDPARTS is removed. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
-rw-r--r--drivers/dfu/Kconfig1
-rw-r--r--drivers/dfu/dfu_mtd.c34
2 files changed, 19 insertions, 16 deletions
diff --git a/drivers/dfu/Kconfig b/drivers/dfu/Kconfig
index 8d7f13d..c3a0b93 100644
--- a/drivers/dfu/Kconfig
+++ b/drivers/dfu/Kconfig
@@ -41,7 +41,6 @@ config DFU_MMC
config DFU_MTD
bool "MTD back end for DFU"
depends on DM_MTD
- depends on CMD_MTDPARTS
help
This option enables using DFU to read and write to on any MTD device.
diff --git a/drivers/dfu/dfu_mtd.c b/drivers/dfu/dfu_mtd.c
index c7075f1..75e2f6a 100644
--- a/drivers/dfu/dfu_mtd.c
+++ b/drivers/dfu/dfu_mtd.c
@@ -10,7 +10,6 @@
#include <common.h>
#include <dfu.h>
#include <mtd.h>
-#include <jffs2/load_kernel.h>
#include <linux/err.h>
#include <linux/ctype.h>
@@ -275,7 +274,7 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char **argv, int a
{
char *s;
struct mtd_info *mtd;
- int ret, part;
+ int part;
mtd = get_mtd_device_nm(devstr);
if (IS_ERR_OR_NULL(mtd))
@@ -299,10 +298,9 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char **argv, int a
if (*s)
return -EINVAL;
} else if ((!strcmp(argv[0], "part")) || (!strcmp(argv[0], "partubi"))) {
- char mtd_id[32];
- struct mtd_device *mtd_dev;
- u8 part_num;
- struct part_info *pi;
+ struct mtd_info *partition;
+ int partnum = 0;
+ bool part_found = false;
if (argc != 2)
return -EINVAL;
@@ -313,19 +311,25 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char **argv, int a
if (*s)
return -EINVAL;
- sprintf(mtd_id, "%s,%d", devstr, part - 1);
- printf("using id '%s'\n", mtd_id);
+ /* register partitions with MTDIDS/MTDPARTS or OF fallback */
+ mtd_probe_devices();
- mtdparts_init();
-
- ret = find_dev_and_part(mtd_id, &mtd_dev, &part_num, &pi);
- if (ret != 0) {
- printf("Could not locate '%s'\n", mtd_id);
+ partnum = 0;
+ list_for_each_entry(partition, &mtd->partitions, node) {
+ partnum++;
+ if (partnum == part) {
+ part_found = true;
+ break;
+ }
+ }
+ if (!part_found) {
+ printf("No partition %d in %s\n", part, mtd->name);
return -1;
}
+ log_debug("partition %d:%s in %s\n", partnum, partition->name, mtd->name);
- dfu->data.mtd.start = pi->offset;
- dfu->data.mtd.size = pi->size;
+ dfu->data.mtd.start = partition->offset;
+ dfu->data.mtd.size = partition->size;
if (!strcmp(argv[0], "partubi"))
dfu->data.mtd.ubi = 1;
} else {