summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorWeijie Gao <[email protected]>2026-05-20 16:27:38 +0800
committerHeiko Schocher <[email protected]>2026-07-08 11:34:12 +0200
commit14fe02ac5e5260a0dad58804cc6c922827bf9d7e (patch)
treecb742f2f328a5745b1bf9993c22f250574283bae /cmd
parent75d8b453ab2fd9f736844a25c3e6628668d9562f (diff)
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_remove_vol is renamed to __ubi_remove_vol to allow the new ubi_remove_vol() being used as a wrapper for __ubi_remove_vol() with volume name. Also, comments are added for all exported functions. Reviewed-by: Simon Glass <[email protected]> Signed-off-by: Weijie Gao <[email protected]>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/ubi.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/cmd/ubi.c b/cmd/ubi.c
index 04616d49fac..eea863ac303 100644
--- 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)
{
struct ubi_mkvol_req req;
int err;
@@ -246,7 +246,7 @@ static int ubi_create_vol(const char *volume, int64_t size, bool dynamic,
return ubi_create_volume(ubi, &req);
}
-static struct ubi_volume *ubi_find_volume(const char *volume)
+struct ubi_volume *ubi_find_volume(const char *volume)
{
struct ubi_volume *vol;
int i;
@@ -270,7 +270,7 @@ static struct ubi_volume *ubi_require_volume(const char *volume)
return vol;
}
-static int ubi_remove_vol(struct ubi_volume *vol)
+static int __ubi_remove_vol(struct ubi_volume *vol)
{
int err, reserved_pebs, i;
@@ -315,6 +315,17 @@ out_err:
return err;
}
+int ubi_remove_vol(const char *volume)
+{
+ struct ubi_volume *vol;
+
+ vol = ubi_require_volume(volume);
+ if (!vol)
+ return -ENODEV;
+
+ return __ubi_remove_vol(vol);
+}
+
static int ubi_rename_vol(const char *oldname, const char *newname)
{
struct ubi_volume *vol;
@@ -632,7 +643,7 @@ static int ubi_set_skip_check(const char *volume, bool skip_check)
return ubi_change_vtbl_record(ubi, vol->vol_id, &vtbl_rec);
}
-static int ubi_detach(void)
+int ubi_detach(void)
{
#ifdef CONFIG_CMD_UBIFS
/*
@@ -828,7 +839,7 @@ static int do_ubi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
vol_id = vol->vol_id;
- ret = ubi_remove_vol(vol);
+ ret = __ubi_remove_vol(vol);
if (ret)
return CMD_RET_FAILURE;