From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 4/8] mtd: ubi: Add support for opening a volume by cdev
Date: Tue, 6 Aug 2013 15:07:04 +0200 [thread overview]
Message-ID: <1375794428-29577-5-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1375794428-29577-1-git-send-email-s.hauer@pengutronix.de>
Needed by ubifs support.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mtd/ubi/cdev.c | 6 ++++++
drivers/mtd/ubi/kapi.c | 17 +++++++++++++++++
drivers/mtd/ubi/ubi.h | 2 ++
include/linux/mtd/ubi.h | 1 +
4 files changed, 26 insertions(+)
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 3907673..129f2e2 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -5,6 +5,8 @@
#include "ubi-barebox.h"
#include "ubi.h"
+LIST_HEAD(ubi_volumes_list);
+
struct ubi_volume_cdev_priv {
struct ubi_device *ubi;
struct ubi_volume *vol;
@@ -184,6 +186,8 @@ int ubi_volume_cdev_add(struct ubi_device *ubi, struct ubi_volume *vol)
free(cdev->name);
}
+ list_add_tail(&vol->list, &ubi_volumes_list);
+
return 0;
}
@@ -192,6 +196,8 @@ void ubi_volume_cdev_remove(struct ubi_volume *vol)
struct cdev *cdev = &vol->cdev;
struct ubi_volume_cdev_priv *priv = cdev->priv;
+ list_del(&vol->list);
+
devfs_remove(cdev);
kfree(cdev->name);
kfree(priv);
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index 23ac234..31571ad 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -265,6 +265,23 @@ struct ubi_volume_desc *ubi_open_volume_nm(int ubi_num, const char *name,
}
EXPORT_SYMBOL_GPL(ubi_open_volume_nm);
+extern struct list_head ubi_volumes_list;
+
+struct ubi_volume_desc *ubi_open_volume_cdev(struct cdev *cdev, int mode)
+{
+ struct ubi_volume *vol;
+
+ list_for_each_entry(vol, &ubi_volumes_list, list) {
+ if (cdev == &vol->cdev)
+ goto found;
+ }
+
+ return ERR_PTR(-ENOENT);
+
+found:
+ return ubi_open_volume(vol->ubi->ubi_num, vol->vol_id, mode);
+}
+
/**
* ubi_close_volume - close UBI volume.
* @desc: volume descriptor
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 11877a3..aa2cf02 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -322,6 +322,8 @@ struct ubi_volume {
unsigned int updating:1;
unsigned int changing_leb:1;
unsigned int direct_writes:1;
+
+ struct list_head list;
};
/**
diff --git a/include/linux/mtd/ubi.h b/include/linux/mtd/ubi.h
index b3288d1..274ec4e 100644
--- a/include/linux/mtd/ubi.h
+++ b/include/linux/mtd/ubi.h
@@ -200,6 +200,7 @@ void ubi_get_volume_info(struct ubi_volume_desc *desc,
struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode);
struct ubi_volume_desc *ubi_open_volume_nm(int ubi_num, const char *name,
int mode);
+struct ubi_volume_desc *ubi_open_volume_cdev(struct cdev *cdev, int mode);
struct ubi_volume_desc *ubi_open_volume_path(const char *pathname, int mode);
void ubi_close_volume(struct ubi_volume_desc *desc);
--
1.8.4.rc1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-08-06 13:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-06 13:07 [PATCH] UBIFS support Sascha Hauer
2013-08-06 13:07 ` [PATCH 1/8] mtd: ubi: add missing prototype for ubi_volume_notify Sascha Hauer
2013-08-06 13:07 ` [PATCH 2/8] mtd: ubi: add ubi info functions Sascha Hauer
2013-08-06 13:07 ` [PATCH 3/8] filetype: Add ubifs detection Sascha Hauer
2013-08-06 13:07 ` Sascha Hauer [this message]
2013-08-06 13:07 ` [PATCH 5/8] move print_hex_dump function to include/common.h Sascha Hauer
2013-08-06 13:07 ` [PATCH 6/8] extend barebox wrapper header Sascha Hauer
2013-08-06 13:07 ` [PATCH 7/8] Add deflate_decompress function Sascha Hauer
2013-08-06 13:07 ` [PATCH 8/8] fs: Add ubifs support Sascha Hauer
2013-08-06 18:16 ` Alexander Aring
2013-08-06 19:50 ` Sascha Hauer
2013-08-06 23:50 ` Alexander Aring
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=1375794428-29577-5-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