[MTD] NAND Initialize controller lock and wq only once

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Thu May 25 08:59:04 EDT 2006


Commit:     04bbd0eafb0c733c6c7f5d63c5098c615fe0685a
Parent:     8b9e9fe8c6ee354aa75dc5a33e1575b21aa52084
Author:     Thomas Gleixner <tglx at cruncher.tec.linutronix.de>
AuthorDate: Thu May 25 09:45:29 2006 +0200
Commit:     David Woodhouse <dwmw2 at infradead.org>
CommitDate: Thu May 25 12:45:26 2006 +0100

    [MTD] NAND Initialize controller lock and wq only once
    
    The lock simplifying patch did not move the lock and waitqueue
    initialization into the controller allocation patch.
    This reinitializes waitqueue and spinlocks also for driver
    supplied controller stuctures. Move it into the allocation path.
    
    Signed-off-by: Thomas Gleixner <tglx at linutronix.de>

 drivers/mtd/nand/nand_base.c |    7 ++++---
 drivers/mtd/nand/ndfc.c      |    6 +++++-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 5690de2..61b2363 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2125,6 +2125,9 @@ static int nand_allocate_kmem(struct mtd
 					   GFP_KERNEL);
 		if (!chip->controller)
 			goto outerr;
+
+		spin_lock_init(&chip->controller->lock);
+		init_waitqueue_head(&chip->controller->wq);
 		chip->options |= NAND_CONTROLLER_ALLOC;
 	}
 	return 0;
@@ -2451,10 +2454,8 @@ int nand_scan(struct mtd_info *mtd, int 
 		BUG();
 	}
 
-	/* Initialize state, waitqueue and spinlock */
+	/* Initialize state */
 	chip->state = FL_READY;
-	init_waitqueue_head(&chip->controller->wq);
-	spin_lock_init(&chip->controller->lock);
 
 	/* De-select the device */
 	chip->select_chip(mtd, -1);
diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index 481541a..4d70dd1 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -293,8 +293,12 @@ static struct platform_driver ndfc_nand_
 
 static int __init ndfc_nand_init(void)
 {
-	int ret = platform_driver_register(&ndfc_nand_driver);
+	int ret;
 
+	spin_lock_init(&ndfc_ctrl.ndfc_control.lock);
+	init_waitqueue_head(&ndfc_ctrl.ndfc_control.wq);
+
+	ret = platform_driver_register(&ndfc_nand_driver);
 	if (!ret)
 		ret = platform_driver_register(&ndfc_chip_driver);
 	return ret;



More information about the linux-mtd-cvs mailing list