]> www.infradead.org Git - mtd-utils.git/commitdiff
libmtd: allow write operations when MEMWRITE is not supported
authorBrian Norris <computersforpeace@gmail.com>
Fri, 9 Dec 2011 19:45:14 +0000 (11:45 -0800)
committerArtem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
Mon, 12 Dec 2011 21:45:54 +0000 (23:45 +0200)
MEMWRITE is a recently introduced write interface for MTD; however, it
is only supported on NAND flash. mtd-utils should fall back to
old write methods when either ENOTTY or EOPNOTSUPP are returned.

This is a showstopper when, for instance, using ubiformat on NOR, which
don't have a mtd->write_oob interface (and thus don't support MEMWRITE):

  ubiformat: formatting eraseblock 2 --  1 % complete  libmtd: error!: MEMWRITE ioctl failed for eraseblock 2 (mtd3)
          error 122 (Operation not supported)

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
lib/libmtd.c

index 1b16de5250a5bf4abf1f979ecf19a7088d9aa170..9b247ae8a65097a6520ebf8be73d1e67633eab9e 100644 (file)
@@ -1151,7 +1151,7 @@ int mtd_write(libmtd_t desc, const struct mtd_dev_info *mtd, int fd, int eb,
        ret = ioctl(fd, MEMWRITE, &ops);
        if (ret == 0)
                return 0;
-       else if (errno != ENOTTY)
+       else if (errno != ENOTTY && errno != EOPNOTSUPP)
                return mtd_ioctl_error(mtd, eb, "MEMWRITE");
 
        /* Fall back to old methods if necessary */