summaryrefslogtreecommitdiff
path: root/drivers/rtc
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>2017-07-06 12:42:06 +0300
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>2017-07-07 14:14:21 +0300
commit69b119a642b7e143be08f9cbabca7bc910f5720d (patch)
treefb4281ec2f31223b6fbc3fdaa5dfa344164ebde4 /drivers/rtc
parent2a52482ffb1a65249049eaec9e3560a1e79abf3d (diff)
downloadlinux-69b119a642b7e143be08f9cbabca7bc910f5720d.tar.xz
rtc: ds1307: switch to rtc_register_device
This removes a possible race condition and crash and allows for further improvement of the driver. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-ds1307.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 57ea25400ecd..6f94f20326fb 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -1674,8 +1674,8 @@ read_rtc:
device_set_wakeup_capable(ds1307->dev, true);
set_bit(HAS_ALARM, &ds1307->flags);
}
- ds1307->rtc = devm_rtc_device_register(ds1307->dev, ds1307->name,
- rtc_ops, THIS_MODULE);
+
+ ds1307->rtc = devm_rtc_allocate_device(ds1307->dev);
if (IS_ERR(ds1307->rtc)) {
return PTR_ERR(ds1307->rtc);
}
@@ -1737,6 +1737,11 @@ read_rtc:
}
}
+ ds1307->rtc->ops = rtc_ops;
+ err = rtc_register_device(ds1307->rtc);
+ if (err)
+ return err;
+
ds1307_hwmon_register(ds1307);
ds1307_clks_register(ds1307);