From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-io0-x243.google.com ([2607:f8b0:4001:c06::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e91cQ-0005OO-HD for linux-mtd@lists.infradead.org; Mon, 30 Oct 2017 04:24:12 +0000 Received: by mail-io0-x243.google.com with SMTP id j17so24237601iod.5 for ; Sun, 29 Oct 2017 21:23:49 -0700 (PDT) From: motobud@gmail.com To: boris.brezillon@free-electrons.com Cc: Brent Taylor , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] Fix writing mtdoops to nand flash. Date: Sun, 29 Oct 2017 23:23:43 -0500 Message-Id: <20171030042343.24551-1-motobud@gmail.com> List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Brent Taylor 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 --- 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