mtd: nand_wait: warn if the nand is busy on exit
authorMatthieu CASTET <matthieu.castet@parrot.com>
Mon, 5 Nov 2012 14:00:44 +0000 (15:00 +0100)
committerArtem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
Thu, 15 Nov 2012 17:50:30 +0000 (19:50 +0200)
This patch allow to detect buggy driver/hardware with
bad RnB (dev_ready) management or when timeout occurs in polling mode.

This works when dev_ready is set or not set.
There are 2 methods to wait for an erase/program command completion:

1. Wait until nand RnB pin goes high (that's what chip->dev_ready usually does)
2. Poll the device: send a status (0x70) command and read status byte in a loop
   until bit NAND_STATUS_READY is set

In all cases, you should send a status command after completion, to check if
the operation was successful. And if the operation completed, the status should
have bit NAND_STATUS_READY set.

Signed-off-by: Matthieu CASTET <matthieu.castet@parrot.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
drivers/mtd/nand/nand_base.c

index 1d5c951ebcb00b1c217e7cf55f0be019dfbfc4d6..01505406ca7b4ac69b95a925a8f73494e8c0d9ac 100644 (file)
@@ -865,6 +865,8 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)
        led_trigger_event(nand_led_trigger, LED_OFF);
 
        status = (int)chip->read_byte(mtd);
+       /* This can happen if in case of timeout or buggy dev_ready */
+       WARN_ON(!(status & NAND_STATUS_READY));
        return status;
 }
 
This page took 0.02674 seconds and 5 git commands to generate.