From: Arnd Bergmann <arnd@arndb.de>
To: Alexandre Belloni <alexandre.belloni@free-electrons.com>,
Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-arm-kernel@lists.infradead.org,
Kyle McMartin <kyle@mcmartin.ca>,
rtc-linux@googlegroups.com,
Alessandro Zummo <a.zummo@towertech.it>,
linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org,
linux-parisc@vger.kernel.org, linux-m68k@vger.kernel.org,
Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/6] m68k: rtc: provide rtc_class_ops directly
Date: Tue, 1 Mar 2016 17:59:58 +0100 [thread overview]
Message-ID: <1456851608-3374907-3-git-send-email-arnd@arndb.de> (raw)
In-Reply-To: <1456851608-3374907-1-git-send-email-arnd@arndb.de>
The rtc-generic driver provides an architecture specific
wrapper on top of the generic rtc_class_ops abstraction,
and m68k has another abstraction on top, which is a bit
silly.
This changes the m68k rtc-generic device to provide its
rtc_class_ops directly, to reduce the number of layers
by one.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/m68k/kernel/time.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c
index 3857737e3958..773b2187210d 100644
--- a/arch/m68k/kernel/time.c
+++ b/arch/m68k/kernel/time.c
@@ -87,6 +87,23 @@ void read_persistent_clock(struct timespec *ts)
}
#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
+static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm)
+{
+ mach_hwclk(0, tm);
+ return rtc_valid_tm(tm);
+}
+
+static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm)
+{
+ if (mach_hwclk(1, tm) < 0)
+ return -EOPNOTSUPP;
+ return 0;
+}
+
+static const struct rtc_class_ops generic_rtc_ops = {
+ .read_time = rtc_generic_get_time,
+ .set_time = rtc_generic_set_time,
+};
static int __init rtc_init(void)
{
@@ -95,7 +112,10 @@ static int __init rtc_init(void)
if (!mach_hwclk)
return -ENODEV;
- pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0);
+ /* or just call devm_rtc_device_register instead? */
+ pdev = platform_device_register_data(NULL, "rtc-generic", -1,
+ &generic_rtc_ops,
+ sizeof(generic_rtc_ops));
return PTR_ERR_OR_ZERO(pdev);
}
--
2.7.0
next prev parent reply other threads:[~2016-03-01 17:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1456851608-3374907-1-git-send-email-arnd@arndb.de>
2016-03-01 16:59 ` [PATCH 1/6] rtc: generic: allow building on all architectures Arnd Bergmann
2016-03-02 8:57 ` Geert Uytterhoeven
2016-03-02 9:05 ` Arnd Bergmann
2016-03-02 9:28 ` Andreas Schwab
2016-03-02 9:39 ` Geert Uytterhoeven
2016-03-01 16:59 ` Arnd Bergmann [this message]
2016-03-01 16:59 ` [PATCH 3/6] powerpc: rtc: provide rtc_class_ops directly Arnd Bergmann
2016-03-01 18:37 ` kbuild test robot
2016-03-01 20:31 ` Arnd Bergmann
2016-03-01 17:00 ` [PATCH 4/6] parisc: " Arnd Bergmann
2016-03-01 17:19 ` kbuild test robot
2016-03-10 4:34 ` Alexandre Belloni
2016-03-01 17:00 ` [PATCH 5/6] sh: " Arnd Bergmann
2016-03-01 17:00 ` [PATCH 6/6] rtc: generic: remove get_rtc_time/set_rtc_time wrappers Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456851608-3374907-3-git-send-email-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@free-electrons.com \
--cc=geert@linux-m68k.org \
--cc=kyle@mcmartin.ca \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=rtc-linux@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox