@@ -1207,25 +1207,29 @@ out_ai:
/**
* ubi_attach - attach an MTD device.
* @ubi: UBI device descriptor
+ * @force_scan: if set to non-zero attach by scanning
*
* 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 ubi_attach(struct ubi_device *ubi, int force_scan)
{
- int err;
+ int err, i;
struct ubi_attach_info *ai;
ai = kzalloc(sizeof(struct ubi_attach_info), GFP_KERNEL);
if (!ai)
return -ENOMEM;
- err = ubi_scan_fastmap(ubi, ai);
- if (err > 0) {
+ if (force_scan)
err = scan_all(ubi, ai);
- if (err)
- return err;
- } else if (err < 0)
+ else {
+ err = ubi_scan_fastmap(ubi, ai);
+ if (err > 0)
+ err = scan_all(ubi, ai);
+ }
+
+ if (err)
return err;
/* TODO: currently the fastmap code assumes that the fastmap data
@@ -928,7 +928,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
if (err)
goto out_free;
- err = ubi_attach(ubi);
+ err = ubi_attach(ubi, 0);
if (err) {
ubi_err("failed to attach mtd%d, error %d", mtd->index, err);
goto out_debugging;
@@ -693,7 +693,7 @@ struct ubi_ainf_volume *ubi_find_av(const struct ubi_attach_info *ai,
void ubi_remove_av(struct ubi_attach_info *ai, struct ubi_ainf_volume *av);
struct ubi_ainf_peb *ubi_early_get_peb(struct ubi_device *ubi,
struct ubi_attach_info *ai);
-int ubi_attach(struct ubi_device *ubi);
+int ubi_attach(struct ubi_device *ubi, int force_scan);
void ubi_destroy_ai(struct ubi_device *ubi, struct ubi_attach_info *ai);
/* vtbl.c */
Signed-off-by: Richard Weinberger <richard@nod.at> --- drivers/mtd/ubi/attach.c | 18 +++++++++++------- drivers/mtd/ubi/build.c | 2 +- drivers/mtd/ubi/ubi.h | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-)