Commit e20880e6 authored by Kumar, Anil's avatar Kumar, Anil Committed by Wim Van Sebroeck

watchdog: davinci_wdt: update to devm_* API

Update the code to use devm_* API so that driver
core will manage resources.
Signed-off-by: default avatarKumar, Anil <anilkumar.v@ti.com>
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent 362ce5ae
...@@ -69,7 +69,6 @@ static unsigned long wdt_status; ...@@ -69,7 +69,6 @@ static unsigned long wdt_status;
#define WDT_REGION_INITED 2 #define WDT_REGION_INITED 2
#define WDT_DEVICE_INITED 3 #define WDT_DEVICE_INITED 3
static struct resource *wdt_mem;
static void __iomem *wdt_base; static void __iomem *wdt_base;
struct clk *wdt_clk; struct clk *wdt_clk;
...@@ -201,8 +200,9 @@ static struct miscdevice davinci_wdt_miscdev = { ...@@ -201,8 +200,9 @@ static struct miscdevice davinci_wdt_miscdev = {
static int davinci_wdt_probe(struct platform_device *pdev) static int davinci_wdt_probe(struct platform_device *pdev)
{ {
int ret = 0, size; int ret = 0;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct resource *wdt_mem;
wdt_clk = devm_clk_get(dev, NULL); wdt_clk = devm_clk_get(dev, NULL);
if (WARN_ON(IS_ERR(wdt_clk))) if (WARN_ON(IS_ERR(wdt_clk)))
...@@ -221,41 +221,25 @@ static int davinci_wdt_probe(struct platform_device *pdev) ...@@ -221,41 +221,25 @@ static int davinci_wdt_probe(struct platform_device *pdev)
return -ENOENT; return -ENOENT;
} }
size = resource_size(wdt_mem); wdt_base = devm_request_and_ioremap(dev, wdt_mem);
if (!request_mem_region(wdt_mem->start, size, pdev->name)) {
dev_err(dev, "failed to get memory region\n");
return -ENOENT;
}
wdt_base = ioremap(wdt_mem->start, size);
if (!wdt_base) { if (!wdt_base) {
dev_err(dev, "failed to map memory region\n"); dev_err(dev, "ioremap failed\n");
release_mem_region(wdt_mem->start, size); return -EADDRNOTAVAIL;
wdt_mem = NULL;
return -ENOMEM;
} }
ret = misc_register(&davinci_wdt_miscdev); ret = misc_register(&davinci_wdt_miscdev);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "cannot register misc device\n"); dev_err(dev, "cannot register misc device\n");
release_mem_region(wdt_mem->start, size);
wdt_mem = NULL;
} else { } else {
set_bit(WDT_DEVICE_INITED, &wdt_status); set_bit(WDT_DEVICE_INITED, &wdt_status);
} }
iounmap(wdt_base);
return ret; return ret;
} }
static int davinci_wdt_remove(struct platform_device *pdev) static int davinci_wdt_remove(struct platform_device *pdev)
{ {
misc_deregister(&davinci_wdt_miscdev); misc_deregister(&davinci_wdt_miscdev);
if (wdt_mem) {
release_mem_region(wdt_mem->start, resource_size(wdt_mem));
wdt_mem = NULL;
}
clk_disable_unprepare(wdt_clk); clk_disable_unprepare(wdt_clk);
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