All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	geert@linux-m68k.org, deller@gmx.de, benh@kernel.crashing.org,
	mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com,
	linux-alpha@vger.kernel.org, a.zummo@towertech.it,
	linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org,
	linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com,
	linux-arch@vger.kernel.org
Subject: [PATCH v2 5/6] rtc: sh: provide rtc_class_ops directly
Date: Tue, 26 Apr 2016 21:52:30 +0000	[thread overview]
Message-ID: <1461707551-1337971-6-git-send-email-arnd@arndb.de> (raw)
In-Reply-To: <1461707551-1337971-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 on sh, that goes through another indirection using
the rtc_sh_get_time/rtc_sh_set_time functions.

This changes the sh rtc-generic device to provide its
rtc_class_ops directly, skipping one of the abstraction
levels.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/sh/kernel/time.c | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c
index d6d0a986c6e9..92cd676970d9 100644
--- a/arch/sh/kernel/time.c
+++ b/arch/sh/kernel/time.c
@@ -50,27 +50,30 @@ int update_persistent_clock(struct timespec now)
 }
 #endif
 
-unsigned int get_rtc_time(struct rtc_time *tm)
+static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm)
 {
-	if (rtc_sh_get_time != null_rtc_get_time) {
-		struct timespec tv;
+	struct timespec tv;
 
-		rtc_sh_get_time(&tv);
-		rtc_time_to_tm(tv.tv_sec, tm);
-	}
-
-	return RTC_24H;
+	rtc_sh_get_time(&tv);
+	rtc_time_to_tm(tv.tv_sec, tm);
+	return 0;
 }
-EXPORT_SYMBOL(get_rtc_time);
 
-int set_rtc_time(struct rtc_time *tm)
+static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm)
 {
 	unsigned long secs;
 
 	rtc_tm_to_time(tm, &secs);
-	return rtc_sh_set_time(secs);
+	if (!rtc_sh_set_time || rtc_sh_set_time(secs) < 0)
+		return -EOPNOTSUPP;
+
+	return 0;
 }
-EXPORT_SYMBOL(set_rtc_time);
+
+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_generic_init(void)
 {
@@ -79,7 +82,10 @@ static int __init rtc_generic_init(void)
 	if (rtc_sh_get_time = null_rtc_get_time)
 		return -ENODEV;
 
-	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);
 }
-- 
2.7.0


WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	geert@linux-m68k.org, deller@gmx.de, benh@kernel.crashing.org,
	mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com,
	linux-alpha@vger.kernel.org, a.zummo@towertech.it,
	linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org,
	linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com,
	linux-arch@vger.kernel.org
Subject: [PATCH v2 5/6] rtc: sh: provide rtc_class_ops directly
Date: Tue, 26 Apr 2016 23:52:30 +0200	[thread overview]
Message-ID: <1461707551-1337971-6-git-send-email-arnd@arndb.de> (raw)
In-Reply-To: <1461707551-1337971-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 on sh, that goes through another indirection using
the rtc_sh_get_time/rtc_sh_set_time functions.

This changes the sh rtc-generic device to provide its
rtc_class_ops directly, skipping one of the abstraction
levels.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/sh/kernel/time.c | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c
index d6d0a986c6e9..92cd676970d9 100644
--- a/arch/sh/kernel/time.c
+++ b/arch/sh/kernel/time.c
@@ -50,27 +50,30 @@ int update_persistent_clock(struct timespec now)
 }
 #endif
 
-unsigned int get_rtc_time(struct rtc_time *tm)
+static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm)
 {
-	if (rtc_sh_get_time != null_rtc_get_time) {
-		struct timespec tv;
+	struct timespec tv;
 
-		rtc_sh_get_time(&tv);
-		rtc_time_to_tm(tv.tv_sec, tm);
-	}
-
-	return RTC_24H;
+	rtc_sh_get_time(&tv);
+	rtc_time_to_tm(tv.tv_sec, tm);
+	return 0;
 }
-EXPORT_SYMBOL(get_rtc_time);
 
-int set_rtc_time(struct rtc_time *tm)
+static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm)
 {
 	unsigned long secs;
 
 	rtc_tm_to_time(tm, &secs);
-	return rtc_sh_set_time(secs);
+	if (!rtc_sh_set_time || rtc_sh_set_time(secs) < 0)
+		return -EOPNOTSUPP;
+
+	return 0;
 }
-EXPORT_SYMBOL(set_rtc_time);
+
+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_generic_init(void)
 {
@@ -79,7 +82,10 @@ static int __init rtc_generic_init(void)
 	if (rtc_sh_get_time == null_rtc_get_time)
 		return -ENODEV;
 
-	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);
 }
-- 
2.7.0

WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	geert@linux-m68k.org, deller@gmx.de, benh@kernel.crashing.org,
	mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com,
	linux-alpha@vger.kernel.org, a.zummo@towertech.it,
	linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org,
	linux-m68k@vger.kernel.org, rtc-linux@googlegroups.com,
	linux-arch@vger.kernel.org
Subject: [PATCH v2 5/6] rtc: sh: provide rtc_class_ops directly
Date: Tue, 26 Apr 2016 23:52:30 +0200	[thread overview]
Message-ID: <1461707551-1337971-6-git-send-email-arnd@arndb.de> (raw)
In-Reply-To: <1461707551-1337971-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 on sh, that goes through another indirection using
the rtc_sh_get_time/rtc_sh_set_time functions.

This changes the sh rtc-generic device to provide its
rtc_class_ops directly, skipping one of the abstraction
levels.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/sh/kernel/time.c | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c
index d6d0a986c6e9..92cd676970d9 100644
--- a/arch/sh/kernel/time.c
+++ b/arch/sh/kernel/time.c
@@ -50,27 +50,30 @@ int update_persistent_clock(struct timespec now)
 }
 #endif
 
-unsigned int get_rtc_time(struct rtc_time *tm)
+static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm)
 {
-	if (rtc_sh_get_time != null_rtc_get_time) {
-		struct timespec tv;
+	struct timespec tv;
 
-		rtc_sh_get_time(&tv);
-		rtc_time_to_tm(tv.tv_sec, tm);
-	}
-
-	return RTC_24H;
+	rtc_sh_get_time(&tv);
+	rtc_time_to_tm(tv.tv_sec, tm);
+	return 0;
 }
-EXPORT_SYMBOL(get_rtc_time);
 
-int set_rtc_time(struct rtc_time *tm)
+static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm)
 {
 	unsigned long secs;
 
 	rtc_tm_to_time(tm, &secs);
-	return rtc_sh_set_time(secs);
+	if (!rtc_sh_set_time || rtc_sh_set_time(secs) < 0)
+		return -EOPNOTSUPP;
+
+	return 0;
 }
-EXPORT_SYMBOL(set_rtc_time);
+
+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_generic_init(void)
 {
@@ -79,7 +82,10 @@ static int __init rtc_generic_init(void)
 	if (rtc_sh_get_time == null_rtc_get_time)
 		return -ENODEV;
 
-	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);
 }
-- 
2.7.0

WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	geert@linux-m68k.org, deller@gmx.de, benh@kernel.crashing.org,
	mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com,
	linux-alpha@vger.kernel.org, a.zummo@towertech.it,
	linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org,
	linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com,
	linux-arch@vger.kernel.org
Subject: [rtc-linux] [PATCH v2 5/6] rtc: sh: provide rtc_class_ops directly
Date: Tue, 26 Apr 2016 23:52:30 +0200	[thread overview]
Message-ID: <1461707551-1337971-6-git-send-email-arnd@arndb.de> (raw)
In-Reply-To: <1461707551-1337971-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 on sh, that goes through another indirection using
the rtc_sh_get_time/rtc_sh_set_time functions.

This changes the sh rtc-generic device to provide its
rtc_class_ops directly, skipping one of the abstraction
levels.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/sh/kernel/time.c | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c
index d6d0a986c6e9..92cd676970d9 100644
--- a/arch/sh/kernel/time.c
+++ b/arch/sh/kernel/time.c
@@ -50,27 +50,30 @@ int update_persistent_clock(struct timespec now)
 }
 #endif
 
-unsigned int get_rtc_time(struct rtc_time *tm)
+static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm)
 {
-	if (rtc_sh_get_time != null_rtc_get_time) {
-		struct timespec tv;
+	struct timespec tv;
 
-		rtc_sh_get_time(&tv);
-		rtc_time_to_tm(tv.tv_sec, tm);
-	}
-
-	return RTC_24H;
+	rtc_sh_get_time(&tv);
+	rtc_time_to_tm(tv.tv_sec, tm);
+	return 0;
 }
-EXPORT_SYMBOL(get_rtc_time);
 
-int set_rtc_time(struct rtc_time *tm)
+static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm)
 {
 	unsigned long secs;
 
 	rtc_tm_to_time(tm, &secs);
-	return rtc_sh_set_time(secs);
+	if (!rtc_sh_set_time || rtc_sh_set_time(secs) < 0)
+		return -EOPNOTSUPP;
+
+	return 0;
 }
-EXPORT_SYMBOL(set_rtc_time);
+
+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_generic_init(void)
 {
@@ -79,7 +82,10 @@ static int __init rtc_generic_init(void)
 	if (rtc_sh_get_time == null_rtc_get_time)
 		return -ENODEV;
 
-	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);
 }
-- 
2.7.0

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

  parent reply	other threads:[~2016-04-26 21:52 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-26 21:52 [PATCH v2 0/6] simplify rtc-generic driver Arnd Bergmann
2016-04-26 21:52 ` [rtc-linux] " Arnd Bergmann
2016-04-26 21:52 ` Arnd Bergmann
2016-04-26 21:52 ` Arnd Bergmann
2016-04-26 21:52 ` [PATCH v2 1/6] rtc: m68k: provide rtc_class_ops directly Arnd Bergmann
2016-04-26 21:52 ` Arnd Bergmann
2016-04-26 21:52   ` [rtc-linux] " Arnd Bergmann
2016-04-26 21:52   ` Arnd Bergmann
2016-04-26 21:52   ` Arnd Bergmann
2016-04-27  7:47   ` Geert Uytterhoeven
2016-04-27  7:47     ` [rtc-linux] " Geert Uytterhoeven
2016-04-27  7:47     ` Geert Uytterhoeven
2016-04-27  7:47     ` Geert Uytterhoeven
2016-04-27 10:34     ` Arnd Bergmann
2016-04-27 10:34       ` [rtc-linux] " Arnd Bergmann
2016-04-27 10:34       ` Arnd Bergmann
2016-04-27 10:34       ` Arnd Bergmann
2016-04-26 21:52 ` [PATCH v2 2/6] rtc: m68k: provide ioctl for q40 Arnd Bergmann
2016-04-26 21:52   ` [rtc-linux] " Arnd Bergmann
2016-04-26 21:52   ` Arnd Bergmann
2016-04-26 21:52   ` Arnd Bergmann
2016-04-26 21:52 ` Arnd Bergmann
2016-04-26 21:52 ` [PATCH v2 3/6] rtc: powerpc: provide rtc_class_ops directly Arnd Bergmann
2016-04-26 21:52   ` [rtc-linux] " Arnd Bergmann
2016-04-26 21:52   ` Arnd Bergmann
2016-04-26 21:52   ` Arnd Bergmann
2016-04-26 21:52 ` [PATCH v2 4/6] rtc: parisc: " Arnd Bergmann
2016-04-26 21:52 ` Arnd Bergmann
2016-04-26 21:52   ` [rtc-linux] " Arnd Bergmann
2016-04-26 21:52   ` Arnd Bergmann
2016-04-26 21:52   ` Arnd Bergmann
2016-04-27  0:22   ` kbuild test robot
2016-04-27  0:22     ` kbuild test robot
2016-04-27  0:22     ` kbuild test robot
2016-04-27  0:22     ` [rtc-linux] " kbuild test robot
2016-04-27  0:22     ` kbuild test robot
2016-04-27  0:22     ` kbuild test robot
2016-04-27 10:10     ` Arnd Bergmann
2016-04-27 10:10       ` [rtc-linux] " Arnd Bergmann
2016-04-27 10:10       ` Arnd Bergmann
2016-04-27 10:10       ` Arnd Bergmann
2016-04-26 21:52 ` Arnd Bergmann [this message]
2016-04-26 21:52   ` [rtc-linux] [PATCH v2 5/6] rtc: sh: " Arnd Bergmann
2016-04-26 21:52   ` Arnd Bergmann
2016-04-26 21:52   ` Arnd Bergmann
2016-04-26 21:52 ` [PATCH v2 6/6] rtc: generic: remove get_rtc_time/set_rtc_time wrappers Arnd Bergmann
2016-04-26 21:52 ` Arnd Bergmann
2016-04-26 21:52   ` Arnd Bergmann
2016-04-26 21:52   ` [rtc-linux] " Arnd Bergmann
2016-04-26 21:52   ` Arnd Bergmann
2016-04-26 21:52   ` Arnd Bergmann
2016-04-27  7:50 ` [PATCH v2 0/6] simplify rtc-generic driver Geert Uytterhoeven
2016-04-27  7:50   ` [rtc-linux] " Geert Uytterhoeven
2016-04-27  7:50   ` Geert Uytterhoeven
2016-04-27  7:50   ` Geert Uytterhoeven
2016-04-27  7:50 ` Geert Uytterhoeven

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=1461707551-1337971-6-git-send-email-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=benh@kernel.crashing.org \
    --cc=dalias@libc.org \
    --cc=deller@gmx.de \
    --cc=dhowells@redhat.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.