Question on mtd devices with zero erasesize

Antonio Borneo borneo.antonio at gmail.com
Wed Dec 6 05:28:25 PST 2017


Hi,
I have searched in the mailing list archives but didn't found such topic.

In mainline kernel there are already few RAM based mtd devices; the
concept of "erase unit" (sector or page) does not always apply to
them.
At least two of such devices set the field "erasesize" to zero (or,
better, do not set it at all and left it to zero):
- drivers/mtd/devices/ms02-nv.c
- drivers/mtd/devices/mchp23k256.c

The following is tested with mchp23k256 only.
Of course I read zero from /sys/class/mtd/mtdX/erasesize
The tool mdtinfo core-dumps for division by zero when it try to
compute the number of erase units by dividing device size by
erasesize.

What would be the proper fix?

First of all, is erasesize=1 correct in this case, or for some reason
it is better to use another value?

Then, is the driver that is supposed to provide a non-zero value for erasesize?
Or is the mtd framework that should check the value set by the driver
and eventually replace it with a minimum erasesize?
Or is the userland that has to accept the zero value?

Thanks and Best Regards,
Antonio Borneo



More information about the linux-mtd mailing list