diff options
author | Aaro Koskinen <aaro.koskinen@iki.fi> | 2012-10-10 16:23:33 -0400 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2012-12-19 16:24:56 -0500 |
commit | 4f4753d96d30cf4477eafa077ae7f1326a80c1d8 (patch) | |
tree | 23ee018d90941a9ec6ff996d79d3aa216bf90fb0 /drivers | |
parent | 67c0f55468443ef8a1edc6ee92f9a92e4915be24 (diff) |
watchdog: omap_wdt: convert to devm_ functions
Use devm_kzalloc(), devm_request_mem_region() ande devm_ioremap()
to simplify the code.
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/watchdog/omap_wdt.c | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c index 89db92d10ade..2a6c434cd741 100644 --- a/drivers/watchdog/omap_wdt.c +++ b/drivers/watchdog/omap_wdt.c | |||
@@ -208,28 +208,23 @@ static int omap_wdt_probe(struct platform_device *pdev) | |||
208 | u32 rs; | 208 | u32 rs; |
209 | int ret; | 209 | int ret; |
210 | 210 | ||
211 | omap_wdt = kzalloc(sizeof(*omap_wdt), GFP_KERNEL); | 211 | omap_wdt = devm_kzalloc(&pdev->dev, sizeof(*omap_wdt), GFP_KERNEL); |
212 | if (!omap_wdt) | 212 | if (!omap_wdt) |
213 | return -ENOMEM; | 213 | return -ENOMEM; |
214 | 214 | ||
215 | /* reserve static register mappings */ | 215 | /* reserve static register mappings */ |
216 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 216 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
217 | if (!res) { | 217 | if (!res) |
218 | ret = -ENOENT; | 218 | return -ENOENT; |
219 | goto err_get_resource; | ||
220 | } | ||
221 | 219 | ||
222 | mem = request_mem_region(res->start, resource_size(res), pdev->name); | 220 | mem = devm_request_mem_region(&pdev->dev, res->start, |
223 | if (!mem) { | 221 | resource_size(res), pdev->name); |
224 | ret = -EBUSY; | 222 | if (!mem) |
225 | goto err_busy; | 223 | return -EBUSY; |
226 | } | ||
227 | 224 | ||
228 | wdev = kzalloc(sizeof(struct omap_wdt_dev), GFP_KERNEL); | 225 | wdev = devm_kzalloc(&pdev->dev, sizeof(*wdev), GFP_KERNEL); |
229 | if (!wdev) { | 226 | if (!wdev) |
230 | ret = -ENOMEM; | 227 | return -ENOMEM; |
231 | goto err_kzalloc; | ||
232 | } | ||
233 | 228 | ||
234 | wdev->omap_wdt_users = false; | 229 | wdev->omap_wdt_users = false; |
235 | wdev->mem = mem; | 230 | wdev->mem = mem; |
@@ -237,11 +232,9 @@ static int omap_wdt_probe(struct platform_device *pdev) | |||
237 | wdev->wdt_trgr_pattern = 0x1234; | 232 | wdev->wdt_trgr_pattern = 0x1234; |
238 | mutex_init(&wdev->lock); | 233 | mutex_init(&wdev->lock); |
239 | 234 | ||
240 | wdev->base = ioremap(res->start, resource_size(res)); | 235 | wdev->base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); |
241 | if (!wdev->base) { | 236 | if (!wdev->base) |
242 | ret = -ENOMEM; | 237 | return -ENOMEM; |
243 | goto err_ioremap; | ||
244 | } | ||
245 | 238 | ||
246 | omap_wdt->info = &omap_wdt_info; | 239 | omap_wdt->info = &omap_wdt_info; |
247 | omap_wdt->ops = &omap_wdt_ops; | 240 | omap_wdt->ops = &omap_wdt_ops; |
@@ -286,18 +279,7 @@ static int omap_wdt_probe(struct platform_device *pdev) | |||
286 | err_register: | 279 | err_register: |
287 | pm_runtime_disable(wdev->dev); | 280 | pm_runtime_disable(wdev->dev); |
288 | platform_set_drvdata(pdev, NULL); | 281 | platform_set_drvdata(pdev, NULL); |
289 | iounmap(wdev->base); | ||
290 | |||
291 | err_ioremap: | ||
292 | wdev->base = NULL; | ||
293 | kfree(wdev); | ||
294 | |||
295 | err_kzalloc: | ||
296 | release_mem_region(res->start, resource_size(res)); | ||
297 | 282 | ||
298 | err_busy: | ||
299 | err_get_resource: | ||
300 | kfree(omap_wdt); | ||
301 | return ret; | 283 | return ret; |
302 | } | 284 | } |
303 | 285 | ||
@@ -322,14 +304,8 @@ static int omap_wdt_remove(struct platform_device *pdev) | |||
322 | 304 | ||
323 | pm_runtime_disable(wdev->dev); | 305 | pm_runtime_disable(wdev->dev); |
324 | watchdog_unregister_device(wdog); | 306 | watchdog_unregister_device(wdog); |
325 | release_mem_region(res->start, resource_size(res)); | ||
326 | platform_set_drvdata(pdev, NULL); | 307 | platform_set_drvdata(pdev, NULL); |
327 | 308 | ||
328 | iounmap(wdev->base); | ||
329 | |||
330 | kfree(wdev); | ||
331 | kfree(wdog); | ||
332 | |||
333 | return 0; | 309 | return 0; |
334 | } | 310 | } |
335 | 311 | ||