[PATCH 4/9] part: Support getting whole disk from part_get_info_by_dev_and_name_or_num

Sean Anderson sean.anderson at seco.com
Thu Jan 7 15:12:03 CET 2021



On 1/7/21 7:35 AM, Simon Glass wrote:
 > On Thu, 31 Dec 2020 at 15:49, Sean Anderson <sean.anderson at seco.com> 
wrote:
 >>
 >> 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 at seco.com>
 >> ---
 >>
 >>   cmd/ab_select.c | 3 ++-
 >>   disk/part.c     | 5 +++--
 >>   include/part.h  | 6 +++++-
 >>   3 files changed, 10 insertions(+), 4 deletions(-)
 >>
 >
 > Reviewed-by: Simon Glass <sjg at chromium.org>
 >
 >> diff --git a/cmd/ab_select.c b/cmd/ab_select.c
 >> index 6298fcfb60..3e46663d6e 100644
 >> --- a/cmd/ab_select.c
 >> +++ b/cmd/ab_select.c
 >> @@ -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;
 >>          }
 >>
 >> diff --git a/disk/part.c b/disk/part.c
 >> index 5e354e256f..39c6b00a59 100644
 >> --- a/disk/part.c
 >> +++ b/disk/part.c
 >> @@ -736,7 +736,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)
 >
 > bool?

It's int to match the allow_whole_dev argument of
blk_get_device_part_str.

 >
 >>   {
 >>          int ret;
 >>
 >> @@ -750,7 +751,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);
 >> diff --git a/include/part.h b/include/part.h
 >> index 55be724d20..778cb36199 100644
 >> --- a/include/part.h
 >> +++ b/include/part.h
 >> @@ -226,12 +226,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
 >> --
 >> 2.25.1
 >>
 >
 > Regards,
 > Simon
 >


More information about the U-Boot mailing list