]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/mtd/ubi/build.c
Merge branch 'master' of git://git.denx.de/u-boot-nand-flash
[karo-tx-uboot.git] / drivers / mtd / ubi / build.c
index f4b01a9ded249adb84d6387e72633d53b1095a4a..25888220df287e99a673a6a95c97de5af76c8b4b 100644 (file)
 #include <ubi_uboot.h>
 #include "ubi.h"
 
+#if (CONFIG_SYS_MALLOC_LEN < (512 << 10))
+#error Malloc area too small for UBI, increase CONFIG_SYS_MALLOC_LEN to >= 512k
+#endif
+
 /* Maximum length of the 'mtd=' parameter */
 #define MTD_PARAM_LEN_MAX 64
 
@@ -472,19 +476,19 @@ static int attach_by_scanning(struct ubi_device *ubi)
        if (err)
                goto out_si;
 
-       err = ubi_wl_init_scan(ubi, si);
+       err = ubi_eba_init_scan(ubi, si);
        if (err)
                goto out_vtbl;
 
-       err = ubi_eba_init_scan(ubi, si);
+       err = ubi_wl_init_scan(ubi, si);
        if (err)
-               goto out_wl;
+               goto out_eba;
 
        ubi_scan_destroy_si(si);
        return 0;
 
-out_wl:
-       ubi_wl_close(ubi);
+out_eba:
+       ubi_eba_close(ubi);
 out_vtbl:
        vfree(ubi->vtbl);
 out_si:
@@ -532,10 +536,10 @@ static int io_init(struct ubi_device *ubi)
         */
 
        ubi->peb_size   = ubi->mtd->erasesize;
-       ubi->peb_count  = ubi->mtd->size / ubi->mtd->erasesize;
+       ubi->peb_count  = mtd_div_by_eb(ubi->mtd->size, ubi->mtd);
        ubi->flash_size = ubi->mtd->size;
 
-       if (ubi->mtd->block_isbad && ubi->mtd->block_markbad)
+       if (mtd_can_have_bb(ubi->mtd))
                ubi->bad_allowed = 1;
 
        ubi->min_io_size = ubi->mtd->writesize;
@@ -1041,6 +1045,7 @@ out_version:
 out_class:
        class_destroy(ubi_class);
 out:
+       mtd_devs = 0;
        ubi_err("UBI error: cannot initialize UBI, error %d", err);
        return err;
 }