hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/rtc/rtc-cros-ec.c
....@@ -5,9 +5,9 @@
55 // Author: Stephen Barber <smbarber@chromium.org>
66
77 #include <linux/kernel.h>
8
-#include <linux/mfd/cros_ec.h>
9
-#include <linux/mfd/cros_ec_commands.h>
108 #include <linux/module.h>
9
+#include <linux/platform_data/cros_ec_commands.h>
10
+#include <linux/platform_data/cros_ec_proto.h>
1111 #include <linux/platform_device.h>
1212 #include <linux/rtc.h>
1313 #include <linux/slab.h>
....@@ -106,11 +106,7 @@
106106 struct cros_ec_rtc *cros_ec_rtc = dev_get_drvdata(dev);
107107 struct cros_ec_device *cros_ec = cros_ec_rtc->cros_ec;
108108 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);
114110
115111 ret = cros_ec_rtc_set(cros_ec, EC_CMD_RTC_SET_VALUE, (u32)time);
116112 if (ret < 0) {
....@@ -347,14 +343,16 @@
347343 return ret;
348344 }
349345
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)
356355 return ret;
357
- }
358356
359357 /* Get RTC events from the EC. */
360358 cros_ec_rtc->notifier.notifier_call = cros_ec_rtc_event;