]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ti-u-boot/ti-u-boot.git/commitdiff
part: Support getting whole disk from part_get_info_by_dev_and_name_or_num
authorSean Anderson <sean.anderson@seco.com>
Fri, 5 Feb 2021 14:38:56 +0000 (09:38 -0500)
committerMarek Vasut <marex@denx.de>
Fri, 26 Feb 2021 14:30:55 +0000 (15:30 +0100)
This adds an option to part_get_info_by_dev_and_name_or_num to allow
callers to specify whether whole-disk partitions are fine.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
cmd/ab_select.c
disk/part.c
include/part.h

index 6298fcfb6044a9f45a31936fc7034f582f1432d7..3e46663d6ea543a59d9c01db2bc0f51a51a3cdcc 100644 (file)
@@ -22,7 +22,8 @@ static int do_ab_select(struct cmd_tbl *cmdtp, int flag, int argc,
 
        /* Lookup the "misc" partition from argv[2] and argv[3] */
        if (part_get_info_by_dev_and_name_or_num(argv[2], argv[3],
-                                                &dev_desc, &part_info) < 0) {
+                                                &dev_desc, &part_info,
+                                                false) < 0) {
                return CMD_RET_FAILURE;
        }
 
index 2a6b85e81b56f3216440da81ac7de3c5dc5c1ac8..03f283307f5a182ca55701e9241e56e9f154d8b1 100644 (file)
@@ -737,7 +737,8 @@ static int part_get_info_by_dev_and_name(const char *dev_iface,
 int part_get_info_by_dev_and_name_or_num(const char *dev_iface,
                                         const char *dev_part_str,
                                         struct blk_desc **dev_desc,
-                                        struct disk_partition *part_info)
+                                        struct disk_partition *part_info,
+                                        int allow_whole_dev)
 {
        int ret;
 
@@ -751,7 +752,7 @@ int part_get_info_by_dev_and_name_or_num(const char *dev_iface,
         * directly.
         */
        ret = blk_get_device_part_str(dev_iface, dev_part_str,
-                                     dev_desc, part_info, 1);
+                                     dev_desc, part_info, allow_whole_dev);
        if (ret < 0)
                printf("Couldn't find partition %s %s\n",
                       dev_iface, dev_part_str);
index 815515aa8094fd43063003da0a2cba8da0a01056..7f78271a9838c33cfd43f2ad3af2ae4ab5a870e2 100644 (file)
@@ -227,12 +227,16 @@ int part_get_info_by_name(struct blk_desc *dev_desc,
  * @param[in] dev_part_str Input partition description, like "0#misc" or "0:1"
  * @param[out] dev_desc        Place to store the device description pointer
  * @param[out] part_info Place to store the partition information
+ * @param[in] allow_whole_dev true to allow the user to select partition 0
+ *             (which means the whole device), false to require a valid
+ *             partition number >= 1
  * @return 0 on success, or a negative on error
  */
 int part_get_info_by_dev_and_name_or_num(const char *dev_iface,
                                         const char *dev_part_str,
                                         struct blk_desc **dev_desc,
-                                        struct disk_partition *part_info);
+                                        struct disk_partition *part_info,
+                                        int allow_whole_dev);
 
 /**
  * part_set_generic_name() - create generic partition like hda1 or sdb2