#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
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:
*/
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;
if (err)
goto out_free;
+ err = -ENOMEM;
ubi->peb_buf1 = vmalloc(ubi->peb_size);
if (!ubi->peb_buf1)
goto out_free;
ubi->peb_buf2 = vmalloc(ubi->peb_size);
if (!ubi->peb_buf2)
- goto out_free;
+ goto out_free;
#ifdef CONFIG_MTD_UBI_DEBUG
mutex_init(&ubi->dbg_buf_mutex);
ubi->dbg_peb_buf = vmalloc(ubi->peb_size);
if (!ubi->dbg_peb_buf)
- goto out_free;
+ goto out_free;
#endif
err = attach_by_scanning(ubi);
out_class:
class_destroy(ubi_class);
out:
+ mtd_devs = 0;
ubi_err("UBI error: cannot initialize UBI, error %d", err);
return err;
}
misc_deregister(&ubi_ctrl_cdev);
class_remove_file(ubi_class, &ubi_version);
class_destroy(ubi_class);
+ mtd_devs = 0;
}
module_exit(ubi_exit);