public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] rtc: generic: allow building on all architectures
       [not found] <1456851608-3374907-1-git-send-email-arnd@arndb.de>
@ 2016-03-01 16:59 ` Arnd Bergmann
  2016-03-02  8:57   ` Geert Uytterhoeven
  2016-03-01 16:59 ` [PATCH 2/6] m68k: rtc: provide rtc_class_ops directly Arnd Bergmann
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Arnd Bergmann @ 2016-03-01 16:59 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: linux-arm-kernel, Kyle McMartin, rtc-linux, Alessandro Zummo,
	linuxppc-dev, linux-sh, linux-parisc, linux-m68k, Arnd Bergmann,
	linux-kernel

There are four architectures using this driver, but since we can
build it with COMPILE_TEST, we should try dealing with the absence
of the asm/rtc.h header file, to avoid getting a build error:

drivers/rtc/rtc-generic.c:12:21: fatal error: asm/rtc.h: No such file or directory

This creates an alternative use of the driver, allowing architectures
to pass a set of rtc_class_ops in platform data. We can convert the
four architectures to use this and then remove the original
code.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/rtc/rtc-generic.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-generic.c b/drivers/rtc/rtc-generic.c
index e782ebd719b2..d726c6aa96a8 100644
--- a/drivers/rtc/rtc-generic.c
+++ b/drivers/rtc/rtc-generic.c
@@ -9,6 +9,8 @@
 #include <linux/platform_device.h>
 #include <linux/rtc.h>
 
+#if defined(CONFIG_M68K) || defined(CONFIG_PARISC) || \
+    defined(CONFIG_PPC) || defined(CONFIG_SUPERH32)
 #include <asm/rtc.h>
 
 static int generic_get_time(struct device *dev, struct rtc_time *tm)
@@ -33,13 +35,21 @@ static const struct rtc_class_ops generic_rtc_ops = {
 	.read_time = generic_get_time,
 	.set_time = generic_set_time,
 };
+#else
+#define generic_rtc_ops *(struct rtc_class_ops*)NULL
+#endif
 
 static int __init generic_rtc_probe(struct platform_device *dev)
 {
 	struct rtc_device *rtc;
+	const struct rtc_class_ops *ops;
+
+	ops = dev_get_platdata(&dev->dev);
+	if (!ops)
+		ops = &generic_rtc_ops;
 
 	rtc = devm_rtc_device_register(&dev->dev, "rtc-generic",
-					&generic_rtc_ops, THIS_MODULE);
+					ops, THIS_MODULE);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/6] m68k: rtc: provide rtc_class_ops directly
       [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-01 16:59 ` Arnd Bergmann
  2016-03-01 16:59 ` [PATCH 3/6] powerpc: " Arnd Bergmann
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Arnd Bergmann @ 2016-03-01 16:59 UTC (permalink / raw)
  To: Alexandre Belloni, Geert Uytterhoeven
  Cc: linux-arm-kernel, Kyle McMartin, rtc-linux, Alessandro Zummo,
	linuxppc-dev, linux-sh, linux-parisc, linux-m68k, Arnd Bergmann,
	linux-kernel

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/6] powerpc: rtc: provide rtc_class_ops directly
       [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-01 16:59 ` [PATCH 2/6] m68k: rtc: provide rtc_class_ops directly Arnd Bergmann
@ 2016-03-01 16:59 ` Arnd Bergmann
  2016-03-01 18:37   ` kbuild test robot
  2016-03-01 17:00 ` [PATCH 4/6] parisc: " Arnd Bergmann
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Arnd Bergmann @ 2016-03-01 16:59 UTC (permalink / raw)
  To: Alexandre Belloni, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman
  Cc: linux-arm-kernel, Kyle McMartin, rtc-linux, Alessandro Zummo,
	linuxppc-dev, linux-sh, linux-parisc, linux-m68k, Arnd Bergmann,
	linux-kernel

The rtc-generic driver provides an architecture specific
wrapper on top of the generic rtc_class_ops abstraction,
and powerpc has another abstraction on top, which is a bit
silly.

This changes the powerpc 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/powerpc/kernel/time.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 81b0900a39ee..84a1228be617 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -1080,6 +1080,28 @@ void calibrate_delay(void)
 	loops_per_jiffy = tb_ticks_per_jiffy;
 }
 
+static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm)
+{
+	ppc_md.get_rtc_time(tm);
+	return rtc_valid_tm(tm);
+}
+
+static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm)
+{
+	if (!ppc_md.set_rtc_time)
+		return -EOPNOTSUPP;
+
+	if (ppc_md.set_rtc_time(tm) < 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;
@@ -1087,7 +1109,9 @@ static int __init rtc_init(void)
 	if (!ppc_md.get_rtc_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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/6] parisc: rtc: provide rtc_class_ops directly
       [not found] <1456851608-3374907-1-git-send-email-arnd@arndb.de>
                   ` (2 preceding siblings ...)
  2016-03-01 16:59 ` [PATCH 3/6] powerpc: " Arnd Bergmann
@ 2016-03-01 17:00 ` 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
  5 siblings, 2 replies; 14+ messages in thread
From: Arnd Bergmann @ 2016-03-01 17:00 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: linux-arm-kernel, Kyle McMartin, rtc-linux, Alessandro Zummo,
	linuxppc-dev, linux-sh, linux-parisc, linux-m68k, Arnd Bergmann,
	James E.J. Bottomley, Helge Deller, linux-kernel

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@arndb.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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/6] sh: rtc: provide rtc_class_ops directly
       [not found] <1456851608-3374907-1-git-send-email-arnd@arndb.de>
                   ` (3 preceding siblings ...)
  2016-03-01 17:00 ` [PATCH 4/6] parisc: " Arnd Bergmann
@ 2016-03-01 17:00 ` Arnd Bergmann
  2016-03-01 17:00 ` [PATCH 6/6] rtc: generic: remove get_rtc_time/set_rtc_time wrappers Arnd Bergmann
  5 siblings, 0 replies; 14+ messages in thread
From: Arnd Bergmann @ 2016-03-01 17:00 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: linux-arm-kernel, Kyle McMartin, rtc-linux, Alessandro Zummo,
	linuxppc-dev, linux-sh, linux-parisc, linux-m68k, Arnd Bergmann,
	Yoshinori Sato, Rich Felker, linux-kernel

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 6/6] rtc: generic: remove get_rtc_time/set_rtc_time wrappers
       [not found] <1456851608-3374907-1-git-send-email-arnd@arndb.de>
                   ` (4 preceding siblings ...)
  2016-03-01 17:00 ` [PATCH 5/6] sh: " Arnd Bergmann
@ 2016-03-01 17:00 ` Arnd Bergmann
  5 siblings, 0 replies; 14+ messages in thread
From: Arnd Bergmann @ 2016-03-01 17:00 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: linux-arm-kernel, Kyle McMartin, rtc-linux, Alessandro Zummo,
	linuxppc-dev, linux-sh, linux-parisc, linux-m68k, Arnd Bergmann,
	linux-kernel

All architectures using this driver are now converted to
provide their own operations, so this one can be turned
into a trivial stub driver relying on its platform data.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/rtc/rtc-generic.c | 36 +-----------------------------------
 1 file changed, 1 insertion(+), 35 deletions(-)

diff --git a/drivers/rtc/rtc-generic.c b/drivers/rtc/rtc-generic.c
index d726c6aa96a8..1bf5d2347928 100644
--- a/drivers/rtc/rtc-generic.c
+++ b/drivers/rtc/rtc-generic.c
@@ -9,44 +9,10 @@
 #include <linux/platform_device.h>
 #include <linux/rtc.h>
 
-#if defined(CONFIG_M68K) || defined(CONFIG_PARISC) || \
-    defined(CONFIG_PPC) || defined(CONFIG_SUPERH32)
-#include <asm/rtc.h>
-
-static int generic_get_time(struct device *dev, struct rtc_time *tm)
-{
-	unsigned int ret = get_rtc_time(tm);
-
-	if (ret & RTC_BATT_BAD)
-		return -EOPNOTSUPP;
-
-	return rtc_valid_tm(tm);
-}
-
-static int generic_set_time(struct device *dev, struct rtc_time *tm)
-{
-	if (set_rtc_time(tm) < 0)
-		return -EOPNOTSUPP;
-
-	return 0;
-}
-
-static const struct rtc_class_ops generic_rtc_ops = {
-	.read_time = generic_get_time,
-	.set_time = generic_set_time,
-};
-#else
-#define generic_rtc_ops *(struct rtc_class_ops*)NULL
-#endif
-
 static int __init generic_rtc_probe(struct platform_device *dev)
 {
 	struct rtc_device *rtc;
-	const struct rtc_class_ops *ops;
-
-	ops = dev_get_platdata(&dev->dev);
-	if (!ops)
-		ops = &generic_rtc_ops;
+	const struct rtc_class_ops *ops = dev_get_platdata(&dev->dev);
 
 	rtc = devm_rtc_device_register(&dev->dev, "rtc-generic",
 					ops, THIS_MODULE);
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/6] parisc: rtc: provide rtc_class_ops directly
  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
  1 sibling, 0 replies; 14+ messages in thread
From: kbuild test robot @ 2016-03-01 17:19 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: kbuild-all, Alexandre Belloni, linux-arm-kernel, Kyle McMartin,
	rtc-linux, Alessandro Zummo, linuxppc-dev, linux-sh, linux-parisc,
	linux-m68k, Arnd Bergmann, James E.J. Bottomley, Helge Deller,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2165 bytes --]

Hi Arnd,

[auto build test ERROR on abelloni/rtc-next]
[also build test ERROR on v4.5-rc6 next-20160301]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Arnd-Bergmann/rtc-generic-follow-up-for-COMPILE_TEST/20160302-011032
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
config: parisc-allyesconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=parisc 

All error/warnings (new ones prefixed by >>):

   arch/parisc/kernel/time.c: In function 'rtc_generic_get_time':
>> arch/parisc/kernel/time.c:232:9: error: 'wtime' undeclared (first use in this function)
     memset(wtime, 0, sizeof(*wtime));
            ^
   arch/parisc/kernel/time.c:232:9: note: each undeclared identifier is reported only once for each function it appears in
>> arch/parisc/kernel/time.c:237:2: warning: passing argument 2 of 'rtc_time64_to_tm' from incompatible pointer type
     rtc_time64_to_tm(tod_data.tod_sec, &tm);
     ^
   In file included from arch/parisc/kernel/time.c:15:0:
   include/linux/rtc.h:23:13: note: expected 'struct rtc_time *' but argument is of type 'struct rtc_time **'
    extern void rtc_time64_to_tm(time64_t time, struct rtc_time *tm);
                ^

vim +/wtime +232 arch/parisc/kernel/time.c

   226	}
   227	
   228	static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm)
   229	{
   230		struct pdc_tod tod_data;
   231	
 > 232		memset(wtime, 0, sizeof(*wtime));
   233		if (pdc_tod_read(&tod_data) < 0)
   234			return -EOPNOTSUPP;
   235	
   236		/* we treat tod_sec as unsigned, so this can work until year 2106 */
 > 237		rtc_time64_to_tm(tod_data.tod_sec, &tm);
   238		return rtc_valid_tm(tm);
   239	}
   240	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 43840 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/6] powerpc: rtc: provide rtc_class_ops directly
  2016-03-01 16:59 ` [PATCH 3/6] powerpc: " Arnd Bergmann
@ 2016-03-01 18:37   ` kbuild test robot
  2016-03-01 20:31     ` Arnd Bergmann
  0 siblings, 1 reply; 14+ messages in thread
From: kbuild test robot @ 2016-03-01 18:37 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: kbuild-all, Alexandre Belloni, Benjamin Herrenschmidt,
	Paul Mackerras, Michael Ellerman, linux-arm-kernel, Kyle McMartin,
	rtc-linux, Alessandro Zummo, linuxppc-dev, linux-sh, linux-parisc,
	linux-m68k, Arnd Bergmann, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1047 bytes --]

Hi Arnd,

[auto build test ERROR on abelloni/rtc-next]
[also build test ERROR on v4.5-rc6 next-20160301]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Arnd-Bergmann/rtc-generic-follow-up-for-COMPILE_TEST/20160302-011032
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
config: powerpc-allnoconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=powerpc 

All errors (new ones prefixed by >>):

   arch/powerpc/kernel/built-in.o: In function `rtc_generic_get_time':
>> time.c:(.text+0x4c58): undefined reference to `rtc_valid_tm'

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 5708 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/6] powerpc: rtc: provide rtc_class_ops directly
  2016-03-01 18:37   ` kbuild test robot
@ 2016-03-01 20:31     ` Arnd Bergmann
  0 siblings, 0 replies; 14+ messages in thread
From: Arnd Bergmann @ 2016-03-01 20:31 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: kbuild test robot, Alessandro Zummo, linux-parisc, rtc-linux,
	linux-sh, linux-kernel, Kyle McMartin, linux-m68k,
	Alexandre Belloni, kbuild-all, Paul Mackerras, linux-arm-kernel

On Wednesday 02 March 2016 02:37:14 kbuild test robot wrote:
> [auto build test ERROR on abelloni/rtc-next]
> [also build test ERROR on v4.5-rc6 next-20160301]
> [if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
> 
> url:    https://github.com/0day-ci/linux/commits/Arnd-Bergmann/rtc-generic-follow-up-for-COMPILE_TEST/20160302-011032
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
> config: powerpc-allnoconfig (attached as .config)
> reproduce:
>         wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         make.cross ARCH=powerpc 
> 
> All errors (new ones prefixed by >>):
> 
>    arch/powerpc/kernel/built-in.o: In function `rtc_generic_get_time':
> >> time.c:(.text+0x4c58): undefined reference to `rtc_valid_tm'
> 

I fixed up the powerpc and parisc patches now, will resend them
after getting some feedback on the overall approach.

	Arnd

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/6] rtc: generic: allow building on all architectures
  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
  0 siblings, 2 replies; 14+ messages in thread
From: Geert Uytterhoeven @ 2016-03-02  8:57 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Alexandre Belloni, linux-arm-kernel@lists.infradead.org,
	Kyle McMartin, RTCLINUX, Alessandro Zummo,
	linuxppc-dev@lists.ozlabs.org, Linux-sh list, Parisc List,
	linux-m68k, linux-kernel@vger.kernel.org

Hi Arnd,

On Tue, Mar 1, 2016 at 5:59 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> There are four architectures using this driver, but since we can
> build it with COMPILE_TEST, we should try dealing with the absence
> of the asm/rtc.h header file, to avoid getting a build error:
>
> drivers/rtc/rtc-generic.c:12:21: fatal error: asm/rtc.h: No such file or directory
>
> This creates an alternative use of the driver, allowing architectures
> to pass a set of rtc_class_ops in platform data. We can convert the
> four architectures to use this and then remove the original
> code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/rtc/rtc-generic.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/rtc-generic.c b/drivers/rtc/rtc-generic.c
> index e782ebd719b2..d726c6aa96a8 100644
> --- a/drivers/rtc/rtc-generic.c
> +++ b/drivers/rtc/rtc-generic.c
> @@ -9,6 +9,8 @@
>  #include <linux/platform_device.h>
>  #include <linux/rtc.h>
>
> +#if defined(CONFIG_M68K) || defined(CONFIG_PARISC) || \
> +    defined(CONFIG_PPC) || defined(CONFIG_SUPERH32)
>  #include <asm/rtc.h>
>
>  static int generic_get_time(struct device *dev, struct rtc_time *tm)
> @@ -33,13 +35,21 @@ static const struct rtc_class_ops generic_rtc_ops = {
>         .read_time = generic_get_time,
>         .set_time = generic_set_time,
>  };
> +#else
> +#define generic_rtc_ops *(struct rtc_class_ops*)NULL
> +#endif
>
>  static int __init generic_rtc_probe(struct platform_device *dev)
>  {
>         struct rtc_device *rtc;
> +       const struct rtc_class_ops *ops;
> +
> +       ops = dev_get_platdata(&dev->dev);
> +       if (!ops)
> +               ops = &generic_rtc_ops;

I hope no compiler version treats "&*(struct rtc_class_ops*)NULL" as
undefined behavior?

>
>         rtc = devm_rtc_device_register(&dev->dev, "rtc-generic",
> -                                       &generic_rtc_ops, THIS_MODULE);
> +                                       ops, THIS_MODULE);
>         if (IS_ERR(rtc))
>                 return PTR_ERR(rtc);

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/6] rtc: generic: allow building on all architectures
  2016-03-02  8:57   ` Geert Uytterhoeven
@ 2016-03-02  9:05     ` Arnd Bergmann
  2016-03-02  9:28     ` Andreas Schwab
  1 sibling, 0 replies; 14+ messages in thread
From: Arnd Bergmann @ 2016-03-02  9:05 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Alexandre Belloni, linux-arm-kernel@lists.infradead.org,
	Kyle McMartin, RTCLINUX, Alessandro Zummo,
	linuxppc-dev@lists.ozlabs.org, Linux-sh list, Parisc List,
	linux-m68k, linux-kernel@vger.kernel.org

On Wednesday 02 March 2016 09:57:27 Geert Uytterhoeven wrote:
> > @@ -33,13 +35,21 @@ static const struct rtc_class_ops generic_rtc_ops = {
> >         .read_time = generic_get_time,
> >         .set_time = generic_set_time,
> >  };
> > +#else
> > +#define generic_rtc_ops *(struct rtc_class_ops*)NULL
> > +#endif
> >
> >  static int __init generic_rtc_probe(struct platform_device *dev)
> >  {
> >         struct rtc_device *rtc;
> > +       const struct rtc_class_ops *ops;
> > +
> > +       ops = dev_get_platdata(&dev->dev);
> > +       if (!ops)
> > +               ops = &generic_rtc_ops;
> 
> I hope no compiler version treats "&*(struct rtc_class_ops*)NULL" as
> undefined behavior?

It's a bit odd, but I think it's syntactically correct C, and not
much too different from 

#define offsetof(TYPE, MEMBER)  ((size_t)&((TYPE *)0)->MEMBER)

is it? My last patch gets rid of it again.

	Arnd

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/6] rtc: generic: allow building on all architectures
  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
  1 sibling, 1 reply; 14+ messages in thread
From: Andreas Schwab @ 2016-03-02  9:28 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Arnd Bergmann, Alexandre Belloni,
	linux-arm-kernel@lists.infradead.org, Kyle McMartin, RTCLINUX,
	Alessandro Zummo, linuxppc-dev@lists.ozlabs.org, Linux-sh list,
	Parisc List, linux-m68k, linux-kernel@vger.kernel.org

Geert Uytterhoeven <geert@linux-m68k.org> writes:

>> +#else
>> +#define generic_rtc_ops *(struct rtc_class_ops*)NULL
>> +#endif
>>
>>  static int __init generic_rtc_probe(struct platform_device *dev)
>>  {
>>         struct rtc_device *rtc;
>> +       const struct rtc_class_ops *ops;
>> +
>> +       ops = dev_get_platdata(&dev->dev);
>> +       if (!ops)
>> +               ops = &generic_rtc_ops;
>
> I hope no compiler version treats "&*(struct rtc_class_ops*)NULL" as
> undefined behavior?

Yes, that is guaranteed, the operations cancel each other (6.5.3.2#3: If
the operand is the result of a unary * operator, neither that operator
nor the & operator is evaluated and the result is as if both were
omitted).

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/6] rtc: generic: allow building on all architectures
  2016-03-02  9:28     ` Andreas Schwab
@ 2016-03-02  9:39       ` Geert Uytterhoeven
  0 siblings, 0 replies; 14+ messages in thread
From: Geert Uytterhoeven @ 2016-03-02  9:39 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Arnd Bergmann, Alexandre Belloni,
	linux-arm-kernel@lists.infradead.org, Kyle McMartin, RTCLINUX,
	Alessandro Zummo, linuxppc-dev@lists.ozlabs.org, Linux-sh list,
	Parisc List, linux-m68k, linux-kernel@vger.kernel.org

On Wed, Mar 2, 2016 at 10:28 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> Geert Uytterhoeven <geert@linux-m68k.org> writes:
>
>>> +#else
>>> +#define generic_rtc_ops *(struct rtc_class_ops*)NULL
>>> +#endif
>>>
>>>  static int __init generic_rtc_probe(struct platform_device *dev)
>>>  {
>>>         struct rtc_device *rtc;
>>> +       const struct rtc_class_ops *ops;
>>> +
>>> +       ops = dev_get_platdata(&dev->dev);
>>> +       if (!ops)
>>> +               ops = &generic_rtc_ops;
>>
>> I hope no compiler version treats "&*(struct rtc_class_ops*)NULL" as
>> undefined behavior?
>
> Yes, that is guaranteed, the operations cancel each other (6.5.3.2#3: If
> the operand is the result of a unary * operator, neither that operator
> nor the & operator is evaluated and the result is as if both were
> omitted).

Thanks for confirming.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/6] parisc: rtc: provide rtc_class_ops directly
  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
  1 sibling, 0 replies; 14+ messages in thread
From: Alexandre Belloni @ 2016-03-10  4:34 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arm-kernel, Kyle McMartin, rtc-linux, Alessandro Zummo,
	linuxppc-dev, linux-sh, linux-parisc, linux-m68k,
	James E.J. Bottomley, Helge Deller, linux-kernel

On 01/03/2016 at 18:00:00 +0100, Arnd Bergmann wrote :
> -	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));
> +
> +

spurious blank line

>  	return PTR_ERR_OR_ZERO(pdev);
>  }
>  device_initcall(rtc_init);
> -- 
> 2.7.0
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2016-03-10  4:34 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [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 ` [PATCH 2/6] m68k: rtc: provide rtc_class_ops directly Arnd Bergmann
2016-03-01 16:59 ` [PATCH 3/6] powerpc: " 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox