Hi Joshua, On Wed, 28 Jun 2023 at 14:34, Joshua Watt <jpewhac...@gmail.com> wrote: > > On Mon, Jun 26, 2023 at 4:07 AM Simon Glass <s...@chromium.org> wrote: > > > > Hi Joshua, > > > > On Fri, 23 Jun 2023 at 21:01, Joshua Watt <jpewhac...@gmail.com> wrote: > > > > > > 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 <jpewhac...@gmail.com> > > > --- > > > disk/part.c | 38 +++++++++++++++++++++++++++++++------- > > > include/part.h | 2 ++ > > > 2 files changed, 33 insertions(+), 7 deletions(-) > > > > > > diff --git a/disk/part.c b/disk/part.c > > > index 35300df590..1f8c786ca5 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 */ > > > @@ -306,8 +319,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; > > > > > > @@ -320,7 +333,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); > > > @@ -340,6 +358,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) > > > { > > > diff --git a/include/part.h b/include/part.h > > > index be75c73549..f150c84206 100644 > > > --- a/include/part.h > > > +++ b/include/part.h > > > @@ -106,6 +106,8 @@ struct blk_desc *blk_get_dev(const char *ifname, int > > > dev); > > > struct blk_desc *mg_disk_get_dev(int dev); > > > > > > /* disk/part.c */ > > > +int part_get_info_by_type(struct blk_desc *dev_desc, int part, int > > > part_type, > > > + struct disk_partition *info); > > > > Please can you add a full comment? > > > > Also please add a test to test/dm/part.c for your new function[1] > > Any trick to getting the current test/dm/part.c tests to pass? When I > run them they fail with `** No device specified **` errors, which > doesn't give me hope that I can write tests that I could actually run > locally.
Yes you probably need to run the ''test_ut_dm_init_bootstd' test first. This pytest is run automatically if you run everything, but otherwise is not. It sets up the mmc1.img file. Regards, Simon