Commit 69b119a6 authored by Alexandre Belloni's avatar Alexandre Belloni

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: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
parent 2a52482f
...@@ -1674,8 +1674,8 @@ static int ds1307_probe(struct i2c_client *client, ...@@ -1674,8 +1674,8 @@ static int ds1307_probe(struct i2c_client *client,
device_set_wakeup_capable(ds1307->dev, true); device_set_wakeup_capable(ds1307->dev, true);
set_bit(HAS_ALARM, &ds1307->flags); 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)) { if (IS_ERR(ds1307->rtc)) {
return PTR_ERR(ds1307->rtc); return PTR_ERR(ds1307->rtc);
} }
...@@ -1737,6 +1737,11 @@ static int ds1307_probe(struct i2c_client *client, ...@@ -1737,6 +1737,11 @@ static int ds1307_probe(struct i2c_client *client,
} }
} }
ds1307->rtc->ops = rtc_ops;
err = rtc_register_device(ds1307->rtc);
if (err)
return err;
ds1307_hwmon_register(ds1307); ds1307_hwmon_register(ds1307);
ds1307_clks_register(ds1307); ds1307_clks_register(ds1307);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment