diff options
author | Alessandro Zummo <a.zummo@towertech.it> | 2014-04-03 17:49:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-03 19:21:16 -0400 |
commit | 4071ea25cc08d41002746cca2d69ac700d67a2ac (patch) | |
tree | 43cf44f8265b885c8c1e4e81f0ced5c6babb53c7 /drivers/rtc/rtc-ds1553.c | |
parent | a68b31080912dae377bee4994716b357dc74286d (diff) |
rtc: fix potential race condition
RTC drivers must not return an error after device registration.
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
Reported-by: Ales Novak <alnovak@suse.cz>
Cc: Alexander Shiyan <shc_work@mail.ru>
Cc: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Srikanth Srinivasan <srikanth.srinivasan@freescale.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.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-ds1553.c')
-rw-r--r-- | drivers/rtc/rtc-ds1553.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c index fd31571941f5..9ac2fa07dffa 100644 --- a/drivers/rtc/rtc-ds1553.c +++ b/drivers/rtc/rtc-ds1553.c | |||
@@ -278,7 +278,6 @@ static struct bin_attribute ds1553_nvram_attr = { | |||
278 | 278 | ||
279 | static int ds1553_rtc_probe(struct platform_device *pdev) | 279 | static int ds1553_rtc_probe(struct platform_device *pdev) |
280 | { | 280 | { |
281 | struct rtc_device *rtc; | ||
282 | struct resource *res; | 281 | struct resource *res; |
283 | unsigned int cen, sec; | 282 | unsigned int cen, sec; |
284 | struct rtc_plat_data *pdata; | 283 | struct rtc_plat_data *pdata; |
@@ -311,6 +310,12 @@ static int ds1553_rtc_probe(struct platform_device *pdev) | |||
311 | spin_lock_init(&pdata->lock); | 310 | spin_lock_init(&pdata->lock); |
312 | pdata->last_jiffies = jiffies; | 311 | pdata->last_jiffies = jiffies; |
313 | platform_set_drvdata(pdev, pdata); | 312 | platform_set_drvdata(pdev, pdata); |
313 | |||
314 | pdata->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, | ||
315 | &ds1553_rtc_ops, THIS_MODULE); | ||
316 | if (IS_ERR(pdata->rtc)) | ||
317 | return PTR_ERR(pdata->rtc); | ||
318 | |||
314 | if (pdata->irq > 0) { | 319 | if (pdata->irq > 0) { |
315 | writeb(0, ioaddr + RTC_INTERRUPTS); | 320 | writeb(0, ioaddr + RTC_INTERRUPTS); |
316 | if (devm_request_irq(&pdev->dev, pdata->irq, | 321 | if (devm_request_irq(&pdev->dev, pdata->irq, |
@@ -321,15 +326,12 @@ static int ds1553_rtc_probe(struct platform_device *pdev) | |||
321 | } | 326 | } |
322 | } | 327 | } |
323 | 328 | ||
324 | rtc = devm_rtc_device_register(&pdev->dev, pdev->name, | ||
325 | &ds1553_rtc_ops, THIS_MODULE); | ||
326 | if (IS_ERR(rtc)) | ||
327 | return PTR_ERR(rtc); | ||
328 | pdata->rtc = rtc; | ||
329 | |||
330 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1553_nvram_attr); | 329 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1553_nvram_attr); |
330 | if (ret) | ||
331 | dev_err(&pdev->dev, "unable to create sysfs file: %s\n", | ||
332 | ds1553_nvram_attr.attr.name); | ||
331 | 333 | ||
332 | return ret; | 334 | return 0; |
333 | } | 335 | } |
334 | 336 | ||
335 | static int ds1553_rtc_remove(struct platform_device *pdev) | 337 | static int ds1553_rtc_remove(struct platform_device *pdev) |