rtc: vr41xx: fix possible race condition
[linux-2.6-microblaze.git] / drivers / rtc / rtc-vr41xx.c
index 480cffe..2f1212a 100644 (file)
@@ -292,13 +292,14 @@ static int rtc_probe(struct platform_device *pdev)
                goto err_rtc1_iounmap;
        }
 
-       rtc = devm_rtc_device_register(&pdev->dev, rtc_name, &vr41xx_rtc_ops,
-                                       THIS_MODULE);
+       rtc = devm_rtc_allocate_device(&pdev->dev);
        if (IS_ERR(rtc)) {
                retval = PTR_ERR(rtc);
                goto err_iounmap_all;
        }
 
+       rtc->ops = &vr41xx_rtc_ops;
+
        rtc->max_user_freq = MAX_PERIODIC_RATE;
 
        spin_lock_irq(&rtc_lock);
@@ -340,6 +341,10 @@ static int rtc_probe(struct platform_device *pdev)
 
        dev_info(&pdev->dev, "Real Time Clock of NEC VR4100 series\n");
 
+       retval = rtc_register_device(rtc);
+       if (retval)
+               goto err_iounmap_all;
+
        return 0;
 
 err_iounmap_all: