From 08d79c253d42d1d7fe5e7ee27eb18ba09957e91b Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 28 Jan 2011 13:49:27 -0800 Subject: [PATCH] ARM: tegra: stingray: Prevent double-enables in the panel regulator Change-Id: I33bd9b4acfc501a346d65d1575398a621eb2a4b6 Signed-off-by: Colin Cross --- arch/arm/mach-tegra/board-stingray-panel.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-tegra/board-stingray-panel.c b/arch/arm/mach-tegra/board-stingray-panel.c index 1a66d9827fdf..c4df1e3178a2 100644 --- a/arch/arm/mach-tegra/board-stingray-panel.c +++ b/arch/arm/mach-tegra/board-stingray-panel.c @@ -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; } -- 2.34.1