| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Driver for NEC VR4100 series Real Time Clock unit. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * 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 |
|---|
| 19 | 6 | */ |
|---|
| 7 | +#include <linux/compat.h> |
|---|
| 20 | 8 | #include <linux/err.h> |
|---|
| 21 | 9 | #include <linux/fs.h> |
|---|
| 22 | 10 | #include <linux/init.h> |
|---|
| .. | .. |
|---|
| 79 | 67 | #define rtc2_read(offset) readw(rtc2_base + (offset)) |
|---|
| 80 | 68 | #define rtc2_write(offset, value) writew((value), rtc2_base + (offset)) |
|---|
| 81 | 69 | |
|---|
| 70 | +/* 32-bit compat for ioctls that nobody else uses */ |
|---|
| 71 | +#define RTC_EPOCH_READ32 _IOR('p', 0x0d, __u32) |
|---|
| 72 | + |
|---|
| 82 | 73 | static unsigned long epoch = 1970; /* Jan 1 1970 00:00:00 */ |
|---|
| 83 | 74 | |
|---|
| 84 | 75 | static DEFINE_SPINLOCK(rtc_lock); |
|---|
| .. | .. |
|---|
| 136 | 127 | time64_t epoch_sec, current_sec; |
|---|
| 137 | 128 | |
|---|
| 138 | 129 | 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); |
|---|
| 141 | 131 | |
|---|
| 142 | 132 | write_elapsed_second(current_sec - epoch_sec); |
|---|
| 143 | 133 | |
|---|
| .. | .. |
|---|
| 158 | 148 | |
|---|
| 159 | 149 | spin_unlock_irq(&rtc_lock); |
|---|
| 160 | 150 | |
|---|
| 161 | | - rtc_time_to_tm((high << 17) | (mid << 1) | (low >> 15), time); |
|---|
| 151 | + rtc_time64_to_tm((high << 17) | (mid << 1) | (low >> 15), time); |
|---|
| 162 | 152 | |
|---|
| 163 | 153 | return 0; |
|---|
| 164 | 154 | } |
|---|
| .. | .. |
|---|
| 166 | 156 | static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) |
|---|
| 167 | 157 | { |
|---|
| 168 | 158 | time64_t alarm_sec; |
|---|
| 169 | | - struct rtc_time *time = &wkalrm->time; |
|---|
| 170 | 159 | |
|---|
| 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); |
|---|
| 173 | 161 | |
|---|
| 174 | 162 | spin_lock_irq(&rtc_lock); |
|---|
| 175 | 163 | |
|---|
| .. | .. |
|---|
| 195 | 183 | switch (cmd) { |
|---|
| 196 | 184 | case RTC_EPOCH_READ: |
|---|
| 197 | 185 | 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 |
|---|
| 198 | 190 | case RTC_EPOCH_SET: |
|---|
| 199 | 191 | /* Doesn't support before 1900 */ |
|---|
| 200 | 192 | if (arg < 1900) |
|---|