diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2016-09-22 09:37:14 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-09-22 09:39:55 +0200 |
commit | 85dccb92982450cacc0d7dd393f16778388582a6 (patch) | |
tree | 022479e6668502c314b748959069ac7ebabfaa20 | |
parent | d549e5d498bd3124cd490ea3cba3919b9779d181 (diff) | |
download | barebox-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>
-rw-r--r-- | drivers/mtd/ubi/barebox.c | 23 | ||||
-rw-r--r-- | include/linux/mtd/ubi.h | 3 |
2 files changed, 26 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; diff --git a/include/linux/mtd/ubi.h b/include/linux/mtd/ubi.h index 0614681d73..c72f95b327 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. |