diff options
author | Miquel Raynal <miquel.raynal@bootlin.com> | 2020-05-25 10:58:51 +0200 |
---|---|---|
committer | Miquel Raynal <miquel.raynal@bootlin.com> | 2020-05-31 10:53:40 +0200 |
commit | 5724fa7f2e25a0f355063ba9271529fa00c32206 (patch) | |
tree | 927f01698bc4dde9b2aa995b621191b9688d51d7 /drivers | |
parent | f82d82e202fce7d461c2a6bdb55feaf28448a075 (diff) | |
download | linux-stable-5724fa7f2e25a0f355063ba9271529fa00c32206.tar.gz linux-stable-5724fa7f2e25a0f355063ba9271529fa00c32206.tar.bz2 linux-stable-5724fa7f2e25a0f355063ba9271529fa00c32206.zip |
mtd: rawnand: nandsim: Reorganize ns_cleanup_module()
Reorganize ns_cleanup_module() to fit the reworked exit path of
ns_init_module().
There is no need for a ns_free_lists() function anymore, so drop it.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-18-miquel.raynal@bootlin.com
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/nand/raw/nandsim.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c index 7076acfbe0f4..0a5cb77966cc 100644 --- a/drivers/mtd/nand/raw/nandsim.c +++ b/drivers/mtd/nand/raw/nandsim.c @@ -978,24 +978,6 @@ static int ns_read_error(unsigned int page_no) return 0; } -static void ns_free_lists(void) -{ - struct list_head *pos, *n; - list_for_each_safe(pos, n, &weak_blocks) { - list_del(pos); - kfree(list_entry(pos, struct weak_block, list)); - } - list_for_each_safe(pos, n, &weak_pages) { - list_del(pos); - kfree(list_entry(pos, struct weak_page, list)); - } - list_for_each_safe(pos, n, &grave_pages) { - list_del(pos); - kfree(list_entry(pos, struct grave_page, list)); - } - kfree(erase_block_wear); -} - static int ns_setup_wear_reporting(struct mtd_info *mtd) { size_t mem; @@ -2443,12 +2425,30 @@ static void __exit ns_cleanup_module(void) { struct nand_chip *chip = mtd_to_nand(nsmtd); struct nandsim *ns = nand_get_controller_data(chip); + struct list_head *pos, *n; ns_debugfs_remove(ns); - ns_free(ns); /* Free nandsim private resources */ - nand_release(chip); /* Unregister driver */ - kfree(ns); /* Free other structures */ - ns_free_lists(); + WARN_ON(mtd_device_unregister(nsmtd)); + ns_free(ns); + kfree(erase_block_wear); + nand_cleanup(chip); + + list_for_each_safe(pos, n, &grave_pages) { + list_del(pos); + kfree(list_entry(pos, struct grave_page, list)); + } + + list_for_each_safe(pos, n, &weak_pages) { + list_del(pos); + kfree(list_entry(pos, struct weak_page, list)); + } + + list_for_each_safe(pos, n, &weak_blocks) { + list_del(pos); + kfree(list_entry(pos, struct weak_block, list)); + } + + kfree(ns); } module_exit(ns_cleanup_module); |