Commit 0e843137 authored by Alexandre Belloni's avatar Alexandre Belloni

rtc: cros-ec: let the core handle rtc range

Let the rtc core check the date/time against the RTC range.
Reviewed-by: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
Link: https://lore.kernel.org/r/20191016201414.30934-2-alexandre.belloni@bootlin.comSigned-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
parent 4fc0d13f
...@@ -107,11 +107,7 @@ static int cros_ec_rtc_set_time(struct device *dev, struct rtc_time *tm) ...@@ -107,11 +107,7 @@ static int cros_ec_rtc_set_time(struct device *dev, struct rtc_time *tm)
struct cros_ec_rtc *cros_ec_rtc = dev_get_drvdata(dev); struct cros_ec_rtc *cros_ec_rtc = dev_get_drvdata(dev);
struct cros_ec_device *cros_ec = cros_ec_rtc->cros_ec; struct cros_ec_device *cros_ec = cros_ec_rtc->cros_ec;
int ret; int ret;
time64_t time; time64_t time = rtc_tm_to_time64(tm);
time = rtc_tm_to_time64(tm);
if (time < 0 || time > U32_MAX)
return -EINVAL;
ret = cros_ec_rtc_set(cros_ec, EC_CMD_RTC_SET_VALUE, (u32)time); ret = cros_ec_rtc_set(cros_ec, EC_CMD_RTC_SET_VALUE, (u32)time);
if (ret < 0) { if (ret < 0) {
...@@ -348,12 +344,17 @@ static int cros_ec_rtc_probe(struct platform_device *pdev) ...@@ -348,12 +344,17 @@ static int cros_ec_rtc_probe(struct platform_device *pdev)
return ret; return ret;
} }
cros_ec_rtc->rtc = devm_rtc_device_register(&pdev->dev, DRV_NAME, cros_ec_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
&cros_ec_rtc_ops,
THIS_MODULE);
if (IS_ERR(cros_ec_rtc->rtc)) if (IS_ERR(cros_ec_rtc->rtc))
return PTR_ERR(cros_ec_rtc->rtc); return PTR_ERR(cros_ec_rtc->rtc);
cros_ec_rtc->rtc->ops = &cros_ec_rtc_ops;
cros_ec_rtc->rtc->range_max = U32_MAX;
ret = rtc_register_device(cros_ec_rtc->rtc);
if (ret)
return ret;
/* Get RTC events from the EC. */ /* Get RTC events from the EC. */
cros_ec_rtc->notifier.notifier_call = cros_ec_rtc_event; cros_ec_rtc->notifier.notifier_call = cros_ec_rtc_event;
ret = blocking_notifier_chain_register(&cros_ec->event_notifier, ret = blocking_notifier_chain_register(&cros_ec->event_notifier,
......
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