[PATCH v4 08/10] cmd: ubi: export more APIs to public
Weijie Gao
weijie.gao at mediatek.com
Tue May 19 11:07:31 CEST 2026
On Fri, 2026-05-15 at 06:58 -0600, Simon Glass wrote:
> Hi Weijie,
>
> On 2026-05-13T08:02:45, Weijie Gao <weijie.gao at mediatek.com> wrote:
> > cmd: ubi: export more APIs to public
> >
> > Export the following functions to public:
> >
> > - ubi_detach(): this is paired with ubi_part(). One may call this
> > function
> > to completely clean up the ubi subsystem after using ubi_part().
> >
> > - ubi_{create,find,remove}_vol: this is a set of functions for
> > volume
> > management.
> >
> > The original ubi_create_vol is renamed to __ubi_create_vol to allow
> > the new
> > ubi_create_vol() being used as a wrapper for __ubi_create_vol()
> > with volume
> > name.
> >
> > Also, comments are added for all exported functions.
> >
> > Signed-off-by: Weijie Gao <weijie.gao at mediatek.com>
> >
> > cmd/ubi.c | 23 ++++++++++----
> > include/ubi_uboot.h | 91
> > +++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 2 files changed, 108 insertions(+), 6 deletions(-)
>
> Reviewed-by: Simon Glass <sjg at chromium.org>
>
> > diff --git a/cmd/ubi.c b/cmd/ubi.c
> > @@ -213,8 +213,8 @@ bad:
> > return err;
> > }
> >
> > -static int ubi_create_vol(const char *volume, int64_t size, bool
> > dynamic,
> > - int vol_id, bool skipcheck)
> > +int ubi_create_vol(const char *volume, int64_t size, bool dynamic,
> > int vol_id,
> > + bool skipcheck)
>
> The commit message is now out of date - it says ubi_create_vol() is
> renamed to __ubi_create_vol() and wrapped.
This is my mistake. They should be ubi_remove_vol()/__ubi_remove_vol()
>
> > diff --git a/include/ubi_uboot.h b/include/ubi_uboot.h
> > @@ -47,11 +47,102 @@
> > + * ubi_part() - attach UBI to MTD partition
> > + * @part_name: name of the MTD partition to attach
> > + * @vid_header_offset: VID header offset (string)
> > + *
> > + * This function detaches any existing UBI device, then probes for
> > the
> > + * specified MTD partition, and then scans it to initialize UBI.
> > + *
> > + * @vid_header_offset is optional and is usually set to NULL.
> > + *
> > + * Return: 0 on success, 1 if partition not found, or -ve on
> > error.
> > + */
> > int ubi_part(const char *part_name, const char
> > *vid_header_offset);
>
> Just to check, where does the '1 if partition not found' come from?
> My
> reading of ubi_dev_scan() / do_ubi() is that a missing partition
> surfaces as a negative errno. If there is no path that returns +1,
> please drop that clause.
Before changing all return value to negative, this function does return
1 after printing "Error, no volume name passed". Now this value is
changed to -ENODEV. I'll update this.
>
> Regards,
> Simon
More information about the U-Boot
mailing list