From 1e33e3cb7c543a31ca9ba7d940328073e397b0fb Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Mon, 27 Apr 2020 17:05:50 +0800 Subject: [PATCH] common: spl: ab: update new function to support ab system Add spl_ab_append_part_slot() Delete spl_get_partitions_sector() Signed-off-by: Jason Zhu Change-Id: I116d6d708604762203974dc66a39be1a0e7b6bbe --- common/spl/spl_ab.c | 30 ++++++++++++++---------------- include/spl_ab.h | 13 ++++++++----- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/common/spl/spl_ab.c b/common/spl/spl_ab.c index 428e44cd81..2c6f71f9d2 100644 --- a/common/spl/spl_ab.c +++ b/common/spl/spl_ab.c @@ -242,26 +242,24 @@ out: return 0; } -int spl_get_partitions_sector(struct blk_desc *dev_desc, char *partition, - u32 *sectors) +int spl_ab_append_part_slot(struct blk_desc *dev_desc, + const char *part_name, + char *new_name) { - disk_partition_t part_info; - char part[10] = {0}; - char slot[3] = {0}; + char slot_suffix[3] = {0}; - if (!partition || !sectors) - return -EFAULT; + if (!strcmp(part_name, "misc")) { + strcat(new_name, part_name); + return 0; + } - spl_get_current_slot(dev_desc, "misc", slot); - if (strlen(partition) > 8) - return -ENOMEM; + if (spl_get_current_slot(dev_desc, "misc", slot_suffix)) { + printf("%s: failed to get slot suffix !\n", __func__); + return -1; + } - strcat(part, partition); - strcat(part, slot); - if (part_get_info_by_name(dev_desc, part, &part_info) < 0) - return -ENODEV; - - *sectors = part_info.start; + strcpy(new_name, part_name); + strcat(new_name, slot_suffix); return 0; } diff --git a/include/spl_ab.h b/include/spl_ab.h index b5be70f5bf..fc854787cd 100644 --- a/include/spl_ab.h +++ b/include/spl_ab.h @@ -24,13 +24,16 @@ int spl_get_current_slot(struct blk_desc *dev_desc, char *partition, char *slot); /* - * spl_get_partitions_sector + * spl_ab_append_part_slot * * @dev_desc: block description - * @partition: partition name - * @sectors: firmware load address + * @part_name: partition name + * @new_name: append the slot suffix + * + * return: 0 success, others fail. */ -int spl_get_partitions_sector(struct blk_desc *dev_desc, char *partition, - u32 *sectors); +int spl_ab_append_part_slot(struct blk_desc *dev_desc, + const char *part_name, + char *new_name); #endif