hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/rtc/rtc-vr41xx.c
....@@ -1,22 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for NEC VR4100 series Real Time Clock unit.
34 *
45 * Copyright (C) 2003-2008 Yoichi Yuasa <yuasa@linux-mips.org>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
196 */
7
+#include <linux/compat.h>
208 #include <linux/err.h>
219 #include <linux/fs.h>
2210 #include <linux/init.h>
....@@ -79,6 +67,9 @@
7967 #define rtc2_read(offset) readw(rtc2_base + (offset))
8068 #define rtc2_write(offset, value) writew((value), rtc2_base + (offset))
8169
70
+/* 32-bit compat for ioctls that nobody else uses */
71
+#define RTC_EPOCH_READ32 _IOR('p', 0x0d, __u32)
72
+
8273 static unsigned long epoch = 1970; /* Jan 1 1970 00:00:00 */
8374
8475 static DEFINE_SPINLOCK(rtc_lock);
....@@ -136,8 +127,7 @@
136127 time64_t epoch_sec, current_sec;
137128
138129 epoch_sec = mktime64(epoch, 1, 1, 0, 0, 0);
139
- current_sec = mktime64(time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
140
- time->tm_hour, time->tm_min, time->tm_sec);
130
+ current_sec = rtc_tm_to_time64(time);
141131
142132 write_elapsed_second(current_sec - epoch_sec);
143133
....@@ -158,7 +148,7 @@
158148
159149 spin_unlock_irq(&rtc_lock);
160150
161
- rtc_time_to_tm((high << 17) | (mid << 1) | (low >> 15), time);
151
+ rtc_time64_to_tm((high << 17) | (mid << 1) | (low >> 15), time);
162152
163153 return 0;
164154 }
....@@ -166,10 +156,8 @@
166156 static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
167157 {
168158 time64_t alarm_sec;
169
- struct rtc_time *time = &wkalrm->time;
170159
171
- alarm_sec = mktime64(time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
172
- time->tm_hour, time->tm_min, time->tm_sec);
160
+ alarm_sec = rtc_tm_to_time64(&wkalrm->time);
173161
174162 spin_lock_irq(&rtc_lock);
175163
....@@ -195,6 +183,10 @@
195183 switch (cmd) {
196184 case RTC_EPOCH_READ:
197185 return put_user(epoch, (unsigned long __user *)arg);
186
+#ifdef CONFIG_64BIT
187
+ case RTC_EPOCH_READ32:
188
+ return put_user(epoch, (unsigned int __user *)arg);
189
+#endif
198190 case RTC_EPOCH_SET:
199191 /* Doesn't support before 1900 */
200192 if (arg < 1900)