[MTD] NAND Initialize controller lock and wq only once
authorThomas Gleixner <tglx@cruncher.tec.linutronix.de>
Thu, 25 May 2006 07:45:29 +0000 (09:45 +0200)
committerDavid Woodhouse <dwmw2@infradead.org>
Thu, 25 May 2006 11:45:26 +0000 (12:45 +0100)
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@linutronix.de>
drivers/mtd/nand/nand_base.c
drivers/mtd/nand/ndfc.c

index 5690de223c114b8478a4c0b8ff1044ac7823bef8..61b2363f9324a36429f70730685255062b1c7b4a 100644 (file)
@@ -2125,6 +2125,9 @@ static int nand_allocate_kmem(struct mtd_info *mtd, struct nand_chip *chip)
                                           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 maxchips)
                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);
index 481541a683ca8764a7129a964c37acc574c5678a..4d70dd16cf5d00976e0c6a73fd9bd9a6c82bf173 100644 (file)
@@ -293,8 +293,12 @@ static struct platform_driver ndfc_nand_driver = {
 
 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;