ARM: tegra: stingray: Prevent double-enables in the panel regulator
authorColin Cross <ccross@android.com>
Fri, 28 Jan 2011 21:49:27 +0000 (13:49 -0800)
committerColin Cross <ccross@android.com>
Fri, 28 Jan 2011 21:49:27 +0000 (13:49 -0800)
Change-Id: I33bd9b4acfc501a346d65d1575398a621eb2a4b6
Signed-off-by: Colin Cross <ccross@android.com>
arch/arm/mach-tegra/board-stingray-panel.c

index 1a66d9827fdfa2a0d39326c64cc98c12c5b32e7d..c4df1e3178a2f2989951ed2096c0309abd3741c5 100644 (file)
@@ -220,14 +220,23 @@ static DECLARE_DELAYED_WORK(stingray_panel_early_reg_disable_work,
 
 static void stingray_panel_early_reg_enable(struct work_struct *work)
 {
-       stingray_panel_enable();
+       /*
+        * If the regulator was previously enabled, the work function to
+        * disable the work will be pending, cancel_delayed_work_sync
+        * will return true, and the regulator will not get enabled again.
+        */
+       if (!cancel_delayed_work_sync(&stingray_panel_early_reg_disable_work))
+               stingray_panel_enable();
 
        /*
-        * Once the panel is powered up, set it to power down in 1 second.
+        * After the cancel_delay_work_sync, there is no outstanding work
+        * to disable the regulator, so queue the disable in 1 second.
         * If no other driver calls regulator_enable on stingray_panel_regulator
         * before 1 second has elapsed, the bridge chip will power down.
         */
-       schedule_delayed_work(&stingray_panel_early_reg_disable_work, HZ);
+       queue_delayed_work(system_nrt_wq,
+               &stingray_panel_early_reg_disable_work,
+               msecs_to_jiffies(1000));
 }
 
 static DECLARE_WORK(stingray_panel_early_reg_enable_work,
@@ -264,7 +273,7 @@ static int stingray_panel_early_reg_power(void)
 {
        smp_rmb();
        if (stingray_panel_early_reg_in_resume)
-               schedule_work(&stingray_panel_early_reg_enable_work);
+               queue_work(system_nrt_wq, &stingray_panel_early_reg_enable_work);
 
        return 0;
 }