diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-04-29 19:20:51 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 21:28:38 -0400 |
commit | ddb396f12556286dfb19f54f39293d8d3fe89c60 (patch) | |
tree | cb9ad3907dcfd24e0bc138563cf8841795ef1b8f | |
parent | 4ad21183da64a27fbe4bb547ae385ad1ff912690 (diff) |
rtc: rtc-rp5c01: 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>
-rw-r--r-- | drivers/rtc/rtc-rp5c01.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/drivers/rtc/rtc-rp5c01.c b/drivers/rtc/rtc-rp5c01.c index d25d2f6c0cad..873c689f01c3 100644 --- a/drivers/rtc/rtc-rp5c01.c +++ b/drivers/rtc/rtc-rp5c01.c | |||
@@ -230,15 +230,13 @@ static int __init rp5c01_rtc_probe(struct platform_device *dev) | |||
230 | if (!res) | 230 | if (!res) |
231 | return -ENODEV; | 231 | return -ENODEV; |
232 | 232 | ||
233 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 233 | priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL); |
234 | if (!priv) | 234 | if (!priv) |
235 | return -ENOMEM; | 235 | return -ENOMEM; |
236 | 236 | ||
237 | priv->regs = ioremap(res->start, resource_size(res)); | 237 | priv->regs = devm_ioremap(&dev->dev, res->start, resource_size(res)); |
238 | if (!priv->regs) { | 238 | if (!priv->regs) |
239 | error = -ENOMEM; | 239 | return -ENOMEM; |
240 | goto out_free_priv; | ||
241 | } | ||
242 | 240 | ||
243 | sysfs_bin_attr_init(&priv->nvram_attr); | 241 | sysfs_bin_attr_init(&priv->nvram_attr); |
244 | priv->nvram_attr.attr.name = "nvram"; | 242 | priv->nvram_attr.attr.name = "nvram"; |
@@ -251,27 +249,22 @@ static int __init rp5c01_rtc_probe(struct platform_device *dev) | |||
251 | 249 | ||
252 | platform_set_drvdata(dev, priv); | 250 | platform_set_drvdata(dev, priv); |
253 | 251 | ||
254 | rtc = rtc_device_register("rtc-rp5c01", &dev->dev, &rp5c01_rtc_ops, | 252 | rtc = devm_rtc_device_register(&dev->dev, "rtc-rp5c01", &rp5c01_rtc_ops, |
255 | THIS_MODULE); | 253 | THIS_MODULE); |
256 | if (IS_ERR(rtc)) { | 254 | if (IS_ERR(rtc)) { |
257 | error = PTR_ERR(rtc); | 255 | error = PTR_ERR(rtc); |
258 | goto out_unmap; | 256 | goto out; |
259 | } | 257 | } |
260 | priv->rtc = rtc; | 258 | priv->rtc = rtc; |
261 | 259 | ||
262 | error = sysfs_create_bin_file(&dev->dev.kobj, &priv->nvram_attr); | 260 | error = sysfs_create_bin_file(&dev->dev.kobj, &priv->nvram_attr); |
263 | if (error) | 261 | if (error) |
264 | goto out_unregister; | 262 | goto out; |
265 | 263 | ||
266 | return 0; | 264 | return 0; |
267 | 265 | ||
268 | out_unregister: | 266 | out: |
269 | rtc_device_unregister(rtc); | ||
270 | out_unmap: | ||
271 | platform_set_drvdata(dev, NULL); | 267 | platform_set_drvdata(dev, NULL); |
272 | iounmap(priv->regs); | ||
273 | out_free_priv: | ||
274 | kfree(priv); | ||
275 | return error; | 268 | return error; |
276 | } | 269 | } |
277 | 270 | ||
@@ -280,9 +273,6 @@ static int __exit rp5c01_rtc_remove(struct platform_device *dev) | |||
280 | struct rp5c01_priv *priv = platform_get_drvdata(dev); | 273 | struct rp5c01_priv *priv = platform_get_drvdata(dev); |
281 | 274 | ||
282 | sysfs_remove_bin_file(&dev->dev.kobj, &priv->nvram_attr); | 275 | sysfs_remove_bin_file(&dev->dev.kobj, &priv->nvram_attr); |
283 | rtc_device_unregister(priv->rtc); | ||
284 | iounmap(priv->regs); | ||
285 | kfree(priv); | ||
286 | return 0; | 276 | return 0; |
287 | } | 277 | } |
288 | 278 | ||