diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2013-01-31 04:03:22 -0500 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2013-02-06 01:13:57 -0500 |
commit | b2bbc6a2ace78eaca2f6482b58b984519aa783ac (patch) | |
tree | 1273d37753c5eaffde6f8627dd432a6299c9c5d7 /drivers/thermal | |
parent | f8f53e1874c2dfddf4c6dc69008ba85d6de4d944 (diff) |
thermal: rcar: use mutex lock instead of spin lock
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>
Diffstat (limited to 'drivers/thermal')
-rw-r--r-- | drivers/thermal/rcar_thermal.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 068b2a1c5c15..e19b267f76d6 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c | |||
@@ -42,7 +42,7 @@ | |||
42 | struct rcar_thermal_priv { | 42 | struct rcar_thermal_priv { |
43 | void __iomem *base; | 43 | void __iomem *base; |
44 | struct device *dev; | 44 | struct device *dev; |
45 | spinlock_t lock; | 45 | struct mutex lock; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | #define MCELSIUS(temp) ((temp) * 1000) | 48 | #define MCELSIUS(temp) ((temp) * 1000) |
@@ -54,46 +54,26 @@ struct rcar_thermal_priv { | |||
54 | */ | 54 | */ |
55 | static u32 rcar_thermal_read(struct rcar_thermal_priv *priv, u32 reg) | 55 | static u32 rcar_thermal_read(struct rcar_thermal_priv *priv, u32 reg) |
56 | { | 56 | { |
57 | unsigned long flags; | 57 | return ioread32(priv->base + reg); |
58 | u32 ret; | ||
59 | |||
60 | spin_lock_irqsave(&priv->lock, flags); | ||
61 | |||
62 | ret = ioread32(priv->base + reg); | ||
63 | |||
64 | spin_unlock_irqrestore(&priv->lock, flags); | ||
65 | |||
66 | return ret; | ||
67 | } | 58 | } |
68 | 59 | ||
69 | #if 0 /* no user at this point */ | 60 | #if 0 /* no user at this point */ |
70 | static void rcar_thermal_write(struct rcar_thermal_priv *priv, | 61 | static void rcar_thermal_write(struct rcar_thermal_priv *priv, |
71 | u32 reg, u32 data) | 62 | u32 reg, u32 data) |
72 | { | 63 | { |
73 | unsigned long flags; | ||
74 | |||
75 | spin_lock_irqsave(&priv->lock, flags); | ||
76 | |||
77 | iowrite32(data, priv->base + reg); | 64 | iowrite32(data, priv->base + reg); |
78 | |||
79 | spin_unlock_irqrestore(&priv->lock, flags); | ||
80 | } | 65 | } |
81 | #endif | 66 | #endif |
82 | 67 | ||
83 | static void rcar_thermal_bset(struct rcar_thermal_priv *priv, u32 reg, | 68 | static void rcar_thermal_bset(struct rcar_thermal_priv *priv, u32 reg, |
84 | u32 mask, u32 data) | 69 | u32 mask, u32 data) |
85 | { | 70 | { |
86 | unsigned long flags; | ||
87 | u32 val; | 71 | u32 val; |
88 | 72 | ||
89 | spin_lock_irqsave(&priv->lock, flags); | ||
90 | |||
91 | val = ioread32(priv->base + reg); | 73 | val = ioread32(priv->base + reg); |
92 | val &= ~mask; | 74 | val &= ~mask; |
93 | val |= (data & mask); | 75 | val |= (data & mask); |
94 | iowrite32(val, priv->base + reg); | 76 | iowrite32(val, priv->base + reg); |
95 | |||
96 | spin_unlock_irqrestore(&priv->lock, flags); | ||
97 | } | 77 | } |
98 | 78 | ||
99 | /* | 79 | /* |
@@ -107,6 +87,8 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, | |||
107 | int i; | 87 | int i; |
108 | int ctemp, old, new; | 88 | int ctemp, old, new; |
109 | 89 | ||
90 | mutex_lock(&priv->lock); | ||
91 | |||
110 | /* | 92 | /* |
111 | * TSC decides a value of CPTAP automatically, | 93 | * TSC decides a value of CPTAP automatically, |
112 | * and this is the conditions which validate interrupt. | 94 | * and this is the conditions which validate interrupt. |
@@ -138,6 +120,8 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, | |||
138 | 120 | ||
139 | *temp = MCELSIUS((ctemp * 5) - 65); | 121 | *temp = MCELSIUS((ctemp * 5) - 65); |
140 | 122 | ||
123 | mutex_unlock(&priv->lock); | ||
124 | |||
141 | return 0; | 125 | return 0; |
142 | } | 126 | } |
143 | 127 | ||
@@ -225,7 +209,7 @@ static int rcar_thermal_probe(struct platform_device *pdev) | |||
225 | } | 209 | } |
226 | 210 | ||
227 | priv->dev = &pdev->dev; | 211 | priv->dev = &pdev->dev; |
228 | spin_lock_init(&priv->lock); | 212 | mutex_init(&priv->lock); |
229 | priv->base = devm_ioremap_nocache(&pdev->dev, | 213 | priv->base = devm_ioremap_nocache(&pdev->dev, |
230 | res->start, resource_size(res)); | 214 | res->start, resource_size(res)); |
231 | if (!priv->base) { | 215 | if (!priv->base) { |