|
@@ -46,6 +46,8 @@
|
|
|
* perform extra error status checks on erase and write failures. This required
|
|
|
* adding a wrapper function for nand_read_ecc.
|
|
|
*
|
|
|
+ * 08-20-2005 vwool: suspend/resume added
|
|
|
+ *
|
|
|
* Credits:
|
|
|
* David Woodhouse for adding multichip support
|
|
|
*
|
|
@@ -59,7 +61,7 @@
|
|
|
* The AG-AND chips have nice features for speed improvement,
|
|
|
* which are not supported yet. Read / program 4 pages in one go.
|
|
|
*
|
|
|
- * $Id: nand_base.c,v 1.148 2005/08/04 17:14:48 gleixner Exp $
|
|
|
+ * $Id: nand_base.c,v 1.150 2005/09/15 13:58:48 vwool Exp $
|
|
|
*
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
@@ -153,7 +155,7 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int
|
|
|
#define nand_verify_pages(...) (0)
|
|
|
#endif
|
|
|
|
|
|
-static void nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state);
|
|
|
+static int nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state);
|
|
|
|
|
|
/**
|
|
|
* nand_release_device - [GENERIC] release chip
|
|
@@ -756,7 +758,7 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column,
|
|
|
*
|
|
|
* Get the device and lock it for exclusive access
|
|
|
*/
|
|
|
-static void nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state)
|
|
|
+static int nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state)
|
|
|
{
|
|
|
struct nand_chip *active;
|
|
|
spinlock_t *lock;
|
|
@@ -779,7 +781,11 @@ retry:
|
|
|
if (active == this && this->state == FL_READY) {
|
|
|
this->state = new_state;
|
|
|
spin_unlock(lock);
|
|
|
- return;
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ if (new_state == FL_PM_SUSPENDED) {
|
|
|
+ spin_unlock(lock);
|
|
|
+ return (this->state == FL_PM_SUSPENDED) ? 0 : -EAGAIN;
|
|
|
}
|
|
|
set_current_state(TASK_UNINTERRUPTIBLE);
|
|
|
add_wait_queue(wq, &wait);
|
|
@@ -2284,6 +2290,34 @@ static int nand_block_markbad (struct mtd_info *mtd, loff_t ofs)
|
|
|
return this->block_markbad(mtd, ofs);
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * nand_suspend - [MTD Interface] Suspend the NAND flash
|
|
|
+ * @mtd: MTD device structure
|
|
|
+ */
|
|
|
+static int nand_suspend(struct mtd_info *mtd)
|
|
|
+{
|
|
|
+ struct nand_chip *this = mtd->priv;
|
|
|
+
|
|
|
+ return nand_get_device (this, mtd, FL_PM_SUSPENDED);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * nand_resume - [MTD Interface] Resume the NAND flash
|
|
|
+ * @mtd: MTD device structure
|
|
|
+ */
|
|
|
+static void nand_resume(struct mtd_info *mtd)
|
|
|
+{
|
|
|
+ struct nand_chip *this = mtd->priv;
|
|
|
+
|
|
|
+ if (this->state == FL_PM_SUSPENDED)
|
|
|
+ nand_release_device(mtd);
|
|
|
+ else
|
|
|
+ printk(KERN_ERR "resume() called for the chip which is not "
|
|
|
+ "in suspended state\n");
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* nand_scan - [NAND Interface] Scan for the NAND device
|
|
|
* @mtd: MTD device structure
|
|
@@ -2643,8 +2677,8 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
|
|
|
mtd->sync = nand_sync;
|
|
|
mtd->lock = NULL;
|
|
|
mtd->unlock = NULL;
|
|
|
- mtd->suspend = NULL;
|
|
|
- mtd->resume = NULL;
|
|
|
+ mtd->suspend = nand_suspend;
|
|
|
+ mtd->resume = nand_resume;
|
|
|
mtd->block_isbad = nand_block_isbad;
|
|
|
mtd->block_markbad = nand_block_markbad;
|
|
|
|