Skip to content

Commit 5724fa7

Browse files
committed
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 <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent f82d82e commit 5724fa7

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

drivers/mtd/nand/raw/nandsim.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -978,24 +978,6 @@ static int ns_read_error(unsigned int page_no)
978978
return 0;
979979
}
980980

981-
static void ns_free_lists(void)
982-
{
983-
struct list_head *pos, *n;
984-
list_for_each_safe(pos, n, &weak_blocks) {
985-
list_del(pos);
986-
kfree(list_entry(pos, struct weak_block, list));
987-
}
988-
list_for_each_safe(pos, n, &weak_pages) {
989-
list_del(pos);
990-
kfree(list_entry(pos, struct weak_page, list));
991-
}
992-
list_for_each_safe(pos, n, &grave_pages) {
993-
list_del(pos);
994-
kfree(list_entry(pos, struct grave_page, list));
995-
}
996-
kfree(erase_block_wear);
997-
}
998-
999981
static int ns_setup_wear_reporting(struct mtd_info *mtd)
1000982
{
1001983
size_t mem;
@@ -2443,12 +2425,30 @@ static void __exit ns_cleanup_module(void)
24432425
{
24442426
struct nand_chip *chip = mtd_to_nand(nsmtd);
24452427
struct nandsim *ns = nand_get_controller_data(chip);
2428+
struct list_head *pos, *n;
24462429

24472430
ns_debugfs_remove(ns);
2448-
ns_free(ns); /* Free nandsim private resources */
2449-
nand_release(chip); /* Unregister driver */
2450-
kfree(ns); /* Free other structures */
2451-
ns_free_lists();
2431+
WARN_ON(mtd_device_unregister(nsmtd));
2432+
ns_free(ns);
2433+
kfree(erase_block_wear);
2434+
nand_cleanup(chip);
2435+
2436+
list_for_each_safe(pos, n, &grave_pages) {
2437+
list_del(pos);
2438+
kfree(list_entry(pos, struct grave_page, list));
2439+
}
2440+
2441+
list_for_each_safe(pos, n, &weak_pages) {
2442+
list_del(pos);
2443+
kfree(list_entry(pos, struct weak_page, list));
2444+
}
2445+
2446+
list_for_each_safe(pos, n, &weak_blocks) {
2447+
list_del(pos);
2448+
kfree(list_entry(pos, struct weak_block, list));
2449+
}
2450+
2451+
kfree(ns);
24522452
}
24532453

24542454
module_exit(ns_cleanup_module);

0 commit comments

Comments
 (0)