mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 1/4] mtd: ubi: Add API calls to create/remove volumes
Date: Thu, 22 Sep 2016 09:49:23 +0200	[thread overview]
Message-ID: <1474530566-23625-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1474530566-23625-1-git-send-email-s.hauer@pengutronix.de>

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>
---
 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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2016-09-22  7:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-22  7:49 Add and use function API for UBI Sascha Hauer
2016-09-22  7:49 ` Sascha Hauer [this message]
2016-09-22  7:49 ` [PATCH 2/4] mtd: ubi: introduce barebox specific ioctl to get ubi_num Sascha Hauer
2016-09-22  7:49 ` [PATCH 3/4] mtd: ubi: commands: use function API to access ubi volumes Sascha Hauer
2016-09-22  7:49 ` [PATCH 4/4] mtd: ubi: remove now unused ioctls Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1474530566-23625-2-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox