hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/rtc/rtc-armada38x.c
....@@ -1,15 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * RTC driver for the Armada 38x Marvell SoCs
34 *
45 * Copyright (C) 2015 Marvell
56 *
67 * Gregory Clement <gregory.clement@free-electrons.com>
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU General Public License as
10
- * published by the Free Software Foundation; either version 2 of the
11
- * License, or (at your option) any later version.
12
- *
138 */
149
1510 #include <linux/delay.h>
....@@ -79,7 +74,7 @@
7974 int irq;
8075 bool initialized;
8176 struct value_to_freq *val_to_freq;
82
- struct armada38x_rtc_data *data;
77
+ const struct armada38x_rtc_data *data;
8378 };
8479
8580 #define ALARM1 0
....@@ -224,7 +219,7 @@
224219 time = rtc->data->read_rtc_reg(rtc, RTC_TIME);
225220 spin_unlock_irqrestore(&rtc->lock, flags);
226221
227
- rtc_time_to_tm(time, tm);
222
+ rtc_time64_to_tm(time, tm);
228223
229224 return 0;
230225 }
....@@ -249,13 +244,9 @@
249244 static int armada38x_rtc_set_time(struct device *dev, struct rtc_time *tm)
250245 {
251246 struct armada38x_rtc *rtc = dev_get_drvdata(dev);
252
- int ret = 0;
253247 unsigned long time, flags;
254248
255
- ret = rtc_tm_to_time(tm, &time);
256
-
257
- if (ret)
258
- goto out;
249
+ time = rtc_tm_to_time64(tm);
259250
260251 if (!rtc->initialized)
261252 armada38x_rtc_reset(rtc);
....@@ -264,8 +255,7 @@
264255 rtc_delayed_write(time, rtc, RTC_TIME);
265256 spin_unlock_irqrestore(&rtc->lock, flags);
266257
267
-out:
268
- return ret;
258
+ return 0;
269259 }
270260
271261 static int armada38x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
....@@ -284,7 +274,7 @@
284274 spin_unlock_irqrestore(&rtc->lock, flags);
285275
286276 alrm->enabled = val ? 1 : 0;
287
- rtc_time_to_tm(time, &alrm->time);
277
+ rtc_time64_to_tm(time, &alrm->time);
288278
289279 return 0;
290280 }
....@@ -295,12 +285,8 @@
295285 u32 reg = ALARM_REG(RTC_ALARM1, rtc->data->alarm);
296286 u32 reg_irq = ALARM_REG(RTC_IRQ1_CONF, rtc->data->alarm);
297287 unsigned long time, flags;
298
- int ret = 0;
299288
300
- ret = rtc_tm_to_time(&alrm->time, &time);
301
-
302
- if (ret)
303
- goto out;
289
+ time = rtc_tm_to_time64(&alrm->time);
304290
305291 spin_lock_irqsave(&rtc->lock, flags);
306292
....@@ -313,8 +299,7 @@
313299
314300 spin_unlock_irqrestore(&rtc->lock, flags);
315301
316
-out:
317
- return ret;
302
+ return 0;
318303 }
319304
320305 static int armada38x_rtc_alarm_irq_enable(struct device *dev,
....@@ -516,17 +501,13 @@
516501 {
517502 struct resource *res;
518503 struct armada38x_rtc *rtc;
519
- const struct of_device_id *match;
520
- int ret;
521
-
522
- match = of_match_device(armada38x_rtc_of_match_table, &pdev->dev);
523
- if (!match)
524
- return -ENODEV;
525504
526505 rtc = devm_kzalloc(&pdev->dev, sizeof(struct armada38x_rtc),
527506 GFP_KERNEL);
528507 if (!rtc)
529508 return -ENOMEM;
509
+
510
+ rtc->data = of_device_get_match_data(&pdev->dev);
530511
531512 rtc->val_to_freq = devm_kcalloc(&pdev->dev, SAMPLE_NR,
532513 sizeof(struct value_to_freq), GFP_KERNEL);
....@@ -545,11 +526,8 @@
545526 return PTR_ERR(rtc->regs_soc);
546527
547528 rtc->irq = platform_get_irq(pdev, 0);
548
-
549
- if (rtc->irq < 0) {
550
- dev_err(&pdev->dev, "no irq\n");
529
+ if (rtc->irq < 0)
551530 return rtc->irq;
552
- }
553531
554532 rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
555533 if (IS_ERR(rtc->rtc_dev))
....@@ -572,16 +550,13 @@
572550 */
573551 rtc->rtc_dev->ops = &armada38x_rtc_ops_noirq;
574552 }
575
- rtc->data = (struct armada38x_rtc_data *)match->data;
576553
577554 /* Update RTC-MBUS bridge timing parameters */
578555 rtc->data->update_mbus_timing(rtc);
579556
580
- ret = rtc_register_device(rtc->rtc_dev);
581
- if (ret)
582
- dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret);
557
+ rtc->rtc_dev->range_max = U32_MAX;
583558
584
- return ret;
559
+ return rtc_register_device(rtc->rtc_dev);
585560 }
586561
587562 #ifdef CONFIG_PM_SLEEP