thermal: rcar: use mutex lock instead of spin lock
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 31 Jan 2013 09:03:22 +0000 (09:03 +0000)
committerZhang Rui <rui.zhang@intel.com>
Wed, 6 Feb 2013 06:13:57 +0000 (14:13 +0800)
Current R-Car thermal driver is using spin lock for each
registers read/write, but it is pointless lock.
This lock is required while reading temperature,
but it needs long wait (= 300ms).
So, this patch used mutex lock while reading temperature,
instead of spin lock for each registers.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
drivers/thermal/rcar_thermal.c

index 068b2a1c5c159b42b5a08b1dbf22a3b0b6df8fbc..e19b267f76d6ec5389130015d41a04ecb3842a23 100644 (file)
@@ -42,7 +42,7 @@
 struct rcar_thermal_priv {
        void __iomem *base;
        struct device *dev;
-       spinlock_t lock;
+       struct mutex lock;
 };
 
 #define MCELSIUS(temp)                 ((temp) * 1000)
@@ -54,46 +54,26 @@ struct rcar_thermal_priv {
  */
 static u32 rcar_thermal_read(struct rcar_thermal_priv *priv, u32 reg)
 {
-       unsigned long flags;
-       u32 ret;
-
-       spin_lock_irqsave(&priv->lock, flags);
-
-       ret = ioread32(priv->base + reg);
-
-       spin_unlock_irqrestore(&priv->lock, flags);
-
-       return ret;
+       return ioread32(priv->base + reg);
 }
 
 #if 0 /* no user at this point */
 static void rcar_thermal_write(struct rcar_thermal_priv *priv,
                               u32 reg, u32 data)
 {
-       unsigned long flags;
-
-       spin_lock_irqsave(&priv->lock, flags);
-
        iowrite32(data, priv->base + reg);
-
-       spin_unlock_irqrestore(&priv->lock, flags);
 }
 #endif
 
 static void rcar_thermal_bset(struct rcar_thermal_priv *priv, u32 reg,
                              u32 mask, u32 data)
 {
-       unsigned long flags;
        u32 val;
 
-       spin_lock_irqsave(&priv->lock, flags);
-
        val = ioread32(priv->base + reg);
        val &= ~mask;
        val |= (data & mask);
        iowrite32(val, priv->base + reg);
-
-       spin_unlock_irqrestore(&priv->lock, flags);
 }
 
 /*
@@ -107,6 +87,8 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
        int i;
        int ctemp, old, new;
 
+       mutex_lock(&priv->lock);
+
        /*
         * TSC decides a value of CPTAP automatically,
         * and this is the conditions which validate interrupt.
@@ -138,6 +120,8 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
 
        *temp = MCELSIUS((ctemp * 5) - 65);
 
+       mutex_unlock(&priv->lock);
+
        return 0;
 }
 
@@ -225,7 +209,7 @@ static int rcar_thermal_probe(struct platform_device *pdev)
        }
 
        priv->dev = &pdev->dev;
-       spin_lock_init(&priv->lock);
+       mutex_init(&priv->lock);
        priv->base = devm_ioremap_nocache(&pdev->dev,
                                          res->start, resource_size(res));
        if (!priv->base) {
This page took 0.025917 seconds and 5 git commands to generate.