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