.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * drivers/rtc/rtc-vt8500.c |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2010 Alexey Charkov <alchark@gmail.com> |
---|
5 | 6 | * |
---|
6 | 7 | * Based on rtc-pxa.c |
---|
7 | | - * |
---|
8 | | - * This software is licensed under the terms of the GNU General Public |
---|
9 | | - * License version 2, as published by the Free Software Foundation, and |
---|
10 | | - * may be copied, distributed, and modified under those terms. |
---|
11 | | - * |
---|
12 | | - * This program is distributed in the hope that it will be useful, |
---|
13 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | | - * GNU General Public License for more details. |
---|
16 | 8 | */ |
---|
17 | 9 | |
---|
18 | 10 | #include <linux/module.h> |
---|
.. | .. |
---|
130 | 122 | { |
---|
131 | 123 | struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev); |
---|
132 | 124 | |
---|
133 | | - if (tm->tm_year < 100) { |
---|
134 | | - dev_warn(dev, "Only years 2000-2199 are supported by the " |
---|
135 | | - "hardware!\n"); |
---|
136 | | - return -EINVAL; |
---|
137 | | - } |
---|
138 | | - |
---|
139 | 125 | writel((bin2bcd(tm->tm_year % 100) << DATE_YEAR_S) |
---|
140 | 126 | | (bin2bcd(tm->tm_mon + 1) << DATE_MONTH_S) |
---|
141 | 127 | | (bin2bcd(tm->tm_mday)) |
---|
.. | .. |
---|
208 | 194 | static int vt8500_rtc_probe(struct platform_device *pdev) |
---|
209 | 195 | { |
---|
210 | 196 | struct vt8500_rtc *vt8500_rtc; |
---|
211 | | - struct resource *res; |
---|
212 | 197 | int ret; |
---|
213 | 198 | |
---|
214 | 199 | vt8500_rtc = devm_kzalloc(&pdev->dev, |
---|
.. | .. |
---|
220 | 205 | platform_set_drvdata(pdev, vt8500_rtc); |
---|
221 | 206 | |
---|
222 | 207 | vt8500_rtc->irq_alarm = platform_get_irq(pdev, 0); |
---|
223 | | - if (vt8500_rtc->irq_alarm < 0) { |
---|
224 | | - dev_err(&pdev->dev, "No alarm IRQ resource defined\n"); |
---|
| 208 | + if (vt8500_rtc->irq_alarm < 0) |
---|
225 | 209 | return vt8500_rtc->irq_alarm; |
---|
226 | | - } |
---|
227 | 210 | |
---|
228 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
---|
229 | | - vt8500_rtc->regbase = devm_ioremap_resource(&pdev->dev, res); |
---|
| 211 | + vt8500_rtc->regbase = devm_platform_ioremap_resource(pdev, 0); |
---|
230 | 212 | if (IS_ERR(vt8500_rtc->regbase)) |
---|
231 | 213 | return PTR_ERR(vt8500_rtc->regbase); |
---|
232 | 214 | |
---|
.. | .. |
---|
234 | 216 | writel(VT8500_RTC_CR_ENABLE, |
---|
235 | 217 | vt8500_rtc->regbase + VT8500_RTC_CR); |
---|
236 | 218 | |
---|
237 | | - vt8500_rtc->rtc = devm_rtc_device_register(&pdev->dev, "vt8500-rtc", |
---|
238 | | - &vt8500_rtc_ops, THIS_MODULE); |
---|
239 | | - if (IS_ERR(vt8500_rtc->rtc)) { |
---|
240 | | - ret = PTR_ERR(vt8500_rtc->rtc); |
---|
241 | | - dev_err(&pdev->dev, |
---|
242 | | - "Failed to register RTC device -> %d\n", ret); |
---|
243 | | - goto err_return; |
---|
244 | | - } |
---|
| 219 | + vt8500_rtc->rtc = devm_rtc_allocate_device(&pdev->dev); |
---|
| 220 | + if (IS_ERR(vt8500_rtc->rtc)) |
---|
| 221 | + return PTR_ERR(vt8500_rtc->rtc); |
---|
| 222 | + |
---|
| 223 | + vt8500_rtc->rtc->ops = &vt8500_rtc_ops; |
---|
| 224 | + vt8500_rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; |
---|
| 225 | + vt8500_rtc->rtc->range_max = RTC_TIMESTAMP_END_2199; |
---|
245 | 226 | |
---|
246 | 227 | ret = devm_request_irq(&pdev->dev, vt8500_rtc->irq_alarm, |
---|
247 | 228 | vt8500_rtc_irq, 0, "rtc alarm", vt8500_rtc); |
---|
248 | 229 | if (ret < 0) { |
---|
249 | 230 | dev_err(&pdev->dev, "can't get irq %i, err %d\n", |
---|
250 | 231 | vt8500_rtc->irq_alarm, ret); |
---|
251 | | - goto err_return; |
---|
| 232 | + return ret; |
---|
252 | 233 | } |
---|
253 | 234 | |
---|
254 | | - return 0; |
---|
255 | | - |
---|
256 | | -err_return: |
---|
257 | | - return ret; |
---|
| 235 | + return rtc_register_device(vt8500_rtc->rtc); |
---|
258 | 236 | } |
---|
259 | 237 | |
---|
260 | 238 | static int vt8500_rtc_remove(struct platform_device *pdev) |
---|