mtd: nand: added nand_shutdown

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon Feb 16 18:59:02 PST 2015


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=72ea403669c7d49e8c407c61205b6d52438d39ab
Commit:     72ea403669c7d49e8c407c61205b6d52438d39ab
Parent:     3efe41be224c4441f2a872a25471a14d85ceb7c6
Author:     Scott Branden <sbranden at broadcom.com>
AuthorDate: Thu Nov 20 11:18:05 2014 -0800
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Wed Jan 7 17:54:28 2015 -0800

    mtd: nand: added nand_shutdown
    
    Add nand_shutdown to wait for current nand operations to finish and prevent
    further operations by changing the nand flash state to FL_SHUTDOWN.
    
    This is addressing a problem observed during reboot tests using UBIFS
    root file system: NAND erase operations that are in progress during
    system reboot/shutdown are causing partial erased blocks. Although UBI should
    be able to detect and recover from this error, this change will avoid
    the creation of partial erased blocks on reboot in the middle of a NAND erase
    operation.
    
    Signed-off-by: Scott Branden <sbranden at broadcom.com>
    Tested-by: Scott Branden <sbranden at broadcom.com>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/nand/nand_base.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 41585df..382354b 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2944,6 +2944,16 @@ static void nand_resume(struct mtd_info *mtd)
 			__func__);
 }
 
+/**
+ * nand_shutdown - [MTD Interface] Finish the current NAND operation and
+ *                 prevent further operations
+ * @mtd: MTD device structure
+ */
+static void nand_shutdown(struct mtd_info *mtd)
+{
+	nand_get_device(mtd, FL_SHUTDOWN);
+}
+
 /* Set default functions */
 static void nand_set_defaults(struct nand_chip *chip, int busw)
 {
@@ -4146,6 +4156,7 @@ int nand_scan_tail(struct mtd_info *mtd)
 	mtd->_unlock = NULL;
 	mtd->_suspend = nand_suspend;
 	mtd->_resume = nand_resume;
+	mtd->_reboot = nand_shutdown;
 	mtd->_block_isreserved = nand_block_isreserved;
 	mtd->_block_isbad = nand_block_isbad;
 	mtd->_block_markbad = nand_block_markbad;



More information about the linux-mtd-cvs mailing list