aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/davinci_wdt.c
diff options
context:
space:
mode:
authorKumar, Anil <anilkumar.v@ti.com>2013-02-08 02:39:30 -0500
committerWim Van Sebroeck <wim@iguana.be>2013-03-01 06:56:18 -0500
commite20880e60faadc03837f661533135adb4b7cde01 (patch)
tree2d99b9973fc67d394713a7fb23437d730fc9330a /drivers/watchdog/davinci_wdt.c
parent362ce5aeeb1b1828f91c2ca07327f72c24183ec9 (diff)
watchdog: davinci_wdt: update to devm_* API
Update the code to use devm_* API so that driver core will manage resources. Signed-off-by: Kumar, Anil <anilkumar.v@ti.com> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog/davinci_wdt.c')
-rw-r--r--drivers/watchdog/davinci_wdt.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c
index c3c2f8205ef1..7df1fdca9e78 100644
--- a/drivers/watchdog/davinci_wdt.c
+++ b/drivers/watchdog/davinci_wdt.c
@@ -69,7 +69,6 @@ static unsigned long wdt_status;
69#define WDT_REGION_INITED 2 69#define WDT_REGION_INITED 2
70#define WDT_DEVICE_INITED 3 70#define WDT_DEVICE_INITED 3
71 71
72static struct resource *wdt_mem;
73static void __iomem *wdt_base; 72static void __iomem *wdt_base;
74struct clk *wdt_clk; 73struct clk *wdt_clk;
75 74
@@ -201,8 +200,9 @@ static struct miscdevice davinci_wdt_miscdev = {
201 200
202static int davinci_wdt_probe(struct platform_device *pdev) 201static int davinci_wdt_probe(struct platform_device *pdev)
203{ 202{
204 int ret = 0, size; 203 int ret = 0;
205 struct device *dev = &pdev->dev; 204 struct device *dev = &pdev->dev;
205 struct resource *wdt_mem;
206 206
207 wdt_clk = devm_clk_get(dev, NULL); 207 wdt_clk = devm_clk_get(dev, NULL);
208 if (WARN_ON(IS_ERR(wdt_clk))) 208 if (WARN_ON(IS_ERR(wdt_clk)))
@@ -221,41 +221,25 @@ static int davinci_wdt_probe(struct platform_device *pdev)
221 return -ENOENT; 221 return -ENOENT;
222 } 222 }
223 223
224 size = resource_size(wdt_mem); 224 wdt_base = devm_request_and_ioremap(dev, wdt_mem);
225 if (!request_mem_region(wdt_mem->start, size, pdev->name)) {
226 dev_err(dev, "failed to get memory region\n");
227 return -ENOENT;
228 }
229
230 wdt_base = ioremap(wdt_mem->start, size);
231 if (!wdt_base) { 225 if (!wdt_base) {
232 dev_err(dev, "failed to map memory region\n"); 226 dev_err(dev, "ioremap failed\n");
233 release_mem_region(wdt_mem->start, size); 227 return -EADDRNOTAVAIL;
234 wdt_mem = NULL;
235 return -ENOMEM;
236 } 228 }
237 229
238 ret = misc_register(&davinci_wdt_miscdev); 230 ret = misc_register(&davinci_wdt_miscdev);
239 if (ret < 0) { 231 if (ret < 0) {
240 dev_err(dev, "cannot register misc device\n"); 232 dev_err(dev, "cannot register misc device\n");
241 release_mem_region(wdt_mem->start, size);
242 wdt_mem = NULL;
243 } else { 233 } else {
244 set_bit(WDT_DEVICE_INITED, &wdt_status); 234 set_bit(WDT_DEVICE_INITED, &wdt_status);
245 } 235 }
246 236
247 iounmap(wdt_base);
248 return ret; 237 return ret;
249} 238}
250 239
251static int davinci_wdt_remove(struct platform_device *pdev) 240static int davinci_wdt_remove(struct platform_device *pdev)
252{ 241{
253 misc_deregister(&davinci_wdt_miscdev); 242 misc_deregister(&davinci_wdt_miscdev);
254 if (wdt_mem) {
255 release_mem_region(wdt_mem->start, resource_size(wdt_mem));
256 wdt_mem = NULL;
257 }
258
259 clk_disable_unprepare(wdt_clk); 243 clk_disable_unprepare(wdt_clk);
260 244
261 return 0; 245 return 0;