aboutsummaryrefslogtreecommitdiffstats
path: root/disk
diff options
context:
space:
mode:
authorSam Protsenko2017-09-21 17:51:58 -0500
committerTom Rini2017-10-06 10:28:17 -0500
commit30789095566a6f4c62430f613f450acf8d5162e5 (patch)
tree638ea729a038272db9e29915b866168b5653ad9c /disk
parent19d141a0f90c640a8d5ed699745cbc8169918945 (diff)
downloadu-boot-30789095566a6f4c62430f613f450acf8d5162e5.tar.gz
u-boot-30789095566a6f4c62430f613f450acf8d5162e5.tar.xz
u-boot-30789095566a6f4c62430f613f450acf8d5162e5.zip
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>
Diffstat (limited to 'disk')
-rw-r--r--disk/part.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/disk/part.c b/disk/part.c
index aa9183d696..66b8101f98 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -21,6 +21,9 @@
21#define PRINTF(fmt,args...) 21#define PRINTF(fmt,args...)
22#endif 22#endif
23 23
24/* Check all partition types */
25#define PART_TYPE_ALL -1
26
24DECLARE_GLOBAL_DATA_PTR; 27DECLARE_GLOBAL_DATA_PTR;
25 28
26#ifdef HAVE_BLOCK_DEVICE 29#ifdef HAVE_BLOCK_DEVICE
@@ -626,8 +629,8 @@ cleanup:
626 return ret; 629 return ret;
627} 630}
628 631
629int part_get_info_by_name(struct blk_desc *dev_desc, const char *name, 632int part_get_info_by_name_type(struct blk_desc *dev_desc, const char *name,
630 disk_partition_t *info) 633 disk_partition_t *info, int part_type)
631{ 634{
632 struct part_driver *first_drv = 635 struct part_driver *first_drv =
633 ll_entry_start(struct part_driver, part_driver); 636 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,
638 int ret; 641 int ret;
639 int i; 642 int i;
640 for (i = 1; i < part_drv->max_entries; i++) { 643 for (i = 1; i < part_drv->max_entries; i++) {
644 if (part_type >= 0 && part_type != part_drv->part_type)
645 break;
641 ret = part_drv->get_info(dev_desc, i, info); 646 ret = part_drv->get_info(dev_desc, i, info);
642 if (ret != 0) { 647 if (ret != 0) {
643 /* no more entries in table */ 648 /* no more entries in table */
@@ -652,6 +657,12 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
652 return -1; 657 return -1;
653} 658}
654 659
660int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
661 disk_partition_t *info)
662{
663 return part_get_info_by_name_type(dev_desc, name, info, PART_TYPE_ALL);
664}
665
655void part_set_generic_name(const struct blk_desc *dev_desc, 666void part_set_generic_name(const struct blk_desc *dev_desc,
656 int part_num, char *name) 667 int part_num, char *name)
657{ 668{