aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/build.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/ubi/build.c')
-rw-r--r--drivers/mtd/ubi/build.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 65626c1c446d..6c3fb5ab20f5 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -953,10 +953,14 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
953 if (!ubi->peb_buf2) 953 if (!ubi->peb_buf2)
954 goto out_free; 954 goto out_free;
955 955
956 err = ubi_debugging_init_dev(ubi);
957 if (err)
958 goto out_free;
959
956 err = attach_by_scanning(ubi); 960 err = attach_by_scanning(ubi);
957 if (err) { 961 if (err) {
958 dbg_err("failed to attach by scanning, error %d", err); 962 dbg_err("failed to attach by scanning, error %d", err);
959 goto out_free; 963 goto out_debugging;
960 } 964 }
961 965
962 if (ubi->autoresize_vol_id != -1) { 966 if (ubi->autoresize_vol_id != -1) {
@@ -969,12 +973,16 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
969 if (err) 973 if (err)
970 goto out_detach; 974 goto out_detach;
971 975
976 err = ubi_debugfs_init_dev(ubi);
977 if (err)
978 goto out_uif;
979
972 ubi->bgt_thread = kthread_create(ubi_thread, ubi, ubi->bgt_name); 980 ubi->bgt_thread = kthread_create(ubi_thread, ubi, ubi->bgt_name);
973 if (IS_ERR(ubi->bgt_thread)) { 981 if (IS_ERR(ubi->bgt_thread)) {
974 err = PTR_ERR(ubi->bgt_thread); 982 err = PTR_ERR(ubi->bgt_thread);
975 ubi_err("cannot spawn \"%s\", error %d", ubi->bgt_name, 983 ubi_err("cannot spawn \"%s\", error %d", ubi->bgt_name,
976 err); 984 err);
977 goto out_uif; 985 goto out_debugfs;
978 } 986 }
979 987
980 ubi_msg("attached mtd%d to ubi%d", mtd->index, ubi_num); 988 ubi_msg("attached mtd%d to ubi%d", mtd->index, ubi_num);
@@ -1008,12 +1016,18 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
1008 ubi_notify_all(ubi, UBI_VOLUME_ADDED, NULL); 1016 ubi_notify_all(ubi, UBI_VOLUME_ADDED, NULL);
1009 return ubi_num; 1017 return ubi_num;
1010 1018
1019out_debugfs:
1020 ubi_debugfs_exit_dev(ubi);
1011out_uif: 1021out_uif:
1022 get_device(&ubi->dev);
1023 ubi_assert(ref);
1012 uif_close(ubi); 1024 uif_close(ubi);
1013out_detach: 1025out_detach:
1014 ubi_wl_close(ubi); 1026 ubi_wl_close(ubi);
1015 free_internal_volumes(ubi); 1027 free_internal_volumes(ubi);
1016 vfree(ubi->vtbl); 1028 vfree(ubi->vtbl);
1029out_debugging:
1030 ubi_debugging_exit_dev(ubi);
1017out_free: 1031out_free:
1018 vfree(ubi->peb_buf1); 1032 vfree(ubi->peb_buf1);
1019 vfree(ubi->peb_buf2); 1033 vfree(ubi->peb_buf2);
@@ -1080,11 +1094,13 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
1080 */ 1094 */
1081 get_device(&ubi->dev); 1095 get_device(&ubi->dev);
1082 1096
1097 ubi_debugfs_exit_dev(ubi);
1083 uif_close(ubi); 1098 uif_close(ubi);
1084 ubi_wl_close(ubi); 1099 ubi_wl_close(ubi);
1085 free_internal_volumes(ubi); 1100 free_internal_volumes(ubi);
1086 vfree(ubi->vtbl); 1101 vfree(ubi->vtbl);
1087 put_mtd_device(ubi->mtd); 1102 put_mtd_device(ubi->mtd);
1103 ubi_debugging_exit_dev(ubi);
1088 vfree(ubi->peb_buf1); 1104 vfree(ubi->peb_buf1);
1089 vfree(ubi->peb_buf2); 1105 vfree(ubi->peb_buf2);
1090 ubi_msg("mtd%d is detached from ubi%d", ubi->mtd->index, ubi->ubi_num); 1106 ubi_msg("mtd%d is detached from ubi%d", ubi->mtd->index, ubi->ubi_num);
@@ -1199,6 +1215,11 @@ static int __init ubi_init(void)
1199 if (!ubi_wl_entry_slab) 1215 if (!ubi_wl_entry_slab)
1200 goto out_dev_unreg; 1216 goto out_dev_unreg;
1201 1217
1218 err = ubi_debugfs_init();
1219 if (err)
1220 goto out_slab;
1221
1222
1202 /* Attach MTD devices */ 1223 /* Attach MTD devices */
1203 for (i = 0; i < mtd_devs; i++) { 1224 for (i = 0; i < mtd_devs; i++) {
1204 struct mtd_dev_param *p = &mtd_dev_param[i]; 1225 struct mtd_dev_param *p = &mtd_dev_param[i];
@@ -1247,6 +1268,8 @@ out_detach:
1247 ubi_detach_mtd_dev(ubi_devices[k]->ubi_num, 1); 1268 ubi_detach_mtd_dev(ubi_devices[k]->ubi_num, 1);
1248 mutex_unlock(&ubi_devices_mutex); 1269 mutex_unlock(&ubi_devices_mutex);
1249 } 1270 }
1271 ubi_debugfs_exit();
1272out_slab:
1250 kmem_cache_destroy(ubi_wl_entry_slab); 1273 kmem_cache_destroy(ubi_wl_entry_slab);
1251out_dev_unreg: 1274out_dev_unreg:
1252 misc_deregister(&ubi_ctrl_cdev); 1275 misc_deregister(&ubi_ctrl_cdev);
@@ -1270,6 +1293,7 @@ static void __exit ubi_exit(void)
1270 ubi_detach_mtd_dev(ubi_devices[i]->ubi_num, 1); 1293 ubi_detach_mtd_dev(ubi_devices[i]->ubi_num, 1);
1271 mutex_unlock(&ubi_devices_mutex); 1294 mutex_unlock(&ubi_devices_mutex);
1272 } 1295 }
1296 ubi_debugfs_exit();
1273 kmem_cache_destroy(ubi_wl_entry_slab); 1297 kmem_cache_destroy(ubi_wl_entry_slab);
1274 misc_deregister(&ubi_ctrl_cdev); 1298 misc_deregister(&ubi_ctrl_cdev);
1275 class_remove_file(ubi_class, &ubi_version); 1299 class_remove_file(ubi_class, &ubi_version);