aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal/rcar_thermal.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/thermal/rcar_thermal.c')
-rw-r--r--drivers/thermal/rcar_thermal.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index f7a1b574a304..90db951725da 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -43,6 +43,9 @@ struct rcar_thermal_priv {
43 u32 comp; 43 u32 comp;
44}; 44};
45 45
46#define MCELSIUS(temp) ((temp) * 1000)
47#define rcar_zone_to_priv(zone) (zone->devdata)
48
46/* 49/*
47 * basic functions 50 * basic functions
48 */ 51 */
@@ -96,7 +99,7 @@ static void rcar_thermal_bset(struct rcar_thermal_priv *priv, u32 reg,
96static int rcar_thermal_get_temp(struct thermal_zone_device *zone, 99static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
97 unsigned long *temp) 100 unsigned long *temp)
98{ 101{
99 struct rcar_thermal_priv *priv = zone->devdata; 102 struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
100 int val, min, max, tmp; 103 int val, min, max, tmp;
101 104
102 tmp = -200; /* default */ 105 tmp = -200; /* default */
@@ -169,7 +172,7 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
169 } 172 }
170 } 173 }
171 174
172 *temp = tmp; 175 *temp = MCELSIUS(tmp);
173 return 0; 176 return 0;
174} 177}
175 178
@@ -185,7 +188,6 @@ static int rcar_thermal_probe(struct platform_device *pdev)
185 struct thermal_zone_device *zone; 188 struct thermal_zone_device *zone;
186 struct rcar_thermal_priv *priv; 189 struct rcar_thermal_priv *priv;
187 struct resource *res; 190 struct resource *res;
188 int ret;
189 191
190 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 192 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
191 if (!res) { 193 if (!res) {
@@ -206,16 +208,14 @@ static int rcar_thermal_probe(struct platform_device *pdev)
206 res->start, resource_size(res)); 208 res->start, resource_size(res));
207 if (!priv->base) { 209 if (!priv->base) {
208 dev_err(&pdev->dev, "Unable to ioremap thermal register\n"); 210 dev_err(&pdev->dev, "Unable to ioremap thermal register\n");
209 ret = -ENOMEM; 211 return -ENOMEM;
210 goto error_free_priv;
211 } 212 }
212 213
213 zone = thermal_zone_device_register("rcar_thermal", 0, 0, priv, 214 zone = thermal_zone_device_register("rcar_thermal", 0, 0, priv,
214 &rcar_thermal_zone_ops, 0, 0); 215 &rcar_thermal_zone_ops, NULL, 0, 0);
215 if (IS_ERR(zone)) { 216 if (IS_ERR(zone)) {
216 dev_err(&pdev->dev, "thermal zone device is NULL\n"); 217 dev_err(&pdev->dev, "thermal zone device is NULL\n");
217 ret = PTR_ERR(zone); 218 return PTR_ERR(zone);
218 goto error_iounmap;
219 } 219 }
220 220
221 platform_set_drvdata(pdev, zone); 221 platform_set_drvdata(pdev, zone);
@@ -223,26 +223,15 @@ static int rcar_thermal_probe(struct platform_device *pdev)
223 dev_info(&pdev->dev, "proved\n"); 223 dev_info(&pdev->dev, "proved\n");
224 224
225 return 0; 225 return 0;
226
227error_iounmap:
228 devm_iounmap(&pdev->dev, priv->base);
229error_free_priv:
230 devm_kfree(&pdev->dev, priv);
231
232 return ret;
233} 226}
234 227
235static int rcar_thermal_remove(struct platform_device *pdev) 228static int rcar_thermal_remove(struct platform_device *pdev)
236{ 229{
237 struct thermal_zone_device *zone = platform_get_drvdata(pdev); 230 struct thermal_zone_device *zone = platform_get_drvdata(pdev);
238 struct rcar_thermal_priv *priv = zone->devdata;
239 231
240 thermal_zone_device_unregister(zone); 232 thermal_zone_device_unregister(zone);
241 platform_set_drvdata(pdev, NULL); 233 platform_set_drvdata(pdev, NULL);
242 234
243 devm_iounmap(&pdev->dev, priv->base);
244 devm_kfree(&pdev->dev, priv);
245
246 return 0; 235 return 0;
247} 236}
248 237