summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/scan.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-05-18 12:41:17 +0300
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-05-20 20:26:04 +0300
commit47e1ec70b2c57f39752ae3210d89a625768f3e12 (patch)
tree6416115fb9753c5e44c6fd8d5eb15b8e55339af3 /drivers/mtd/ubi/scan.c
parent41e0cd9d4eeff0895e66cad5c70a90ba41023ea3 (diff)
downloadop-kernel-dev-47e1ec70b2c57f39752ae3210d89a625768f3e12.zip
op-kernel-dev-47e1ec70b2c57f39752ae3210d89a625768f3e12.tar.gz
UBI: move and rename attach_by_scanning
Rename the 'attach_by_scanning()' function to 'ubi_attach()' and move it to scan.c. Richard will plug his fastmap stuff there. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
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 93257f3..aecd8cfa 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)
}
/**
- * ubi_scan - scan an MTD device.
+ * scan_all - scan entire MTD device.
* @ubi: UBI device description object
*
* This function does full scanning of an MTD device and returns complete
* information about it in form of a "struct ubi_attach_info" object. In case
* of failure, an error code is returned.
*/
-struct ubi_attach_info *ubi_scan(struct ubi_device *ubi)
+static struct ubi_attach_info *scan_all(struct ubi_device *ubi)
{
int err, pnum;
struct rb_node *rb1, *rb2;
@@ -1208,6 +1208,54 @@ out_ai:
}
/**
+ * ubi_attach - attach an MTD device.
+ * @ubi: UBI device descriptor
+ *
+ * This function returns zero in case of success and a negative error code in
+ * case of failure.
+ */
+int ubi_attach(struct ubi_device *ubi)
+{
+ int err;
+ struct ubi_attach_info *ai;
+
+ ai = scan_all(ubi);
+ if (IS_ERR(ai))
+ return PTR_ERR(ai);
+
+ ubi->bad_peb_count = ai->bad_peb_count;
+ ubi->good_peb_count = ubi->peb_count - ubi->bad_peb_count;
+ ubi->corr_peb_count = ai->corr_peb_count;
+ ubi->max_ec = ai->max_ec;
+ ubi->mean_ec = ai->mean_ec;
+ ubi_msg("max. sequence number: %llu", ai->max_sqnum);
+
+ err = ubi_read_volume_table(ubi, ai);
+ if (err)
+ goto out_ai;
+
+ err = ubi_wl_init(ubi, ai);
+ if (err)
+ goto out_vtbl;
+
+ err = ubi_eba_init(ubi, ai);
+ if (err)
+ goto out_wl;
+
+ ubi_destroy_ai(ai);
+ return 0;
+
+out_wl:
+ ubi_wl_close(ubi);
+out_vtbl:
+ ubi_free_internal_volumes(ubi);
+ vfree(ubi->vtbl);
+out_ai:
+ ubi_destroy_ai(ai);
+ return err;
+}
+
+/**
* destroy_av - free volume attaching information.
* @av: volume attaching information
* @ai: attaching information
OpenPOWER on IntegriCloud