mtd-utils: Proper way to handle erasize=0
Richard Weinberger
richard at nod.at
Mon Jul 19 12:36:46 PDT 2021
----- Ursprüngliche Mail -----
> Von: "festevam" <festevam at gmail.com>
> An: "david oberhollenzer" <david.oberhollenzer at sigma-star.at>, "richard" <richard at nod.at>
> CC: "linux-mtd" <linux-mtd at lists.infradead.org>, "Miquel Raynal" <miquel.raynal at bootlin.com>, "Marek Vasut"
> <marex at denx.de>, "hs" <hs at denx.de>
> Gesendet: Montag, 19. Juli 2021 21:12:26
> Betreff: mtd-utils: Proper way to handle erasize=0
> Hi,
>
> When using a Microchip 48l640 SRAM (drivers/mtd/devices/mchp48l640.c)
> the reported erasesize is 0:
>
> # cat /proc/mtd
> dev: size erasesize name
> mtd0: 00002000 00000000 "spi0.0"
>
> This causes a division by zero at libmtd.c, as mtd_get_dev_info1() has:
>
> mtd->eb_cnt = mtd->size / mtd->eb_size;
>
> What would be the appropriate way to fix this?
Didn't this commit address that problem?
commit 54d68799b73e755923def1306b4da607ad45bd60
Author: Chris Packham <chris.packham at alliedtelesis.co.nz>
Date: Fri Nov 27 13:07:08 2020 +1300
libmtd: avoid divide by zero
The concept of erase blocks doesn't apply to mtd-ram devices. Such
devices set MTD_NO_ERASE to indicate this and some report 0 for the
erase block size. Avoid a divide by zero when calculating the erase
block count for such devices.
Signed-off-by: Chris Packham <chris.packham at alliedtelesis.co.nz>
Acked-by: Richard Weinberger <richard at nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer at sigma-star.at>
Thanks,
//richard
More information about the linux-mtd
mailing list