From mboxrd@z Thu Jan 1 00:00:00 1970 From: Miquel Raynal Date: Thu, 12 Jul 2018 15:12:37 +0200 Subject: [U-Boot] [PATCH v2 20/21] cmd: mtd: add 'mtd' command In-Reply-To: <20180712145132.0d22dcce@xps13> References: <20180711152529.24547-1-miquel.raynal@bootlin.com> <20180711152529.24547-21-miquel.raynal@bootlin.com> <20180712004213.71286527@bbrezillon> <20180712145132.0d22dcce@xps13> Message-ID: <20180712151237.596453b1@xps13> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Hi Boris, > > > + > > > + if (full_erase) { > > > + off =3D 0; > > > + len =3D mtd->size; > > > + } > > > + > > > + if ((u32)off % mtd->erasesize) { =20 > >=20 > > Sounds dangerous. We have 8GB NANDs on sunxi platforms... =20 >=20 > [...] >=20 > > > + > > > + if ((u32)len % mtd->erasesize) { =20 > >=20 > > Same here. I guess there's a do_div() in uboot. =20 >=20 > 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=C3=A8l