From a244485d7689730606f626075fa8d5e9bd4c94f4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=BB=84=E6=B6=9B?= Date: Fri, 20 Apr 2012 14:58:07 +0800 Subject: [PATCH] rk30: tsadc: add mutex to protect rk30_tsadc_get --- arch/arm/mach-rk30/tsadc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/mach-rk30/tsadc.c b/arch/arm/mach-rk30/tsadc.c index 86794765ad80..702d816bf09c 100644 --- a/arch/arm/mach-rk30/tsadc.c +++ b/arch/arm/mach-rk30/tsadc.c @@ -106,6 +106,7 @@ static void tsadc_writel(u32 val, u32 offset) writel_relaxed(val, g_dev->regs + offset); } +static DEFINE_MUTEX(tsadc_mutex); static void rk30_tsadc_get(unsigned int chn, int *temp, int *code) { *temp = 0; @@ -114,6 +115,8 @@ static void rk30_tsadc_get(unsigned int chn, int *temp, int *code) if (!g_dev || chn > 1) return; + mutex_lock(&tsadc_mutex); + clk_enable(g_dev->pclk); clk_enable(g_dev->clk); @@ -135,6 +138,8 @@ static void rk30_tsadc_get(unsigned int chn, int *temp, int *code) clk_disable(g_dev->clk); clk_disable(g_dev->pclk); + + mutex_unlock(&tsadc_mutex); } int rk30_tsadc_get_temp(unsigned int chn) -- 2.34.1