From mboxrd@z Thu Jan 1 00:00:00 1970 From: Miquel Raynal Date: Thu, 12 Jul 2018 10:05:32 +0200 Subject: [U-Boot] [PATCH v2 04/21] mtd: Fallback to ->_read/write() when ->_read/write_oob() is missing In-Reply-To: <20180712002052.63ec7709@bbrezillon> References: <20180711152529.24547-1-miquel.raynal@bootlin.com> <20180711152529.24547-5-miquel.raynal@bootlin.com> <20180712002052.63ec7709@bbrezillon> Message-ID: <20180712100532.562f8c7b@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, Boris Brezillon wrote on Thu, 12 Jul 2018 00:20:52 +0200: > On Wed, 11 Jul 2018 17:25:12 +0200 > Miquel Raynal wrote: >=20 > > Some MTD sublayers/drivers are implementing ->_read/write() and > > not ->_read/write_oob(). > >=20 > > While for NAND devices both are usually valid, for NOR devices, using > > the _oob variant has no real meaning. But, as the MTD layer is supposed > > to hide as much as possible the flash complexity to the user, there is > > no reason to error out while it is just a matter of rewritting things > > internally. > >=20 > > Add a fallback on mtd->_read() (resp. mtd->_write()) when the user calls > > mtd_read_oob() (resp. mtd_write_oob()) while mtd->_read_oob() (resp. > > mtd->_write_oob) is not implemented. There is already a fallback on the > > _oob variant if the former is used. =20 >=20 > Now I'm jealous. Can we have the same thing Linux :-). U-Boot, one step ahead ;) >=20 > >=20 > > Signed-off-by: Miquel Raynal > > --- > > drivers/mtd/mtdcore.c | 26 ++++++++++++++++++++------ > > 1 file changed, 20 insertions(+), 6 deletions(-) > >=20 > > diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c > > index ba170f212e..095c58cf8c 100644 > > --- a/drivers/mtd/mtdcore.c > > +++ b/drivers/mtd/mtdcore.c > > @@ -1048,20 +1048,27 @@ int mtd_read_oob(struct mtd_info *mtd, loff_t f= rom, struct mtd_oob_ops *ops) > > { > > int ret_code; > > ops->retlen =3D ops->oobretlen =3D 0; > > - if (!mtd->_read_oob) > > - return -EOPNOTSUPP; > > =20 > > ret_code =3D mtd_check_oob_ops(mtd, from, ops); > > if (ret_code) > > return ret_code; > > =20 > > + /* Check the validity of a potential fallback on mtd->_read */ > > + if ((!mtd->_read_oob) && (!mtd->_read || ops->oobbuf)) =20 >=20 > Parens around !mtd->_read_oob are not needed. [...] > > - return mtd->_write_oob(mtd, to, ops); > > + /* Check the validity of a potential fallback on mtd->_write */ > > + if ((!mtd->_write_oob) && (!mtd->_write || ops->oobbuf)) =20 >=20 > Ditto. >=20 Right! Thanks, Miqu=C3=A8l