[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1456851608-3374907-5-git-send-email-arnd@arndb.de>
Date: Tue, 1 Mar 2016 18:00:00 +0100
From: Arnd Bergmann <arnd@...db.de>
To: Alexandre Belloni <alexandre.belloni@...e-electrons.com>
Cc: linux-arm-kernel@...ts.infradead.org,
Kyle McMartin <kyle@...artin.ca>, rtc-linux@...glegroups.com,
Alessandro Zummo <a.zummo@...ertech.it>,
linuxppc-dev@...ts.ozlabs.org, linux-sh@...r.kernel.org,
linux-parisc@...r.kernel.org, linux-m68k@...ts.linux-m68k.org,
Arnd Bergmann <arnd@...db.de>,
"James E.J. Bottomley" <jejb@...isc-linux.org>,
Helge Deller <deller@....de>, linux-kernel@...r.kernel.org
Subject: [PATCH 4/6] parisc: rtc: provide rtc_class_ops directly
The rtc-generic driver provides an architecture specific
wrapper on top of the generic rtc_class_ops abstraction,
and on pa-risc, that is implemented using an open-coded
version of rtc_time_to_tm/rtc_tm_to_time.
This changes the parisc rtc-generic device to provide its
rtc_class_ops directly, using the normal helper functions,
which makes this y2038 safe (on 32-bit) and simplifies
the implementation.
Signed-off-by: Arnd Bergmann <arnd@...db.de>
---
arch/parisc/kernel/time.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c
index 400acac0a304..176ef5c2aa82 100644
--- a/arch/parisc/kernel/time.c
+++ b/arch/parisc/kernel/time.c
@@ -12,6 +12,7 @@
*/
#include <linux/errno.h>
#include <linux/module.h>
+#include <linux/rtc.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/param.h>
@@ -224,11 +225,43 @@ void __init start_cpu_itimer(void)
per_cpu(cpu_data, cpu).it_value = next_tick;
}
+static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm)
+{
+ struct pdc_tod tod_data;
+
+ memset(wtime, 0, sizeof(*wtime));
+ if (pdc_tod_read(&tod_data) < 0)
+ return -EOPNOTSUPP;
+
+ /* we treat tod_sec as unsigned, so this can work until year 2106 */
+ rtc_time64_to_tm(tod_data.tod_sec, &tm);
+ return rtc_valid_tm(tm);
+}
+
+static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm)
+{
+ time64_t secs = rtc_tm_to_time64(tm);
+
+ if (pdc_tod_set(secs, 0) < 0)
+ return -EOPNOTSUPP;
+
+ return 0;
+}
+
+static const struct rtc_class_ops rtc_generic_ops = {
+ .read_time = rtc_generic_get_time,
+ .set_time = rtc_generic_set_time,
+};
+
static int __init rtc_init(void)
{
struct platform_device *pdev;
- pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0);
+ pdev = platform_device_register_data(NULL, "rtc-generic", -1,
+ &rtc_generic_ops,
+ sizeof(rtc_generic_ops));
+
+
return PTR_ERR_OR_ZERO(pdev);
}
device_initcall(rtc_init);
--
2.7.0
Powered by blists - more mailing lists