summaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/omap_wdt.c
diff options
context:
space:
mode:
authorAaro Koskinen <aaro.koskinen@iki.fi>2012-10-10 23:23:33 +0300
committerWim Van Sebroeck <wim@iguana.be>2012-12-19 22:24:56 +0100
commit4f4753d96d30cf4477eafa077ae7f1326a80c1d8 (patch)
tree23ee018d90941a9ec6ff996d79d3aa216bf90fb0 /drivers/watchdog/omap_wdt.c
parent67c0f55468443ef8a1edc6ee92f9a92e4915be24 (diff)
downloadop-kernel-dev-4f4753d96d30cf4477eafa077ae7f1326a80c1d8.zip
op-kernel-dev-4f4753d96d30cf4477eafa077ae7f1326a80c1d8.tar.gz
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/watchdog/omap_wdt.c')
-rw-r--r--drivers/watchdog/omap_wdt.c50
1 files changed, 13 insertions, 37 deletions
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 89db92d..2a6c434 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)
u32 rs;
int ret;
- omap_wdt = kzalloc(sizeof(*omap_wdt), GFP_KERNEL);
+ omap_wdt = devm_kzalloc(&pdev->dev, sizeof(*omap_wdt), GFP_KERNEL);
if (!omap_wdt)
return -ENOMEM;
/* reserve static register mappings */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- ret = -ENOENT;
- goto err_get_resource;
- }
+ if (!res)
+ return -ENOENT;
- mem = request_mem_region(res->start, resource_size(res), pdev->name);
- if (!mem) {
- ret = -EBUSY;
- goto err_busy;
- }
+ mem = devm_request_mem_region(&pdev->dev, res->start,
+ resource_size(res), pdev->name);
+ if (!mem)
+ return -EBUSY;
- wdev = kzalloc(sizeof(struct omap_wdt_dev), GFP_KERNEL);
- if (!wdev) {
- ret = -ENOMEM;
- goto err_kzalloc;
- }
+ wdev = devm_kzalloc(&pdev->dev, sizeof(*wdev), GFP_KERNEL);
+ if (!wdev)
+ return -ENOMEM;
wdev->omap_wdt_users = false;
wdev->mem = mem;
@@ -237,11 +232,9 @@ static int omap_wdt_probe(struct platform_device *pdev)
wdev->wdt_trgr_pattern = 0x1234;
mutex_init(&wdev->lock);
- wdev->base = ioremap(res->start, resource_size(res));
- if (!wdev->base) {
- ret = -ENOMEM;
- goto err_ioremap;
- }
+ wdev->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
+ if (!wdev->base)
+ return -ENOMEM;
omap_wdt->info = &omap_wdt_info;
omap_wdt->ops = &omap_wdt_ops;
@@ -286,18 +279,7 @@ static int omap_wdt_probe(struct platform_device *pdev)
err_register:
pm_runtime_disable(wdev->dev);
platform_set_drvdata(pdev, NULL);
- iounmap(wdev->base);
-
-err_ioremap:
- wdev->base = NULL;
- kfree(wdev);
-
-err_kzalloc:
- release_mem_region(res->start, resource_size(res));
-err_busy:
-err_get_resource:
- kfree(omap_wdt);
return ret;
}
@@ -322,14 +304,8 @@ static int omap_wdt_remove(struct platform_device *pdev)
pm_runtime_disable(wdev->dev);
watchdog_unregister_device(wdog);
- release_mem_region(res->start, resource_size(res));
platform_set_drvdata(pdev, NULL);
- iounmap(wdev->base);
-
- kfree(wdev);
- kfree(wdog);
-
return 0;
}
OpenPOWER on IntegriCloud