public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Vitaly Wool <vwool@ru.mvista.com>
To: tglx@linutronix.de
Cc: linux-mtd@lists.infradead.org
Subject: Re: power management routines for NAND driver
Date: Fri, 12 Aug 2005 19:11:46 +0400	[thread overview]
Message-ID: <20050812191146.2e38ed1c.vwool@ru.mvista.com> (raw)
In-Reply-To: <1123772959.23647.24.camel@tglx.tec.linutronix.de>

Hi Thomas,
please find the patch below.

Best regards,
   Vitaly

P. S. Is it reasonable to send the use case (i. e. the NAND driver I'm working at that uses the simple framework introduced)?

File: nand-pm.patch
Type: Enhancement
Signed-off-by: Vitaly Wool <vwool@ru.mvista.com>
Description:

	Add LDM-compliant power management support for NAND flashes.

Index: linux-2.6.10/include/linux/mtd/nand.h
===================================================================
--- linux-2.6.10.orig/include/linux/mtd/nand.h
+++ linux-2.6.10/include/linux/mtd/nand.h
@@ -244,6 +244,7 @@
 	FL_ERASING,
 	FL_SYNCING,
 	FL_CACHEDPRG,
+	FL_PM_SUSPENDED,
 } nand_state_t;
 
 /* Keep gcc happy */
Index: linux-2.6.10/drivers/mtd/nand/nand_base.c
===================================================================
--- linux-2.6.10.orig/drivers/mtd/nand/nand_base.c
+++ linux-2.6.10/drivers/mtd/nand/nand_base.c
@@ -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  
  *	
@@ -2284,6 +2286,45 @@
 }
 
 /**
+ * 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;
+	int ret = 0;
+
+	switch(this->state) {
+		case FL_READY:
+			nand_get_device (this, mtd, FL_PM_SUSPENDED);
+		case FL_PM_SUSPENDED:
+			break;
+
+		default:
+			ret = -EAGAIN;
+			break;
+	}
+	return ret;
+}
+
+/**
+ * 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
  * @maxchips:	Number of chips to scan for
@@ -2642,8 +2683,8 @@
 	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;
 

  parent reply	other threads:[~2005-08-12 15:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-11 14:19 power management routines for NAND driver Vitaly Wool
2005-08-11 15:09 ` Thomas Gleixner
2005-08-11 15:25   ` Vitaly Wool
2005-08-11 16:25     ` Thomas Gleixner
2005-08-12 15:11   ` Vitaly Wool [this message]
2005-08-12 15:36     ` Thomas Gleixner
2005-08-12 15:41       ` Thomas Gleixner
2005-08-12 15:55       ` Vitaly Wool
2005-08-12 16:16         ` Thomas Gleixner
2005-08-12 16:46           ` Vitaly Wool
2005-08-22 12:54             ` Vitaly Wool
2005-08-12 15:57       ` Vitaly Wool
2005-08-11 20:23 ` Todd Poynor
2005-08-11 20:31   ` Thomas Gleixner
2005-08-11 20:49     ` Vitaly Wool
2005-08-11 20:53       ` Thomas Gleixner
2005-08-11 20:55         ` Josh Boyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050812191146.2e38ed1c.vwool@ru.mvista.com \
    --to=vwool@ru.mvista.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox