hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/rtc/rtc-vt8500.c
....@@ -1,18 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * drivers/rtc/rtc-vt8500.c
34 *
45 * Copyright (C) 2010 Alexey Charkov <alchark@gmail.com>
56 *
67 * 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.
168 */
179
1810 #include <linux/module.h>
....@@ -130,12 +122,6 @@
130122 {
131123 struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev);
132124
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
-
139125 writel((bin2bcd(tm->tm_year % 100) << DATE_YEAR_S)
140126 | (bin2bcd(tm->tm_mon + 1) << DATE_MONTH_S)
141127 | (bin2bcd(tm->tm_mday))
....@@ -208,7 +194,6 @@
208194 static int vt8500_rtc_probe(struct platform_device *pdev)
209195 {
210196 struct vt8500_rtc *vt8500_rtc;
211
- struct resource *res;
212197 int ret;
213198
214199 vt8500_rtc = devm_kzalloc(&pdev->dev,
....@@ -220,13 +205,10 @@
220205 platform_set_drvdata(pdev, vt8500_rtc);
221206
222207 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)
225209 return vt8500_rtc->irq_alarm;
226
- }
227210
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);
230212 if (IS_ERR(vt8500_rtc->regbase))
231213 return PTR_ERR(vt8500_rtc->regbase);
232214
....@@ -234,27 +216,23 @@
234216 writel(VT8500_RTC_CR_ENABLE,
235217 vt8500_rtc->regbase + VT8500_RTC_CR);
236218
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;
245226
246227 ret = devm_request_irq(&pdev->dev, vt8500_rtc->irq_alarm,
247228 vt8500_rtc_irq, 0, "rtc alarm", vt8500_rtc);
248229 if (ret < 0) {
249230 dev_err(&pdev->dev, "can't get irq %i, err %d\n",
250231 vt8500_rtc->irq_alarm, ret);
251
- goto err_return;
232
+ return ret;
252233 }
253234
254
- return 0;
255
-
256
-err_return:
257
- return ret;
235
+ return rtc_register_device(vt8500_rtc->rtc);
258236 }
259237
260238 static int vt8500_rtc_remove(struct platform_device *pdev)