mirror of
https://xff.cz/git/u-boot/
synced 2025-09-30 23:11:32 +02:00
disk: Provide API to get partition by name for specific type
There is already existing function part_get_info_by_name(). But sometimes user is particularly interested in looking for only specific partition type. This patch implements such an API that provides partition searching by name for specified partition type. Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
15
disk/part.c
15
disk/part.c
@@ -21,6 +21,9 @@
|
|||||||
#define PRINTF(fmt,args...)
|
#define PRINTF(fmt,args...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Check all partition types */
|
||||||
|
#define PART_TYPE_ALL -1
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
#ifdef HAVE_BLOCK_DEVICE
|
#ifdef HAVE_BLOCK_DEVICE
|
||||||
@@ -626,8 +629,8 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
|
int part_get_info_by_name_type(struct blk_desc *dev_desc, const char *name,
|
||||||
disk_partition_t *info)
|
disk_partition_t *info, int part_type)
|
||||||
{
|
{
|
||||||
struct part_driver *first_drv =
|
struct part_driver *first_drv =
|
||||||
ll_entry_start(struct part_driver, part_driver);
|
ll_entry_start(struct part_driver, part_driver);
|
||||||
@@ -638,6 +641,8 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
|
|||||||
int ret;
|
int ret;
|
||||||
int i;
|
int i;
|
||||||
for (i = 1; i < part_drv->max_entries; i++) {
|
for (i = 1; i < part_drv->max_entries; i++) {
|
||||||
|
if (part_type >= 0 && part_type != part_drv->part_type)
|
||||||
|
break;
|
||||||
ret = part_drv->get_info(dev_desc, i, info);
|
ret = part_drv->get_info(dev_desc, i, info);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
/* no more entries in table */
|
/* no more entries in table */
|
||||||
@@ -652,6 +657,12 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
|
||||||
|
disk_partition_t *info)
|
||||||
|
{
|
||||||
|
return part_get_info_by_name_type(dev_desc, name, info, PART_TYPE_ALL);
|
||||||
|
}
|
||||||
|
|
||||||
void part_set_generic_name(const struct blk_desc *dev_desc,
|
void part_set_generic_name(const struct blk_desc *dev_desc,
|
||||||
int part_num, char *name)
|
int part_num, char *name)
|
||||||
{
|
{
|
||||||
|
@@ -173,6 +173,21 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
|
|||||||
struct blk_desc **dev_desc,
|
struct blk_desc **dev_desc,
|
||||||
disk_partition_t *info, int allow_whole_dev);
|
disk_partition_t *info, int allow_whole_dev);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* part_get_info_by_name_type() - Search for a partition by name
|
||||||
|
* for only specified partition type
|
||||||
|
*
|
||||||
|
* @param dev_desc - block device descriptor
|
||||||
|
* @param gpt_name - the specified table entry name
|
||||||
|
* @param info - returns the disk partition info
|
||||||
|
* @param part_type - only search in partitions of this type
|
||||||
|
*
|
||||||
|
* @return - the partition number on match (starting on 1), -1 on no match,
|
||||||
|
* otherwise error
|
||||||
|
*/
|
||||||
|
int part_get_info_by_name_type(struct blk_desc *dev_desc, const char *name,
|
||||||
|
disk_partition_t *info, int part_type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* part_get_info_by_name() - Search for a partition by name
|
* part_get_info_by_name() - Search for a partition by name
|
||||||
* among all available registered partitions
|
* among all available registered partitions
|
||||||
|
Reference in New Issue
Block a user