hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/rtc/rtc-mc13xxx.c
....@@ -1,12 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Real Time Clock driver for Freescale MC13XXX PMIC
34 *
45 * (C) 2009 Sascha Hauer, Pengutronix
56 * (C) 2009 Uwe Kleine-Koenig, Pengutronix
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
107 */
118
129 #include <linux/mfd/mc13xxx.h>
....@@ -89,14 +86,14 @@
8986 return 0;
9087 }
9188
92
-static int mc13xxx_rtc_set_mmss(struct device *dev, time64_t secs)
89
+static int mc13xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
9390 {
9491 struct mc13xxx_rtc *priv = dev_get_drvdata(dev);
9592 unsigned int seconds, days;
9693 unsigned int alarmseconds;
9794 int ret;
9895
99
- days = div_s64_rem(secs, SEC_PER_DAY, &seconds);
96
+ days = div_s64_rem(rtc_tm_to_time64(tm), SEC_PER_DAY, &seconds);
10097
10198 mc13xxx_lock(priv->mc13xxx);
10299
....@@ -158,7 +155,7 @@
158155 static int mc13xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
159156 {
160157 struct mc13xxx_rtc *priv = dev_get_drvdata(dev);
161
- unsigned seconds, days;
158
+ unsigned int seconds, days;
162159 time64_t s1970;
163160 int enabled, pending;
164161 int ret;
....@@ -253,7 +250,7 @@
253250
254251 static const struct rtc_class_ops mc13xxx_rtc_ops = {
255252 .read_time = mc13xxx_rtc_read_time,
256
- .set_mmss64 = mc13xxx_rtc_set_mmss,
253
+ .set_time = mc13xxx_rtc_set_time,
257254 .read_alarm = mc13xxx_rtc_read_alarm,
258255 .set_alarm = mc13xxx_rtc_set_alarm,
259256 .alarm_irq_enable = mc13xxx_rtc_alarm_irq_enable,
....@@ -285,7 +282,14 @@
285282 priv->mc13xxx = mc13xxx;
286283 priv->valid = 1;
287284
285
+ priv->rtc = devm_rtc_allocate_device(&pdev->dev);
286
+ if (IS_ERR(priv->rtc))
287
+ return PTR_ERR(priv->rtc);
288288 platform_set_drvdata(pdev, priv);
289
+
290
+ priv->rtc->ops = &mc13xxx_rtc_ops;
291
+ /* 15bit days + hours, minutes, seconds */
292
+ priv->rtc->range_max = (timeu64_t)(1 << 15) * SEC_PER_DAY - 1;
289293
290294 mc13xxx_lock(mc13xxx);
291295
....@@ -303,8 +307,11 @@
303307
304308 mc13xxx_unlock(mc13xxx);
305309
306
- priv->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
307
- &mc13xxx_rtc_ops, THIS_MODULE);
310
+ ret = rtc_register_device(priv->rtc);
311
+ if (ret) {
312
+ mc13xxx_lock(mc13xxx);
313
+ goto err_irq_request;
314
+ }
308315
309316 return 0;
310317