diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-04-29 19:20:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 21:28:36 -0400 |
commit | 061d698e208efb8036673295b5be3b0c8be75082 (patch) | |
tree | 34b5227f645d72560a73b019413ec34b5186ccda /drivers/rtc/rtc-ds1286.c | |
parent | 15c1567a71ee4690586780c261ebedc03bb774e5 (diff) |
rtc: rtc-ds1286: use devm_*() functions
Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-ds1286.c')
-rw-r--r-- | drivers/rtc/rtc-ds1286.c | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/drivers/rtc/rtc-ds1286.c b/drivers/rtc/rtc-ds1286.c index d120cb8bfcbe..398c96a98fc4 100644 --- a/drivers/rtc/rtc-ds1286.c +++ b/drivers/rtc/rtc-ds1286.c | |||
@@ -25,8 +25,6 @@ | |||
25 | struct ds1286_priv { | 25 | struct ds1286_priv { |
26 | struct rtc_device *rtc; | 26 | struct rtc_device *rtc; |
27 | u32 __iomem *rtcregs; | 27 | u32 __iomem *rtcregs; |
28 | size_t size; | ||
29 | unsigned long baseaddr; | ||
30 | spinlock_t lock; | 28 | spinlock_t lock; |
31 | }; | 29 | }; |
32 | 30 | ||
@@ -333,56 +331,30 @@ static int ds1286_probe(struct platform_device *pdev) | |||
333 | struct rtc_device *rtc; | 331 | struct rtc_device *rtc; |
334 | struct resource *res; | 332 | struct resource *res; |
335 | struct ds1286_priv *priv; | 333 | struct ds1286_priv *priv; |
336 | int ret = 0; | ||
337 | 334 | ||
338 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 335 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
339 | if (!res) | 336 | if (!res) |
340 | return -ENODEV; | 337 | return -ENODEV; |
341 | priv = kzalloc(sizeof(struct ds1286_priv), GFP_KERNEL); | 338 | priv = devm_kzalloc(&pdev->dev, sizeof(struct ds1286_priv), GFP_KERNEL); |
342 | if (!priv) | 339 | if (!priv) |
343 | return -ENOMEM; | 340 | return -ENOMEM; |
344 | 341 | ||
345 | priv->size = resource_size(res); | 342 | priv->rtcregs = devm_ioremap_resource(&pdev->dev, res); |
346 | if (!request_mem_region(res->start, priv->size, pdev->name)) { | 343 | if (IS_ERR(priv->rtcregs)) |
347 | ret = -EBUSY; | 344 | return PTR_ERR(priv->rtcregs); |
348 | goto out; | 345 | |
349 | } | ||
350 | priv->baseaddr = res->start; | ||
351 | priv->rtcregs = ioremap(priv->baseaddr, priv->size); | ||
352 | if (!priv->rtcregs) { | ||
353 | ret = -ENOMEM; | ||
354 | goto out; | ||
355 | } | ||
356 | spin_lock_init(&priv->lock); | 346 | spin_lock_init(&priv->lock); |
357 | platform_set_drvdata(pdev, priv); | 347 | platform_set_drvdata(pdev, priv); |
358 | rtc = rtc_device_register("ds1286", &pdev->dev, | 348 | rtc = devm_rtc_device_register(&pdev->dev, "ds1286", &ds1286_ops, |
359 | &ds1286_ops, THIS_MODULE); | 349 | THIS_MODULE); |
360 | if (IS_ERR(rtc)) { | 350 | if (IS_ERR(rtc)) |
361 | ret = PTR_ERR(rtc); | 351 | return PTR_ERR(rtc); |
362 | goto out; | ||
363 | } | ||
364 | priv->rtc = rtc; | 352 | priv->rtc = rtc; |
365 | return 0; | 353 | return 0; |
366 | |||
367 | out: | ||
368 | if (priv->rtc) | ||
369 | rtc_device_unregister(priv->rtc); | ||
370 | if (priv->rtcregs) | ||
371 | iounmap(priv->rtcregs); | ||
372 | if (priv->baseaddr) | ||
373 | release_mem_region(priv->baseaddr, priv->size); | ||
374 | kfree(priv); | ||
375 | return ret; | ||
376 | } | 354 | } |
377 | 355 | ||
378 | static int ds1286_remove(struct platform_device *pdev) | 356 | static int ds1286_remove(struct platform_device *pdev) |
379 | { | 357 | { |
380 | struct ds1286_priv *priv = platform_get_drvdata(pdev); | ||
381 | |||
382 | rtc_device_unregister(priv->rtc); | ||
383 | iounmap(priv->rtcregs); | ||
384 | release_mem_region(priv->baseaddr, priv->size); | ||
385 | kfree(priv); | ||
386 | return 0; | 358 | return 0; |
387 | } | 359 | } |
388 | 360 | ||