aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrice Chotard <patrice.chotard@foss.st.com>2023-06-08 17:16:40 +0200
committerPatrice Chotard <patrice.chotard@foss.st.com>2023-06-16 11:01:16 +0200
commita142a1dd908073f85f5324dfb2dba92d25c86891 (patch)
tree3db8392db5b961b61a73d8f5e611233d766893cc
parent28d3439f1b343f1299c8e92a673ceca2d9296baa (diff)
downloadu-boot-a142a1dd908073f85f5324dfb2dba92d25c86891.zip
u-boot-a142a1dd908073f85f5324dfb2dba92d25c86891.tar.gz
u-boot-a142a1dd908073f85f5324dfb2dba92d25c86891.tar.bz2
stm32mp: stm32prog: Remove usage of "mtdparts" function
Motivation for this patch is to remove usage of function define in cmd/mtdparts.c interface, based on env variables mtdids and mtdparts: mtdparts_init() and find_dev_and_part(). See commit 938db6fe5da3 ("cmd: mtdparts: describe as legacy") Now, all MTD devices are populated with their partition's information found in DT, accessible in MTD devices. Use these information to find the wanted partitions, no more need of find_dev_and_part() usage. Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
-rw-r--r--arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index 6f3641c..241ad40 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -208,11 +208,6 @@ static int optee_ta_invoke(struct stm32prog_data *data, int cmd, int type,
return rc;
}
-/* partition handling routines : CONFIG_CMD_MTDPARTS */
-int mtdparts_init(void);
-int find_dev_and_part(const char *id, struct mtd_device **dev,
- u8 *part_num, struct part_info **part);
-
char *stm32prog_get_error(struct stm32prog_data *data)
{
static const char error_msg[] = "Unspecified";
@@ -741,6 +736,7 @@ static int init_device(struct stm32prog_data *data,
struct mmc *mmc = NULL;
struct blk_desc *block_dev = NULL;
struct mtd_info *mtd = NULL;
+ struct mtd_info *partition;
char mtd_id[16];
int part_id;
int ret;
@@ -749,6 +745,7 @@ static int init_device(struct stm32prog_data *data,
u64 part_addr, part_size;
bool part_found;
const char *part_name;
+ u8 i;
switch (dev->target) {
case STM32PROG_MMC:
@@ -793,10 +790,11 @@ static int init_device(struct stm32prog_data *data,
stm32prog_err("unknown device type = %d", dev->target);
return -ENODEV;
}
+ /* register partitions with MTDIDS/MTDPARTS or OF fallback */
+ mtd_probe_devices();
get_mtd_by_target(mtd_id, dev->target, dev->dev_id);
log_debug("%s\n", mtd_id);
- mtdparts_init();
mtd = get_mtd_device_nm(mtd_id);
if (IS_ERR(mtd)) {
stm32prog_err("MTD device %s not found", mtd_id);
@@ -943,25 +941,23 @@ static int init_device(struct stm32prog_data *data,
}
if (IS_ENABLED(CONFIG_MTD) && mtd) {
- char mtd_part_id[32];
- struct part_info *mtd_part;
- struct mtd_device *mtd_dev;
- u8 part_num;
-
- sprintf(mtd_part_id, "%s,%d", mtd_id,
- part->part_id - 1);
- ret = find_dev_and_part(mtd_part_id, &mtd_dev,
- &part_num, &mtd_part);
- if (ret != 0) {
- stm32prog_err("%s (0x%x): Invalid MTD partition %s",
- part->name, part->id,
- mtd_part_id);
+ i = 0;
+ list_for_each_entry(partition, &mtd->partitions, node) {
+ if ((part->part_id - 1) == i) {
+ part_found = true;
+ break;
+ }
+ i++;
+ }
+ if (part_found) {
+ part_addr = partition->offset;
+ part_size = partition->size;
+ part_name = partition->name;
+ } else {
+ stm32prog_err("%s (0x%x):Couldn't find part %d on device mtd %s",
+ part->name, part->id, part->part_id, mtd_id);
return -ENODEV;
}
- part_addr = mtd_part->offset;
- part_size = mtd_part->size;
- part_name = mtd_part->name;
- part_found = true;
}
/* no partition for this device */