]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00279980 ubi: attach: do not return -EINVAL if the mtd->numeraseregions is 1
authorHuang Shijie <b32955@freescale.com>
Wed, 18 Sep 2013 02:17:39 +0000 (10:17 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Wed, 20 Aug 2014 08:06:42 +0000 (10:06 +0200)
If the master mtd does not have any slave mtd partitions,
and its numeraseregions is one(only has one erease block), and
we attach the master mtd with : ubiattach -m 0 -d 0

We will meet the error:
-------------------------------------------------------
root@freescale ~$ ubiattach /dev/ubi_ctrl -m 0 -d 0
UBI: attaching mtd0 to ubi0
UBI error: io_init: multiple regions, not implemented
ubiattach: error!: cannot attach mtd0
           error 22 (Invalid argument)
-------------------------------------------------------

In fact, if there is only one "erase block", we should not
prevent the attach.

This patch fixes it.

Signed-off-by: Huang Shijie <b32955@freescale.com>
drivers/mtd/ubi/build.c

index 6e30a3c280d0ffb6c5ad2f4165a5b946843063b7..405a922977190e8869fc5786ac9f8a35d9ca0bf6 100644 (file)
@@ -640,7 +640,7 @@ static int io_init(struct ubi_device *ubi, int max_beb_per1024)
        dbg_gen("sizeof(struct ubi_ainf_peb) %zu", sizeof(struct ubi_ainf_peb));
        dbg_gen("sizeof(struct ubi_wl_entry) %zu", sizeof(struct ubi_wl_entry));
 
-       if (ubi->mtd->numeraseregions != 0) {
+       if (ubi->mtd->numeraseregions > 1) {
                /*
                 * Some flashes have several erase regions. Different regions
                 * may have different eraseblock size and other