All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix writing mtdoops to nand flash.
@ 2017-10-30  4:23 motobud
  2017-10-30  8:23 ` Boris Brezillon
  2017-10-31  3:32 ` [PATCH v2] mtd: nand: " motobud
  0 siblings, 2 replies; 7+ messages in thread
From: motobud @ 2017-10-30  4:23 UTC (permalink / raw)
  To: boris.brezillon
  Cc: Brent Taylor, Richard Weinberger, David Woodhouse, Brian Norris,
	Marek Vasut, Cyrille Pitchen, linux-mtd, linux-kernel

From: Brent Taylor <motobud@gmail.com>

When mtdoops calls mtd_panic_write, it eventually calls
panic_nand_write in nand_base.c.  In order to properly
wait for the nand chip to be ready in panic_nand_wait,
the chip must first be selected.

When using the atmel nand flash controller, a panic
would occur due to a NULL pointer exception.

Signed-off-by: Brent Taylor <motobud@gmail.com>
---
 drivers/mtd/nand/nand_base.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 12edaae17d81..0a8058a66d93 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2802,9 +2802,14 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
 	struct mtd_oob_ops ops;
 	int ret;
 
+	int chipnr = (int)(to >> chip->chip_shift);
+	chip->select_chip(mtd, chipnr);
+
 	/* Wait for the device to get ready */
 	panic_nand_wait(mtd, chip, 400);
 
+	chip->select_chip(mtd, -1);
+
 	/* Grab the device */
 	panic_nand_get_device(chip, mtd, FL_WRITING);
 
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-11-02 10:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-30  4:23 [PATCH] Fix writing mtdoops to nand flash motobud
2017-10-30  8:23 ` Boris Brezillon
2017-10-30 12:46   ` Brent Taylor
2017-10-30 13:15     ` Boris Brezillon
2017-10-31  3:32 ` [PATCH v2] mtd: nand: " motobud
2017-10-31 10:18   ` Boris Brezillon
2017-11-02 10:48   ` Boris Brezillon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.