aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2012-04-15 06:27:33 -0400
committerWim Van Sebroeck <wim@iguana.be>2012-05-23 10:16:43 -0400
commitae21cc20a604b45e97d0cdbce7e9302ce7dd7d5c (patch)
tree98227beedb9dd62067d9daeb412b75852e6243df /drivers/watchdog
parent065e8238302b630046ba3621943907cf509e78dd (diff)
watchdog: ar7_wdt.c: use devm_request_and_ioremap
Combine request_region and ioremap into devm_request_and_ioremap. This has the effect of fixing a missing iounmap on the failure of clk_get. This also introduces a call to clk_put and clears the vbus_clk variable in the case of failure or device removal. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/ar7_wdt.c33
1 files changed, 10 insertions, 23 deletions
diff --git a/drivers/watchdog/ar7_wdt.c b/drivers/watchdog/ar7_wdt.c
index 639ae9a23fbc..dc30dbd21cf1 100644
--- a/drivers/watchdog/ar7_wdt.c
+++ b/drivers/watchdog/ar7_wdt.c
@@ -282,29 +282,19 @@ static int __devinit ar7_wdt_probe(struct platform_device *pdev)
282 platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); 282 platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
283 if (!ar7_regs_wdt) { 283 if (!ar7_regs_wdt) {
284 pr_err("could not get registers resource\n"); 284 pr_err("could not get registers resource\n");
285 rc = -ENODEV; 285 return -ENODEV;
286 goto out;
287 }
288
289 if (!request_mem_region(ar7_regs_wdt->start,
290 resource_size(ar7_regs_wdt), LONGNAME)) {
291 pr_warn("watchdog I/O region busy\n");
292 rc = -EBUSY;
293 goto out;
294 } 286 }
295 287
296 ar7_wdt = ioremap(ar7_regs_wdt->start, resource_size(ar7_regs_wdt)); 288 ar7_wdt = devm_request_and_ioremap(&pdev->dev, ar7_regs_wdt);
297 if (!ar7_wdt) { 289 if (!ar7_wdt) {
298 pr_err("could not ioremap registers\n"); 290 pr_err("could not ioremap registers\n");
299 rc = -ENXIO; 291 return -ENXIO;
300 goto out_mem_region;
301 } 292 }
302 293
303 vbus_clk = clk_get(NULL, "vbus"); 294 vbus_clk = clk_get(NULL, "vbus");
304 if (IS_ERR(vbus_clk)) { 295 if (IS_ERR(vbus_clk)) {
305 pr_err("could not get vbus clock\n"); 296 pr_err("could not get vbus clock\n");
306 rc = PTR_ERR(vbus_clk); 297 return PTR_ERR(vbus_clk);
307 goto out_mem_region;
308 } 298 }
309 299
310 ar7_wdt_disable_wdt(); 300 ar7_wdt_disable_wdt();
@@ -314,24 +304,21 @@ static int __devinit ar7_wdt_probe(struct platform_device *pdev)
314 rc = misc_register(&ar7_wdt_miscdev); 304 rc = misc_register(&ar7_wdt_miscdev);
315 if (rc) { 305 if (rc) {
316 pr_err("unable to register misc device\n"); 306 pr_err("unable to register misc device\n");
317 goto out_alloc; 307 goto out;
318 } 308 }
319 goto out; 309 return 0;
320 310
321out_alloc:
322 iounmap(ar7_wdt);
323out_mem_region:
324 release_mem_region(ar7_regs_wdt->start, resource_size(ar7_regs_wdt));
325out: 311out:
312 clk_put(vbus_clk);
313 vbus_clk = NULL;
326 return rc; 314 return rc;
327} 315}
328 316
329static int __devexit ar7_wdt_remove(struct platform_device *pdev) 317static int __devexit ar7_wdt_remove(struct platform_device *pdev)
330{ 318{
331 misc_deregister(&ar7_wdt_miscdev); 319 misc_deregister(&ar7_wdt_miscdev);
332 iounmap(ar7_wdt); 320 clk_put(vbus_clk);
333 release_mem_region(ar7_regs_wdt->start, resource_size(ar7_regs_wdt)); 321 vbus_clk = NULL;
334
335 return 0; 322 return 0;
336} 323}
337 324