[PATCH 1/4] mtd: ubi: Add API calls to create/remove volumes
Sascha Hauer
s.hauer at pengutronix.de
Thu Sep 22 00:49:23 PDT 2016
Currently we use a ioctl API to create/remove ubi volumes. This
means we always have to carry all function code for ubi volume
manipulation when the ioctl is compiled in.
This adds a function API to create/remove volumes so that the linker
can throw the unused code away later.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/mtd/ubi/barebox.c | 23 +++++++++++++++++++++++
include/linux/mtd/ubi.h | 3 +++
2 files changed, 26 insertions(+)
diff --git a/drivers/mtd/ubi/barebox.c b/drivers/mtd/ubi/barebox.c
index fc60aae..13c2a47 100644
--- a/drivers/mtd/ubi/barebox.c
+++ b/drivers/mtd/ubi/barebox.c
@@ -257,6 +257,29 @@ void ubi_volume_cdev_remove(struct ubi_volume *vol)
kfree(priv);
}
+int ubi_api_create_volume(int ubi_num, struct ubi_mkvol_req *req)
+{
+ struct ubi_device *ubi;
+ int ret;
+
+ ubi = ubi_get_device(ubi_num);
+ if (!ubi)
+ return -ENODEV;
+
+ if (!req->bytes)
+ req->bytes = (__s64)ubi->avail_pebs * ubi->leb_size;
+ ret = ubi_create_volume(ubi, req);
+
+ ubi_put_device(ubi);
+
+ return ret;
+}
+
+int ubi_api_remove_volume(struct ubi_volume_desc *desc, int no_vtbl)
+{
+ return ubi_remove_volume(desc, no_vtbl);
+}
+
static int ubi_cdev_ioctl(struct cdev *cdev, int cmd, void *buf)
{
struct ubi_volume_desc *desc;
diff --git a/include/linux/mtd/ubi.h b/include/linux/mtd/ubi.h
index 0614681..c72f95b 100644
--- a/include/linux/mtd/ubi.h
+++ b/include/linux/mtd/ubi.h
@@ -218,6 +218,9 @@ int ubi_is_mapped(struct ubi_volume_desc *desc, int lnum);
int ubi_sync(int ubi_num);
int ubi_flush(int ubi_num, int vol_id, int lnum);
+int ubi_api_create_volume(int ubi_num, struct ubi_mkvol_req *req);
+int ubi_api_remove_volume(struct ubi_volume_desc *desc, int no_vtbl);
+
/*
* This function is the same as the 'ubi_leb_read()' function, but it does not
* provide the checking capability.
--
2.8.1
More information about the barebox
mailing list