9
0
Fork 0

mtd: nand: remove automatically created bb devices

the bb devices which are created in add_mtd_device() must be removed
in del_mtd_device(). Also remove deletion of the bb devices in the
mtdparts-add environment file.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2015-02-06 08:46:58 +01:00
parent 99bed34278
commit 7649473f40
4 changed files with 19 additions and 9 deletions

View File

@ -30,9 +30,6 @@ if [ -z "${parts}" ]; then
fi
if [ -e /tmp/mtdparts/${device} ]; then
if [ -n "/dev/${device}.*.bb" ]; then
nand -d /dev/${device}.*.bb
fi
delpart /dev/${device}.*
fi

View File

@ -447,6 +447,8 @@ int del_mtd_device (struct mtd_info *mtd)
hook->del_mtd_device(mtd, &hook->priv);
devfs_remove(&mtd->cdev);
if (mtd->cdev_bb)
mtd_del_bb(mtd);
unregister_device(&mtd->class_dev);
free(mtd->param_size.value);
free(mtd->cdev.name);

View File

@ -307,6 +307,17 @@ err:
return ERR_PTR(ret);
}
void mtd_del_bb(struct mtd_info *mtd)
{
struct cdev *cdev = mtd->cdev_bb;
struct nand_bb *bb = container_of(cdev, struct nand_bb, cdev);
devfs_remove(&bb->cdev);
list_del_init(&bb->list);
free(bb->name);
free(bb);
}
/**
* Add a bad block aware device ontop of another (NAND) device
* @param[in] dev The device to add a partition on
@ -335,10 +346,7 @@ int dev_remove_bb_dev(const char *name)
list_for_each_entry_safe(bb, tmp, &bb_list, list) {
if (!strcmp(bb->cdev.name, name)) {
devfs_remove(&bb->cdev);
list_del_init(&bb->list);
free(bb->name);
free(bb);
mtd_del_bb(bb->mtd);
return 0;
}
}

View File

@ -1,4 +1,3 @@
#ifndef __NAND_H__
#define __NAND_H__
@ -8,6 +7,7 @@ struct nand_bb;
int dev_add_bb_dev(const char *filename, const char *name);
int dev_remove_bb_dev(const char *name);
struct cdev *mtd_add_bb(struct mtd_info *mtd, const char *name);
void mtd_del_bb(struct mtd_info *mtd);
#else
static inline int dev_add_bb_dev(const char *filename, const char *name) {
return 0;
@ -21,7 +21,10 @@ static inline struct cdev *mtd_add_bb(struct mtd_info *mtd, const char *name)
{
return NULL;
}
static inline void mtd_del_bb(struct mtd_info *mtd)
{
}
#endif
#endif /* __NAND_H__ */