| .. | .. |
|---|
| 5 | 5 | // Author: Stephen Barber <smbarber@chromium.org> |
|---|
| 6 | 6 | |
|---|
| 7 | 7 | #include <linux/kernel.h> |
|---|
| 8 | | -#include <linux/mfd/cros_ec.h> |
|---|
| 9 | | -#include <linux/mfd/cros_ec_commands.h> |
|---|
| 10 | 8 | #include <linux/module.h> |
|---|
| 9 | +#include <linux/platform_data/cros_ec_commands.h> |
|---|
| 10 | +#include <linux/platform_data/cros_ec_proto.h> |
|---|
| 11 | 11 | #include <linux/platform_device.h> |
|---|
| 12 | 12 | #include <linux/rtc.h> |
|---|
| 13 | 13 | #include <linux/slab.h> |
|---|
| .. | .. |
|---|
| 106 | 106 | struct cros_ec_rtc *cros_ec_rtc = dev_get_drvdata(dev); |
|---|
| 107 | 107 | struct cros_ec_device *cros_ec = cros_ec_rtc->cros_ec; |
|---|
| 108 | 108 | int ret; |
|---|
| 109 | | - time64_t time; |
|---|
| 110 | | - |
|---|
| 111 | | - time = rtc_tm_to_time64(tm); |
|---|
| 112 | | - if (time < 0 || time > U32_MAX) |
|---|
| 113 | | - return -EINVAL; |
|---|
| 109 | + time64_t time = rtc_tm_to_time64(tm); |
|---|
| 114 | 110 | |
|---|
| 115 | 111 | ret = cros_ec_rtc_set(cros_ec, EC_CMD_RTC_SET_VALUE, (u32)time); |
|---|
| 116 | 112 | if (ret < 0) { |
|---|
| .. | .. |
|---|
| 347 | 343 | return ret; |
|---|
| 348 | 344 | } |
|---|
| 349 | 345 | |
|---|
| 350 | | - cros_ec_rtc->rtc = devm_rtc_device_register(&pdev->dev, DRV_NAME, |
|---|
| 351 | | - &cros_ec_rtc_ops, |
|---|
| 352 | | - THIS_MODULE); |
|---|
| 353 | | - if (IS_ERR(cros_ec_rtc->rtc)) { |
|---|
| 354 | | - ret = PTR_ERR(cros_ec_rtc->rtc); |
|---|
| 355 | | - dev_err(&pdev->dev, "failed to register rtc device\n"); |
|---|
| 346 | + cros_ec_rtc->rtc = devm_rtc_allocate_device(&pdev->dev); |
|---|
| 347 | + if (IS_ERR(cros_ec_rtc->rtc)) |
|---|
| 348 | + return PTR_ERR(cros_ec_rtc->rtc); |
|---|
| 349 | + |
|---|
| 350 | + cros_ec_rtc->rtc->ops = &cros_ec_rtc_ops; |
|---|
| 351 | + cros_ec_rtc->rtc->range_max = U32_MAX; |
|---|
| 352 | + |
|---|
| 353 | + ret = rtc_register_device(cros_ec_rtc->rtc); |
|---|
| 354 | + if (ret) |
|---|
| 356 | 355 | return ret; |
|---|
| 357 | | - } |
|---|
| 358 | 356 | |
|---|
| 359 | 357 | /* Get RTC events from the EC. */ |
|---|
| 360 | 358 | cros_ec_rtc->notifier.notifier_call = cros_ec_rtc_event; |
|---|