summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-09-22 09:37:14 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-09-22 09:39:55 +0200
commit85dccb92982450cacc0d7dd393f16778388582a6 (patch)
tree022479e6668502c314b748959069ac7ebabfaa20 /drivers
parentd549e5d498bd3124cd490ea3cba3919b9779d181 (diff)
downloadbarebox-85dccb92982450cacc0d7dd393f16778388582a6.tar.gz
barebox-85dccb92982450cacc0d7dd393f16778388582a6.tar.xz
mtd: ubi: Add API calls to create/remove volumes
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@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/ubi/barebox.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/barebox.c b/drivers/mtd/ubi/barebox.c
index fc60aaeec5..13c2a47afc 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;