summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdoob.c
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@googlemail.com>2012-09-03 07:58:01 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-09-03 11:06:01 +0200
commit83f311a9bb4dd79c2e8705cf5bdf095e3f624442 (patch)
tree602ef92bc945998e31e947fdb48d97636c669b38 /drivers/mtd/mtdoob.c
parent06e5a6a5cae8a9bdc6a7e6ab5aba48dd8a9d0832 (diff)
downloadbarebox-83f311a9bb4dd79c2e8705cf5bdf095e3f624442.tar.gz
barebox-83f311a9bb4dd79c2e8705cf5bdf095e3f624442.tar.xz
mtd: add private data to mtddev-hook
The mtdoob and mtdraw device don't clean up correctly. Added a private data element to hold allocated memory. Fix remove of mtdoob and mtdraw device. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mtd/mtdoob.c')
-rw-r--r--drivers/mtd/mtdoob.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/mtd/mtdoob.c b/drivers/mtd/mtdoob.c
index e4dd1a00c8..c7bf40cef8 100644
--- a/drivers/mtd/mtdoob.c
+++ b/drivers/mtd/mtdoob.c
@@ -69,7 +69,7 @@ static struct file_operations mtd_ops_oob = {
.lseek = dev_lseek_default,
};
-static int add_mtdoob_device(struct mtd_info *mtd, char *devname)
+static int add_mtdoob_device(struct mtd_info *mtd, char *devname, void **priv)
{
struct mtdoob *mtdoob;
@@ -80,13 +80,26 @@ static int add_mtdoob_device(struct mtd_info *mtd, char *devname)
mtdoob->cdev.priv = mtdoob;
mtdoob->cdev.dev = &mtd->class_dev;
mtdoob->mtd = mtd;
+ *priv = mtdoob;
devfs_create(&mtdoob->cdev);
return 0;
}
+static int del_mtdoob_device(struct mtd_info *mtd, void **priv)
+{
+ struct mtdoob *mtdoob;
+
+ mtdoob = *priv;
+ devfs_remove(&mtdoob->cdev);
+ free(mtdoob);
+
+ return 0;
+}
+
static struct mtddev_hook mtdoob_hook = {
.add_mtd_device = add_mtdoob_device,
+ .del_mtd_device = del_mtdoob_device,
};
static int __init register_mtdoob(void)