
12 Jul
2018
12 Jul
'18
3:12 p.m.
Hi Boris,
if (full_erase) {
off = 0;
len = mtd->size;
}
if ((u32)off % mtd->erasesize) {
Sounds dangerous. We have 8GB NANDs on sunxi platforms...
[...]
if ((u32)len % mtd->erasesize) {
Same here. I guess there's a do_div() in uboot.
In both cases I take the less significant bytes of a 64-bit value. The modulo operation is safe as long as mtd->erasesize is a 32-bit value too. I don't think there is any danger?
As discussed out of this thread, this works because mtd->erasesize is always a power of 2. Erase sizes not being a power of 2 do not exist but it will be safer to switch to do_div().
Thanks, Miquèl