@@ -978,24 +978,6 @@ static int ns_read_error(unsigned int page_no)
978
978
return 0 ;
979
979
}
980
980
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
-
999
981
static int ns_setup_wear_reporting (struct mtd_info * mtd )
1000
982
{
1001
983
size_t mem ;
@@ -2443,12 +2425,30 @@ static void __exit ns_cleanup_module(void)
2443
2425
{
2444
2426
struct nand_chip * chip = mtd_to_nand (nsmtd );
2445
2427
struct nandsim * ns = nand_get_controller_data (chip );
2428
+ struct list_head * pos , * n ;
2446
2429
2447
2430
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 );
2452
2452
}
2453
2453
2454
2454
module_exit (ns_cleanup_module );
0 commit comments