diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-04-29 19:20:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 21:28:37 -0400 |
commit | a63794fefd850a97fe07cfc017f52ea1bb777e75 (patch) | |
tree | 9cf5ff1bda9219af756bb5217fefed032af09f5d /drivers/rtc | |
parent | c40dcf6e8ce477ba8c1c21b949b28e03b1700902 (diff) |
rtc: rtc-nuc900: 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')
-rw-r--r-- | drivers/rtc/rtc-nuc900.c | 53 |
1 files changed, 11 insertions, 42 deletions
diff --git a/drivers/rtc/rtc-nuc900.c b/drivers/rtc/rtc-nuc900.c index 4d9525cc1cf4..f5dfb6e5e7d9 100644 --- a/drivers/rtc/rtc-nuc900.c +++ b/drivers/rtc/rtc-nuc900.c | |||
@@ -226,9 +226,9 @@ static int __init nuc900_rtc_probe(struct platform_device *pdev) | |||
226 | { | 226 | { |
227 | struct resource *res; | 227 | struct resource *res; |
228 | struct nuc900_rtc *nuc900_rtc; | 228 | struct nuc900_rtc *nuc900_rtc; |
229 | int err = 0; | ||
230 | 229 | ||
231 | nuc900_rtc = kzalloc(sizeof(struct nuc900_rtc), GFP_KERNEL); | 230 | nuc900_rtc = devm_kzalloc(&pdev->dev, sizeof(struct nuc900_rtc), |
231 | GFP_KERNEL); | ||
232 | if (!nuc900_rtc) { | 232 | if (!nuc900_rtc) { |
233 | dev_err(&pdev->dev, "kzalloc nuc900_rtc failed\n"); | 233 | dev_err(&pdev->dev, "kzalloc nuc900_rtc failed\n"); |
234 | return -ENOMEM; | 234 | return -ENOMEM; |
@@ -236,68 +236,37 @@ static int __init nuc900_rtc_probe(struct platform_device *pdev) | |||
236 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 236 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
237 | if (!res) { | 237 | if (!res) { |
238 | dev_err(&pdev->dev, "platform_get_resource failed\n"); | 238 | dev_err(&pdev->dev, "platform_get_resource failed\n"); |
239 | err = -ENXIO; | 239 | return -ENXIO; |
240 | goto fail1; | ||
241 | } | 240 | } |
242 | 241 | ||
243 | if (!request_mem_region(res->start, resource_size(res), | 242 | nuc900_rtc->rtc_reg = devm_ioremap_resource(&pdev->dev, res); |
244 | pdev->name)) { | 243 | if (IS_ERR(nuc900_rtc->rtc_reg)) |
245 | dev_err(&pdev->dev, "request_mem_region failed\n"); | 244 | return PTR_ERR(nuc900_rtc->rtc_reg); |
246 | err = -EBUSY; | ||
247 | goto fail1; | ||
248 | } | ||
249 | |||
250 | nuc900_rtc->rtc_reg = ioremap(res->start, resource_size(res)); | ||
251 | if (!nuc900_rtc->rtc_reg) { | ||
252 | dev_err(&pdev->dev, "ioremap rtc_reg failed\n"); | ||
253 | err = -ENOMEM; | ||
254 | goto fail2; | ||
255 | } | ||
256 | 245 | ||
257 | platform_set_drvdata(pdev, nuc900_rtc); | 246 | platform_set_drvdata(pdev, nuc900_rtc); |
258 | 247 | ||
259 | nuc900_rtc->rtcdev = rtc_device_register(pdev->name, &pdev->dev, | 248 | nuc900_rtc->rtcdev = devm_rtc_device_register(&pdev->dev, pdev->name, |
260 | &nuc900_rtc_ops, THIS_MODULE); | 249 | &nuc900_rtc_ops, THIS_MODULE); |
261 | if (IS_ERR(nuc900_rtc->rtcdev)) { | 250 | if (IS_ERR(nuc900_rtc->rtcdev)) { |
262 | dev_err(&pdev->dev, "rtc device register failed\n"); | 251 | dev_err(&pdev->dev, "rtc device register failed\n"); |
263 | err = PTR_ERR(nuc900_rtc->rtcdev); | 252 | return PTR_ERR(nuc900_rtc->rtcdev); |
264 | goto fail3; | ||
265 | } | 253 | } |
266 | 254 | ||
267 | __raw_writel(__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_TSSR) | MODE24, | 255 | __raw_writel(__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_TSSR) | MODE24, |
268 | nuc900_rtc->rtc_reg + REG_RTC_TSSR); | 256 | nuc900_rtc->rtc_reg + REG_RTC_TSSR); |
269 | 257 | ||
270 | nuc900_rtc->irq_num = platform_get_irq(pdev, 0); | 258 | nuc900_rtc->irq_num = platform_get_irq(pdev, 0); |
271 | if (request_irq(nuc900_rtc->irq_num, nuc900_rtc_interrupt, | 259 | if (devm_request_irq(&pdev->dev, nuc900_rtc->irq_num, |
272 | 0, "nuc900rtc", nuc900_rtc)) { | 260 | nuc900_rtc_interrupt, 0, "nuc900rtc", nuc900_rtc)) { |
273 | dev_err(&pdev->dev, "NUC900 RTC request irq failed\n"); | 261 | dev_err(&pdev->dev, "NUC900 RTC request irq failed\n"); |
274 | err = -EBUSY; | 262 | return -EBUSY; |
275 | goto fail4; | ||
276 | } | 263 | } |
277 | 264 | ||
278 | return 0; | 265 | return 0; |
279 | |||
280 | fail4: rtc_device_unregister(nuc900_rtc->rtcdev); | ||
281 | fail3: iounmap(nuc900_rtc->rtc_reg); | ||
282 | fail2: release_mem_region(res->start, resource_size(res)); | ||
283 | fail1: kfree(nuc900_rtc); | ||
284 | return err; | ||
285 | } | 266 | } |
286 | 267 | ||
287 | static int __exit nuc900_rtc_remove(struct platform_device *pdev) | 268 | static int __exit nuc900_rtc_remove(struct platform_device *pdev) |
288 | { | 269 | { |
289 | struct nuc900_rtc *nuc900_rtc = platform_get_drvdata(pdev); | ||
290 | struct resource *res; | ||
291 | |||
292 | free_irq(nuc900_rtc->irq_num, nuc900_rtc); | ||
293 | rtc_device_unregister(nuc900_rtc->rtcdev); | ||
294 | iounmap(nuc900_rtc->rtc_reg); | ||
295 | |||
296 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
297 | release_mem_region(res->start, resource_size(res)); | ||
298 | |||
299 | kfree(nuc900_rtc); | ||
300 | |||
301 | platform_set_drvdata(pdev, NULL); | 270 | platform_set_drvdata(pdev, NULL); |
302 | 271 | ||
303 | return 0; | 272 | return 0; |