mtd: Add sanity checks in mtd_write/read_oob()
authorBoris Brezillon <boris.brezillon@free-electrons.com>
Thu, 16 Aug 2018 15:30:01 +0000 (17:30 +0200)
committerJagan Teki <jagan@amarulasolutions.com>
Thu, 20 Sep 2018 14:40:49 +0000 (20:10 +0530)
commit8fad769f1eab88a2bcf0b714694158968f58715a
tree1ba5bf66ac3327c1365de7844269ad4060217d56
parent5f50d82d8918b711717b4bbd96c6f348eb6e2a2c
mtd: Add sanity checks in mtd_write/read_oob()

Unlike what's done in mtd_read/write(), there are no checks to make sure
the parameters passed to mtd_read/write_oob() are consistent, which
forces implementers of ->_read/write_oob() to do it, which in turn leads
to code duplication and possibly errors in the logic.

Do general sanity checks, like ops fields consistency and range checking.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Peter Pan <peterpandong@micron.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
[Miquel: squashed the fix about the chip's size check]
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/mtdcore.c