hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/rtc/rtc-da9052.c
....@@ -1,15 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Real time clock driver for DA9052
34 *
45 * Copyright(c) 2012 Dialog Semiconductor Ltd.
56 *
67 * Author: Dajun Dajun Chen <dajun.chen@diasemi.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version.
12
- *
138 */
149
1510 #include <linux/module.h>
....@@ -108,13 +103,11 @@
108103 int ret;
109104 uint8_t v[3];
110105
111
- ret = rtc_tm_to_time(rtc_tm, &alm_time);
112
- if (ret != 0)
113
- return ret;
106
+ alm_time = rtc_tm_to_time64(rtc_tm);
114107
115108 if (rtc_tm->tm_sec > 0) {
116109 alm_time += 60 - rtc_tm->tm_sec;
117
- rtc_time_to_tm(alm_time, rtc_tm);
110
+ rtc_time64_to_tm(alm_time, rtc_tm);
118111 }
119112 BUG_ON(rtc_tm->tm_sec); /* it will cause repeated irqs if not zero */
120113
....@@ -303,12 +296,18 @@
303296 rtc_err(rtc, "Failed to disable TICKS: %d\n", ret);
304297
305298 device_init_wakeup(&pdev->dev, true);
306
- rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
307
- &da9052_rtc_ops, THIS_MODULE);
308
-
299
+ rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
309300 if (IS_ERR(rtc->rtc))
310301 return PTR_ERR(rtc->rtc);
311302
303
+ rtc->rtc->ops = &da9052_rtc_ops;
304
+ rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
305
+ rtc->rtc->range_max = RTC_TIMESTAMP_END_2063;
306
+
307
+ ret = rtc_register_device(rtc->rtc);
308
+ if (ret)
309
+ return ret;
310
+
312311 ret = da9052_request_irq(rtc->da9052, DA9052_IRQ_ALARM, "ALM",
313312 da9052_rtc_irq, rtc);
314313 if (ret != 0) {