On writes, the Zynq NAND controller needs a bit to be set in the address
register for the last 4 bytes sent. This is correctly handled by the
zynq_nand_write_page_raw() operation but the callback is overwritten
by the core when soft ECC is on. It leads to write failures.

Don't overwrite the write_page_raw callback if it already has a specific
implementation in the NAND driver.
Do the same for the read_page_raw callback to keep symetry between reads
and writes.

Signed-off-by: Bastien Curutchet (DAVE.eu) <[email protected]>
---
 drivers/mtd/nand/raw/nand_base.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index 48e3685d995..d43263d9f96 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -5058,8 +5058,10 @@ int nand_scan_tail(struct mtd_info *mtd)
                ecc->read_page = nand_read_page_swecc;
                ecc->read_subpage = nand_read_subpage;
                ecc->write_page = nand_write_page_swecc;
-               ecc->read_page_raw = nand_read_page_raw;
-               ecc->write_page_raw = nand_write_page_raw;
+               if (!ecc->read_page_raw)
+                       ecc->read_page_raw = nand_read_page_raw;
+               if (!ecc->write_page_raw)
+                       ecc->write_page_raw = nand_write_page_raw;
                ecc->read_oob = nand_read_oob_std;
                ecc->write_oob = nand_write_oob_std;
                if (!ecc->size)

-- 
2.54.0

Reply via email to