On Fri, Nov 23, 2018 at 03:50:15PM +0100, Matthias Schiffer wrote: > At least some MTD_NO_ERASE devices like MRAM do not specify a sensible > erase block size; instead, erasesize is equal to the whole flash size. This > leads to an EINVAL return from mtd_erase_align() whenever a partial erase > is attempted. > > At least on the MRAM I tested, a full flash erase did not return an error, > but it did not have any effect on the flash either. As erase seems to be > entirely unsupported on this class of devices, and it is not necessary > anyways, it's better to return early with EOPNOTSUPP. > > This fixes envfs_save() on a partitioned MRAM. > > Signed-off-by: Matthias Schiffer <matthias.schiffer@xxxxxxxxxxxxxxx> > --- Applied, thanks Sascha > > v2: handle in mtd_op_erase() instead of envfs_save() > > drivers/mtd/core.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c > index 56e85b3d8..d3cbe502f 100644 > --- a/drivers/mtd/core.c > +++ b/drivers/mtd/core.c > @@ -178,6 +178,9 @@ static int mtd_op_erase(struct cdev *cdev, loff_t count, loff_t offset) > loff_t addr; > int ret; > > + if (mtd->flags & MTD_NO_ERASE) > + return -EOPNOTSUPP; > + > ret = mtd_erase_align(mtd, &count, &offset); > if (ret) > return ret; > -- > 2.17.1 > > > _______________________________________________ > barebox mailing list > barebox@xxxxxxxxxxxxxxxxxxx > http://lists.infradead.org/mailman/listinfo/barebox > -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox