aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/scan.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/ubi/scan.c')
-rw-r--r--drivers/mtd/ubi/scan.c52
1 files changed, 50 insertions, 2 deletions
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 93257f3c25d0..aecd8cfa3f47 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -1107,14 +1107,14 @@ static int late_analysis(struct ubi_device *ubi, struct ubi_attach_info *ai)
1107} 1107}
1108 1108
1109/** 1109/**
1110 * ubi_scan - scan an MTD device. 1110 * scan_all - scan entire MTD device.
1111 * @ubi: UBI device description object 1111 * @ubi: UBI device description object
1112 * 1112 *
1113 * This function does full scanning of an MTD device and returns complete 1113 * This function does full scanning of an MTD device and returns complete
1114 * information about it in form of a "struct ubi_attach_info" object. In case 1114 * information about it in form of a "struct ubi_attach_info" object. In case
1115 * of failure, an error code is returned. 1115 * of failure, an error code is returned.
1116 */ 1116 */
1117struct ubi_attach_info *ubi_scan(struct ubi_device *ubi) 1117static struct ubi_attach_info *scan_all(struct ubi_device *ubi)
1118{ 1118{
1119 int err, pnum; 1119 int err, pnum;
1120 struct rb_node *rb1, *rb2; 1120 struct rb_node *rb1, *rb2;
@@ -1208,6 +1208,54 @@ out_ai:
1208} 1208}
1209 1209
1210/** 1210/**
1211 * ubi_attach - attach an MTD device.
1212 * @ubi: UBI device descriptor
1213 *
1214 * This function returns zero in case of success and a negative error code in
1215 * case of failure.
1216 */
1217int ubi_attach(struct ubi_device *ubi)
1218{
1219 int err;
1220 struct ubi_attach_info *ai;
1221
1222 ai = scan_all(ubi);
1223 if (IS_ERR(ai))
1224 return PTR_ERR(ai);
1225
1226 ubi->bad_peb_count = ai->bad_peb_count;
1227 ubi->good_peb_count = ubi->peb_count - ubi->bad_peb_count;
1228 ubi->corr_peb_count = ai->corr_peb_count;
1229 ubi->max_ec = ai->max_ec;
1230 ubi->mean_ec = ai->mean_ec;
1231 ubi_msg("max. sequence number: %llu", ai->max_sqnum);
1232
1233 err = ubi_read_volume_table(ubi, ai);
1234 if (err)
1235 goto out_ai;
1236
1237 err = ubi_wl_init(ubi, ai);
1238 if (err)
1239 goto out_vtbl;
1240
1241 err = ubi_eba_init(ubi, ai);
1242 if (err)
1243 goto out_wl;
1244
1245 ubi_destroy_ai(ai);
1246 return 0;
1247
1248out_wl:
1249 ubi_wl_close(ubi);
1250out_vtbl:
1251 ubi_free_internal_volumes(ubi);
1252 vfree(ubi->vtbl);
1253out_ai:
1254 ubi_destroy_ai(ai);
1255 return err;
1256}
1257
1258/**
1211 * destroy_av - free volume attaching information. 1259 * destroy_av - free volume attaching information.
1212 * @av: volume attaching information 1260 * @av: volume attaching information
1213 * @ai: attaching information 1261 * @ai: attaching information