power management routines for NAND driver

Thomas Gleixner tglx at linutronix.de
Fri Aug 12 12:16:24 EDT 2005


On Fri, 2005-08-12 at 19:55 +0400, Vitaly Wool wrote:
> @@ -768,6 +770,11 @@
>  	active = this;
>  	spin_lock(lock);
>  
> +	if (this->state == new_state) {
> +		spin_unlock(lock);
> +		return;
> +	}
> +
>  	/* Hardware controller shared among independend devices */

Urggh. That breaks everything except FL_PM_SUSPENDED as you return for
all cases, where this->state and new_state are equal. 

You want to return 0, when the FLASH is already in suspend state ?

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 16:14:47 -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 (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);








More information about the linux-mtd mailing list