[PATCH v4 08/10] cmd: ubi: export more APIs to public
Simon Glass
sjg at chromium.org
Fri May 15 14:58:01 CEST 2026
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.
> 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.
Regards,
Simon
More information about the U-Boot
mailing list