]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
mtd: nand: fix interpretation of NAND_CMD_NONE in nand_command[_lp]()
authorMiquel Raynal <miquel.raynal@free-electrons.com>
Wed, 8 Nov 2017 16:00:27 +0000 (17:00 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Mar 2018 08:09:52 +0000 (09:09 +0100)
commitdf2bc9f0c7d9299757a11fa3e363c95fb10b9160
treebade915d5b7d884072c254f4e50a5408d52788dc
parent71dc53969aa944e91131e65abf140110868d3897
mtd: nand: fix interpretation of NAND_CMD_NONE in nand_command[_lp]()

[ Upstream commit df467899da0b71465760b4e35127bce837244eee ]

Some drivers (like nand_hynix.c) call ->cmdfunc() with NAND_CMD_NONE
and a column address and expect the controller to only send address
cycles. Right now, the default ->cmdfunc() implementations provided by
the core do not filter out the command cycle in this case and forwards
the request to the controller driver through the ->cmd_ctrl() method.
The thing is, NAND controller drivers can get this wrong and send a
command cycle with a NAND_CMD_NONE opcode and since NAND_CMD_NONE is
-1, and the command field is usually casted to an u8, we end up sending
the 0xFF command which is actually a RESET operation.

Add conditions in nand_command[_lp]() functions to sending the initial
command cycle when command == NAND_CMD_NONE.

Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/nand/nand_base.c