power management routines for NAND driver

Thomas Gleixner tglx at linutronix.de
Fri Aug 12 11:41:25 EDT 2005


On Fri, 2005-08-12 at 15:36 +0000, Thomas Gleixner wrote:

> The correct solution is to do the check in nand_get_device with the lock
> held. 

Of course it works better when the lock is unlocked before returning :)

tglx


Index: nand_base.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand_base.c,v
retrieving revision 1.148
diff -u -p -r1.148 nand_base.c
--- nand_base.c	4 Aug 2005 17:14:48 -0000	1.148
+++ nand_base.c	12 Aug 2005 15:39:55 -0000
@@ -755,7 +755,7 @@ static void nand_command_lp (struct mtd_
  *
  * 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;
@@ -778,7 +778,11 @@ retry:
 	if (active == this && this->state == FL_READY) {
 		this->state = new_state;
 		spin_unlock(lock);
-		return;
+		return 0;
+	}
+	if (newstate == FL_PM_SUSPENDED) {
+		spin_unlock(lock);
+		return -EAGAIN;
 	}
 	set_current_state(TASK_UNINTERRUPTIBLE);
 	add_wait_queue(wq, &wait);






More information about the linux-mtd mailing list