hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/rtc/rtc-pcap.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * pcap rtc code for Motorola EZX phones
34 *
....@@ -5,11 +6,6 @@
56 * Copyright (c) 2009 Daniel Ribeiro <drwyrm@gmail.com>
67 *
78 * Based on Motorola's rtc.c Copyright (c) 2003-2005 Motorola
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License version 2 as
11
- * published by the Free Software Foundation.
12
- *
139 */
1410
1511 #include <linux/kernel.h>
....@@ -55,7 +51,7 @@
5551 ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, &days);
5652 secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY;
5753
58
- rtc_time_to_tm(secs, tm);
54
+ rtc_time64_to_tm(secs, tm);
5955
6056 return 0;
6157 }
....@@ -63,11 +59,8 @@
6359 static int pcap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
6460 {
6561 struct pcap_rtc *pcap_rtc = dev_get_drvdata(dev);
66
- struct rtc_time *tm = &alrm->time;
67
- unsigned long secs;
62
+ unsigned long secs = rtc_tm_to_time64(&alrm->time);
6863 u32 tod, days;
69
-
70
- rtc_tm_to_time(tm, &secs);
7164
7265 tod = secs % SEC_PER_DAY;
7366 ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_TODA, tod);
....@@ -90,14 +83,15 @@
9083 ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAY, &days);
9184 secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY;
9285
93
- rtc_time_to_tm(secs, tm);
86
+ rtc_time64_to_tm(secs, tm);
9487
9588 return 0;
9689 }
9790
98
-static int pcap_rtc_set_mmss(struct device *dev, unsigned long secs)
91
+static int pcap_rtc_set_time(struct device *dev, struct rtc_time *tm)
9992 {
10093 struct pcap_rtc *pcap_rtc = dev_get_drvdata(dev);
94
+ unsigned long secs = rtc_tm_to_time64(tm);
10195 u32 tod, days;
10296
10397 tod = secs % SEC_PER_DAY;
....@@ -128,9 +122,9 @@
128122
129123 static const struct rtc_class_ops pcap_rtc_ops = {
130124 .read_time = pcap_rtc_read_time,
125
+ .set_time = pcap_rtc_set_time,
131126 .read_alarm = pcap_rtc_read_alarm,
132127 .set_alarm = pcap_rtc_set_alarm,
133
- .set_mmss = pcap_rtc_set_mmss,
134128 .alarm_irq_enable = pcap_rtc_alarm_irq_enable,
135129 };
136130
....@@ -149,10 +143,12 @@
149143
150144 platform_set_drvdata(pdev, pcap_rtc);
151145
152
- pcap_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pcap",
153
- &pcap_rtc_ops, THIS_MODULE);
146
+ pcap_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
154147 if (IS_ERR(pcap_rtc->rtc))
155148 return PTR_ERR(pcap_rtc->rtc);
149
+
150
+ pcap_rtc->rtc->ops = &pcap_rtc_ops;
151
+ pcap_rtc->rtc->range_max = (1 << 14) * 86400ULL - 1;
156152
157153 timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ);
158154 alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA);
....@@ -167,7 +163,7 @@
167163 if (err)
168164 return err;
169165
170
- return 0;
166
+ return rtc_register_device(pcap_rtc->rtc);
171167 }
172168
173169 static int __exit pcap_rtc_remove(struct platform_device *pdev)