From f880d7bc875bc4165a9de8ad81ecf1ccb8307af7 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Fri, 8 Apr 2011 11:32:44 +0200 Subject: nand bb: add proper bb remove function The old way happily removed cdev entries which were no bb dev at all. Fix this by checking if the given device actually is a bb device. Signed-off-by: Sascha Hauer --- drivers/mtd/nand/nand-bb.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'drivers/mtd/nand/nand-bb.c') diff --git a/drivers/mtd/nand/nand-bb.c b/drivers/mtd/nand/nand-bb.c index d71a2b0c6d..dbfb8e38b3 100644 --- a/drivers/mtd/nand/nand-bb.c +++ b/drivers/mtd/nand/nand-bb.c @@ -31,6 +31,7 @@ #include #include #include +#include struct nand_bb { char cdevname[MAX_DRIVER_NAME]; @@ -47,6 +48,8 @@ struct nand_bb { void *writebuf; struct cdev cdev; + + struct list_head list; }; static ssize_t nand_bb_read(struct cdev *cdev, void *buf, size_t count, @@ -218,6 +221,8 @@ static struct file_operations nand_bb_ops = { #endif }; +static LIST_HEAD(bb_list); + /** * Add a bad block aware device ontop of another (NAND) device * @param[in] dev The device to add a partition on @@ -258,6 +263,8 @@ int dev_add_bb_dev(char *path, const char *name) if (ret) goto out4; + list_add_tail(&bb->list, &bb_list); + return 0; out4: @@ -267,3 +274,18 @@ out1: return ret; } +int dev_remove_bb_dev(const char *name) +{ + struct nand_bb *bb; + + list_for_each_entry(bb, &bb_list, list) { + if (!strcmp(bb->cdev.name, name)) { + devfs_remove(&bb->cdev); + cdev_close(bb->cdev_parent); + free(bb); + return 0; + } + } + + return -ENODEV; +} -- cgit v1.2.3