diff options
author | Joshua Watt | 2023-07-03 08:39:54 -0500 |
---|---|---|
committer | Tom Rini | 2023-07-17 15:39:55 -0400 |
commit | 387f8be55b5091c4ed39221ef6a38ea7099d0a36 (patch) | |
tree | 90111de1210771b235dc8e98106a94125442157c /disk | |
parent | 44ef2855e1ec5964c02cadd2cc3423f87524830b (diff) |
disk: part: Add API to get partitions with specific driver
Adds part_driver_get_type() API which can be used to force a specific
driver to be used when getting partition information instead of relying
on auto detection.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'disk')
-rw-r--r-- | disk/part.c | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/disk/part.c b/disk/part.c index 1d2117ab71e..0a03b8213d8 100644 --- a/disk/part.c +++ b/disk/part.c @@ -26,6 +26,22 @@ /* Check all partition types */ #define PART_TYPE_ALL -1 +static struct part_driver *part_driver_get_type(int part_type) +{ + struct part_driver *drv = + ll_entry_start(struct part_driver, part_driver); + const int n_ents = ll_entry_count(struct part_driver, part_driver); + struct part_driver *entry; + + for (entry = drv; entry != drv + n_ents; entry++) { + if (part_type == entry->part_type) + return entry; + } + + /* Not found */ + return NULL; +} + static struct part_driver *part_driver_lookup_type(struct blk_desc *dev_desc) { struct part_driver *drv = @@ -44,10 +60,7 @@ static struct part_driver *part_driver_lookup_type(struct blk_desc *dev_desc) } } } else { - for (entry = drv; entry != drv + n_ents; entry++) { - if (dev_desc->part_type == entry->part_type) - return entry; - } + return part_driver_get_type(dev_desc->part_type); } /* Not found */ @@ -322,8 +335,8 @@ void part_print(struct blk_desc *dev_desc) drv->print(dev_desc); } -int part_get_info(struct blk_desc *dev_desc, int part, - struct disk_partition *info) +int part_get_info_by_type(struct blk_desc *dev_desc, int part, int part_type, + struct disk_partition *info) { struct part_driver *drv; @@ -336,7 +349,12 @@ int part_get_info(struct blk_desc *dev_desc, int part, info->type_guid[0] = 0; #endif - drv = part_driver_lookup_type(dev_desc); + if (part_type == PART_TYPE_UNKNOWN) { + drv = part_driver_lookup_type(dev_desc); + } else { + drv = part_driver_get_type(part_type); + } + if (!drv) { debug("## Unknown partition table type %x\n", dev_desc->part_type); @@ -356,6 +374,12 @@ int part_get_info(struct blk_desc *dev_desc, int part, return -ENOENT; } +int part_get_info(struct blk_desc *dev_desc, int part, + struct disk_partition *info) +{ + return part_get_info_by_type(dev_desc, part, PART_TYPE_UNKNOWN, info); +} + int part_get_info_whole_disk(struct blk_desc *dev_desc, struct disk_partition *info) { |