hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/rtc/rtc-cpcap.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Motorola CPCAP PMIC RTC driver
34 *
....@@ -12,15 +13,6 @@
1213 * - remove custom "secure clock daemon" helpers
1314 *
1415 * Copyright (C) 2017 Sebastian Reichel <sre@kernel.org>
15
- *
16
- * This program is free software; you can redistribute it and/or modify
17
- * it under the terms of the GNU General Public License version 2 as
18
- * published by the Free Software Foundation.
19
- *
20
- * This program is distributed in the hope that it will be useful,
21
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- * GNU General Public License for more details.
2416 */
2517 #include <linux/kernel.h>
2618 #include <linux/module.h>
....@@ -64,14 +56,14 @@
6456 tod = (cpcap->tod1 & TOD1_MASK) | ((cpcap->tod2 & TOD2_MASK) << 8);
6557 time = tod + ((cpcap->day & DAY_MASK) * SECS_PER_DAY);
6658
67
- rtc_time_to_tm(time, rtc);
59
+ rtc_time64_to_tm(time, rtc);
6860 }
6961
7062 static void rtc2cpcap_time(struct cpcap_time *cpcap, struct rtc_time *rtc)
7163 {
7264 unsigned long time;
7365
74
- rtc_tm_to_time(rtc, &time);
66
+ time = rtc_tm_to_time64(rtc);
7567
7668 cpcap->day = time / SECS_PER_DAY;
7769 time %= SECS_PER_DAY;
....@@ -264,11 +256,12 @@
264256 return -ENODEV;
265257
266258 platform_set_drvdata(pdev, rtc);
267
- rtc->rtc_dev = devm_rtc_device_register(dev, "cpcap_rtc",
268
- &cpcap_rtc_ops, THIS_MODULE);
269
-
259
+ rtc->rtc_dev = devm_rtc_allocate_device(dev);
270260 if (IS_ERR(rtc->rtc_dev))
271261 return PTR_ERR(rtc->rtc_dev);
262
+
263
+ rtc->rtc_dev->ops = &cpcap_rtc_ops;
264
+ rtc->rtc_dev->range_max = (timeu64_t) (DAY_MASK + 1) * SECS_PER_DAY - 1;
272265
273266 err = cpcap_get_vendor(dev, rtc->regmap, &rtc->vendor);
274267 if (err)
....@@ -306,7 +299,7 @@
306299 /* ignore error and continue without wakeup support */
307300 }
308301
309
- return 0;
302
+ return rtc_register_device(rtc->rtc_dev);
310303 }
311304
312305 static const struct of_device_id cpcap_rtc_of_match[] = {