rk30: tsadc: add mutex to protect rk30_tsadc_get
author黄涛 <huangtao@rock-chips.com>
Fri, 20 Apr 2012 06:58:07 +0000 (14:58 +0800)
committer黄涛 <huangtao@rock-chips.com>
Fri, 20 Apr 2012 06:58:07 +0000 (14:58 +0800)
arch/arm/mach-rk30/tsadc.c

index 86794765ad801cdef7a3a19c927c1e9437076c98..702d816bf09c1bd7e45dfadcedf055ddf892e993 100644 (file)
@@ -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)