summaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2013-05-02 14:52:16 +0900
committerWim Van Sebroeck <wim@iguana.be>2013-07-11 20:58:02 +0200
commit9d8a7f16f47fca776b60ab63901dc8481ceb6e1f (patch)
tree327f3b5de268fa90c0bd82ab8fc1608543766694 /drivers/watchdog
parentb94828ffb2261a9803948ccd74f2b75105b1bf87 (diff)
downloadop-kernel-dev-9d8a7f16f47fca776b60ab63901dc8481ceb6e1f.zip
op-kernel-dev-9d8a7f16f47fca776b60ab63901dc8481ceb6e1f.tar.gz
watchdog: ts72xx_wdt: use devm_*() functions
Use devm_*() functions to make cleanup paths simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Acked-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/ts72xx_wdt.c67
1 files changed, 10 insertions, 57 deletions
diff --git a/drivers/watchdog/ts72xx_wdt.c b/drivers/watchdog/ts72xx_wdt.c
index b8a9245..4da59b4 100644
--- a/drivers/watchdog/ts72xx_wdt.c
+++ b/drivers/watchdog/ts72xx_wdt.c
@@ -396,7 +396,7 @@ static int ts72xx_wdt_probe(struct platform_device *pdev)
struct resource *r1, *r2;
int error = 0;
- wdt = kzalloc(sizeof(struct ts72xx_wdt), GFP_KERNEL);
+ wdt = devm_kzalloc(&pdev->dev, sizeof(struct ts72xx_wdt), GFP_KERNEL);
if (!wdt) {
dev_err(&pdev->dev, "failed to allocate memory\n");
return -ENOMEM;
@@ -405,44 +405,22 @@ static int ts72xx_wdt_probe(struct platform_device *pdev)
r1 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!r1) {
dev_err(&pdev->dev, "failed to get memory resource\n");
- error = -ENODEV;
- goto fail;
+ return -ENODEV;
}
- r1 = request_mem_region(r1->start, resource_size(r1), pdev->name);
- if (!r1) {
- dev_err(&pdev->dev, "cannot request memory region\n");
- error = -EBUSY;
- goto fail;
- }
-
- wdt->control_reg = ioremap(r1->start, resource_size(r1));
- if (!wdt->control_reg) {
- dev_err(&pdev->dev, "failed to map memory\n");
- error = -ENODEV;
- goto fail_free_control;
- }
+ wdt->control_reg = devm_ioremap_resource(&pdev->dev, r1);
+ if (IS_ERR(wdt->control_reg))
+ return PTR_ERR(wdt->control_reg);
r2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!r2) {
dev_err(&pdev->dev, "failed to get memory resource\n");
- error = -ENODEV;
- goto fail_unmap_control;
- }
-
- r2 = request_mem_region(r2->start, resource_size(r2), pdev->name);
- if (!r2) {
- dev_err(&pdev->dev, "cannot request memory region\n");
- error = -EBUSY;
- goto fail_unmap_control;
+ return -ENODEV;
}
- wdt->feed_reg = ioremap(r2->start, resource_size(r2));
- if (!wdt->feed_reg) {
- dev_err(&pdev->dev, "failed to map memory\n");
- error = -ENODEV;
- goto fail_free_feed;
- }
+ wdt->feed_reg = devm_ioremap_resource(&pdev->dev, r2);
+ if (IS_ERR(wdt->feed_reg))
+ return PTR_ERR(wdt->feed_reg);
platform_set_drvdata(pdev, wdt);
ts72xx_wdt_pdev = pdev;
@@ -455,45 +433,20 @@ static int ts72xx_wdt_probe(struct platform_device *pdev)
error = misc_register(&ts72xx_wdt_miscdev);
if (error) {
dev_err(&pdev->dev, "failed to register miscdev\n");
- goto fail_unmap_feed;
+ return error;
}
dev_info(&pdev->dev, "TS-72xx Watchdog driver\n");
return 0;
-
-fail_unmap_feed:
- platform_set_drvdata(pdev, NULL);
- iounmap(wdt->feed_reg);
-fail_free_feed:
- release_mem_region(r2->start, resource_size(r2));
-fail_unmap_control:
- iounmap(wdt->control_reg);
-fail_free_control:
- release_mem_region(r1->start, resource_size(r1));
-fail:
- kfree(wdt);
- return error;
}
static int ts72xx_wdt_remove(struct platform_device *pdev)
{
- struct ts72xx_wdt *wdt = platform_get_drvdata(pdev);
- struct resource *res;
int error;
error = misc_deregister(&ts72xx_wdt_miscdev);
- platform_set_drvdata(pdev, NULL);
-
- iounmap(wdt->feed_reg);
- res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- release_mem_region(res->start, resource_size(res));
-
- iounmap(wdt->control_reg);
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- release_mem_region(res->start, resource_size(res));
- kfree(wdt);
return error;
}
OpenPOWER on IntegriCloud