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.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 65626c1c446d..6d0d48395d8c 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,16 @@ 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:
1012 uif_close(ubi); 1022 uif_close(ubi);
1013out_detach: 1023out_detach:
1014 ubi_wl_close(ubi); 1024 ubi_wl_close(ubi);
1015 free_internal_volumes(ubi); 1025 free_internal_volumes(ubi);
1016 vfree(ubi->vtbl); 1026 vfree(ubi->vtbl);
1027out_debugging:
1028 ubi_debugging_exit_dev(ubi);
1017out_free: 1029out_free:
1018 vfree(ubi->peb_buf1); 1030 vfree(ubi->peb_buf1);
1019 vfree(ubi->peb_buf2); 1031 vfree(ubi->peb_buf2);
@@ -1080,11 +1092,13 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
1080 */ 1092 */
1081 get_device(&ubi->dev); 1093 get_device(&ubi->dev);
1082 1094
1095 ubi_debugfs_exit_dev(ubi);
1083 uif_close(ubi); 1096 uif_close(ubi);
1084 ubi_wl_close(ubi); 1097 ubi_wl_close(ubi);
1085 free_internal_volumes(ubi); 1098 free_internal_volumes(ubi);
1086 vfree(ubi->vtbl); 1099 vfree(ubi->vtbl);
1087 put_mtd_device(ubi->mtd); 1100 put_mtd_device(ubi->mtd);
1101 ubi_debugging_exit_dev(ubi);
1088 vfree(ubi->peb_buf1); 1102 vfree(ubi->peb_buf1);
1089 vfree(ubi->peb_buf2); 1103 vfree(ubi->peb_buf2);
1090 ubi_msg("mtd%d is detached from ubi%d", ubi->mtd->index, ubi->ubi_num); 1104 ubi_msg("mtd%d is detached from ubi%d", ubi->mtd->index, ubi->ubi_num);
@@ -1199,6 +1213,11 @@ static int __init ubi_init(void)
1199 if (!ubi_wl_entry_slab) 1213 if (!ubi_wl_entry_slab)
1200 goto out_dev_unreg; 1214 goto out_dev_unreg;
1201 1215
1216 err = ubi_debugfs_init();
1217 if (err)
1218 goto out_slab;
1219
1220
1202 /* Attach MTD devices */ 1221 /* Attach MTD devices */
1203 for (i = 0; i < mtd_devs; i++) { 1222 for (i = 0; i < mtd_devs; i++) {
1204 struct mtd_dev_param *p = &mtd_dev_param[i]; 1223 struct mtd_dev_param *p = &mtd_dev_param[i];
@@ -1247,6 +1266,8 @@ out_detach:
1247 ubi_detach_mtd_dev(ubi_devices[k]->ubi_num, 1); 1266 ubi_detach_mtd_dev(ubi_devices[k]->ubi_num, 1);
1248 mutex_unlock(&ubi_devices_mutex); 1267 mutex_unlock(&ubi_devices_mutex);
1249 } 1268 }
1269 ubi_debugfs_exit();
1270out_slab:
1250 kmem_cache_destroy(ubi_wl_entry_slab); 1271 kmem_cache_destroy(ubi_wl_entry_slab);
1251out_dev_unreg: 1272out_dev_unreg:
1252 misc_deregister(&ubi_ctrl_cdev); 1273 misc_deregister(&ubi_ctrl_cdev);
@@ -1270,6 +1291,7 @@ static void __exit ubi_exit(void)
1270 ubi_detach_mtd_dev(ubi_devices[i]->ubi_num, 1); 1291 ubi_detach_mtd_dev(ubi_devices[i]->ubi_num, 1);
1271 mutex_unlock(&ubi_devices_mutex); 1292 mutex_unlock(&ubi_devices_mutex);
1272 } 1293 }
1294 ubi_debugfs_exit();
1273 kmem_cache_destroy(ubi_wl_entry_slab); 1295 kmem_cache_destroy(ubi_wl_entry_slab);
1274 misc_deregister(&ubi_ctrl_cdev); 1296 misc_deregister(&ubi_ctrl_cdev);
1275 class_remove_file(ubi_class, &ubi_version); 1297 class_remove_file(ubi_class, &ubi_version);