OSDN Git Service

mtd: rawnand: add hooks that may be called during nand_scan()
authorMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 18 Jul 2018 23:05:46 +0000 (01:05 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 31 Jul 2018 07:45:53 +0000 (09:45 +0200)
commit05b54c7bac906c443fd0b23ab8954e0560b33e5c
treeabd06f557b559470ade1502b49fc515ebd645c67
parent7da45139d264f3b7ead04e00ebb29b189cf9826e
mtd: rawnand: add hooks that may be called during nand_scan()

In order to remove the limitation that forbids dynamic allocation in
nand_scan_ident(), we must create a path that will be the same for all
controller drivers. The idea is to use nand_scan() instead of the widely
used nand_scan_ident()/nand_scan_tail() couple. In order to achieve
this, controller drivers will need to adjust some parameters between
these two functions depending on the NAND chip wired on them.

This takes the form of two new hooks (->{attach,detach}_chip()) that are
placed in a new nand_controller_ops structure, which is then attached
to the nand_controller object at driver initialization time.
->attach_chip() is called between nand_scan_ident() and
nand_scan_tail(), and ->detach_chip() is called in the error path of
nand_scan() and in nand_cleanup().

Note that some NAND controller drivers don't have a dedicated
nand_controller object and instead rely on the default/dummy one
embedded in nand_chip. If you're in this case and still want to
initialize the controller ops, you'll have to manipulate
chip->dummy_controller directly.

Last but not least, it's worth mentioning that we plan to move some of
the controller related hooks placed in nand_chip into
nand_controller_ops to make the separation between NAND chip and NAND
controller methods clearer.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Boris Brezillon <boris.brezillon@bootlin.com>
drivers/mtd/nand/raw/nand_base.c
include/linux/mtd/rawnand.h