Commit 4f4753d9 authored by Aaro Koskinen's avatar Aaro Koskinen Committed by Wim Van Sebroeck

watchdog: omap_wdt: convert to devm_ functions

Use devm_kzalloc(), devm_request_mem_region() ande devm_ioremap()
to simplify the code.
Signed-off-by: default avatarAaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent 67c0f554
...@@ -208,28 +208,23 @@ static int omap_wdt_probe(struct platform_device *pdev) ...@@ -208,28 +208,23 @@ static int omap_wdt_probe(struct platform_device *pdev)
u32 rs; u32 rs;
int ret; int ret;
omap_wdt = kzalloc(sizeof(*omap_wdt), GFP_KERNEL); omap_wdt = devm_kzalloc(&pdev->dev, sizeof(*omap_wdt), GFP_KERNEL);
if (!omap_wdt) if (!omap_wdt)
return -ENOMEM; return -ENOMEM;
/* reserve static register mappings */ /* reserve static register mappings */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { if (!res)
ret = -ENOENT; return -ENOENT;
goto err_get_resource;
}
mem = request_mem_region(res->start, resource_size(res), pdev->name); mem = devm_request_mem_region(&pdev->dev, res->start,
if (!mem) { resource_size(res), pdev->name);
ret = -EBUSY; if (!mem)
goto err_busy; return -EBUSY;
}
wdev = kzalloc(sizeof(struct omap_wdt_dev), GFP_KERNEL); wdev = devm_kzalloc(&pdev->dev, sizeof(*wdev), GFP_KERNEL);
if (!wdev) { if (!wdev)
ret = -ENOMEM; return -ENOMEM;
goto err_kzalloc;
}
wdev->omap_wdt_users = false; wdev->omap_wdt_users = false;
wdev->mem = mem; wdev->mem = mem;
...@@ -237,11 +232,9 @@ static int omap_wdt_probe(struct platform_device *pdev) ...@@ -237,11 +232,9 @@ static int omap_wdt_probe(struct platform_device *pdev)
wdev->wdt_trgr_pattern = 0x1234; wdev->wdt_trgr_pattern = 0x1234;
mutex_init(&wdev->lock); mutex_init(&wdev->lock);
wdev->base = ioremap(res->start, resource_size(res)); wdev->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
if (!wdev->base) { if (!wdev->base)
ret = -ENOMEM; return -ENOMEM;
goto err_ioremap;
}
omap_wdt->info = &omap_wdt_info; omap_wdt->info = &omap_wdt_info;
omap_wdt->ops = &omap_wdt_ops; omap_wdt->ops = &omap_wdt_ops;
...@@ -286,18 +279,7 @@ static int omap_wdt_probe(struct platform_device *pdev) ...@@ -286,18 +279,7 @@ static int omap_wdt_probe(struct platform_device *pdev)
err_register: err_register:
pm_runtime_disable(wdev->dev); pm_runtime_disable(wdev->dev);
platform_set_drvdata(pdev, NULL); 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; return ret;
} }
...@@ -322,14 +304,8 @@ static int omap_wdt_remove(struct platform_device *pdev) ...@@ -322,14 +304,8 @@ static int omap_wdt_remove(struct platform_device *pdev)
pm_runtime_disable(wdev->dev); pm_runtime_disable(wdev->dev);
watchdog_unregister_device(wdog); watchdog_unregister_device(wdog);
release_mem_region(res->start, resource_size(res));
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
iounmap(wdev->base);
kfree(wdev);
kfree(wdog);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment