rtc: generic: follow up for COMPILE_TEST
Subsystems (5)
cover rtc: generic: follow up for COMPILE_TEST
Today's linux-next kernel allowed building the rtc-generic driver (and most other rtc drivers) on all architectures, but this caused some errors on architectures without asm/rtc.h.
This series reworks that driver to avoid the dependency, and simplifies all four implementations. My first approach was to split the driver into four separate drivers, but that didn't feel right when three of them have their own multiplexors.
The first five patches can be applied independent of one other, while patch 6 is optional and can be applied when all others are merged. Alternatively, they can all go in through the rtc tree. I compile-tested only the powerpc and sh targets for which I happened to have cross-compilers installed.
Arnd
PATCH 1/6 rtc: generic: allow building on all architectures
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.
--- drivers/rtc/rtc-generic.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/rtc/rtc-generic.c +11 -1
@@ -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);
Signature · 1 line
2.7.0
Geert Uytterhoeven
maintainerRe: [PATCH 1/6] rtc: generic: allow building on all architectures
Hi Arnd,
Quoted 35 lines · Arnd Bergmann
There are four architectures using this driver, but since we can build it with
COMPILE_TEST, we should try dealing with the absence of theasm/rtc.hheader file, to avoid getting a build error:
drivers/rtc/rtc-generic.c:12:21: fatal error:asm/rtc.h: No such file or directoryThis creates an alternative use of the driver, allowing architectures to pass a set of
rtc_class_opsin platform data. We can convert the four architectures to use this and then remove the original code.Signed-off-by Arnd Bergmann <[email protected]>--- drivers/rtc/rtc-generic.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)drivers/rtc/rtc-generic.c +4
-0@@ -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
drivers/rtc/rtc-generic.c static const struct rtc_class_ops generic_rtc_ops = { · line 49
Quoted 10 lines
drivers/rtc/rtc-generic.c +6
-0+#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?
drivers/rtc/rtc-generic.c static const struct rtc_class_ops generic_rtc_ops = { · line 54
Quoted 6 lines
drivers/rtc/rtc-generic.c +1
-1rtc =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 at 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
Re: [PATCH 1/6] rtc: generic: allow building on all architectures
Quoted 8 lines · On Wednesday 02 March 2016 09:57:27 Geert Uytterhoeven wrote:
Quoted 8 lines
drivers/rtc/rtc-generic.c +3
-0@@ -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
Quoted 11 lines
drivers/rtc/rtc-generic.c static const struct rtc_class_ops generic_rtc_ops = { · line 49
Quoted 8 lines
drivers/rtc/rtc-generic.c +5
-0static 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
Re: [PATCH 1/6] rtc: generic: allow building on all architectures
In reply to Geert UytterhoevenQuoted 8 lines · On Wednesday 02 March 2016 09:57:27 Geert Uytterhoeven wrote:
Quoted 8 lines
drivers/rtc/rtc-generic.c +3
-0@@ -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
Quoted 11 lines
drivers/rtc/rtc-generic.c static const struct rtc_class_ops generic_rtc_ops = { · line 49
Quoted 8 lines
drivers/rtc/rtc-generic.c +5
-0static 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
Re: [PATCH 1/6] rtc: generic: allow building on all architectures
In reply to Geert UytterhoevenQuoted 4 lines · Geert Uytterhoeven
Quoted 4 lines
drivers/rtc/rtc-generic.c +3
-0+#else +#define generic_rtc_ops *(struct rtc_class_ops*)NULL +#endif
Quoted 11 lines
drivers/rtc/rtc-generic.c static const struct rtc_class_ops generic_rtc_ops = { · line 49
Quoted 8 lines
static int
__initgeneric_rtc_probe(struct platform_device *dev){ struct rtc_device *rtc;drivers/rtc/rtc-generic.c +5
-0+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.
Signature · 3 lines
Andreas Schwab, schwab at linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Geert Uytterhoeven
maintainerRe: [PATCH 1/6] rtc: generic: allow building on all architectures
Quoted 18 lines · Andreas Schwab
Quoted 4 lines · Geert Uytterhoeven
Quoted 4 lines
drivers/rtc/rtc-generic.c +3
-0+#else +#define generic_rtc_ops *(struct rtc_class_ops*)NULL +#endif Quoted 11 lines
drivers/rtc/rtc-generic.c static const struct rtc_class_ops generic_rtc_ops = { · line 49
Quoted 8 lines
static int
__initgeneric_rtc_probe(struct platform_device *dev){ struct rtc_device *rtc;drivers/rtc/rtc-generic.c +5
-0+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?
Quoted 4 lines
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 at 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
Geert Uytterhoeven
maintainerRe: [PATCH 1/6] rtc: generic: allow building on all architectures
In reply to Andreas SchwabQuoted 18 lines · Andreas Schwab
Quoted 4 lines · Geert Uytterhoeven
Quoted 4 lines
drivers/rtc/rtc-generic.c +3
-0+#else +#define generic_rtc_ops *(struct rtc_class_ops*)NULL +#endif Quoted 11 lines
drivers/rtc/rtc-generic.c static const struct rtc_class_ops generic_rtc_ops = { · line 49
Quoted 8 lines
static int
__initgeneric_rtc_probe(struct platform_device *dev){ struct rtc_device *rtc;drivers/rtc/rtc-generic.c +5
-0+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?
Quoted 4 lines
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 -- [email protected]
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
Geert Uytterhoeven
maintainerRe: [PATCH 1/6] rtc: generic: allow building on all architectures
In reply to Arnd BergmannHi Arnd,
Quoted 35 lines · Arnd Bergmann
There are four architectures using this driver, but since we can build it with
COMPILE_TEST, we should try dealing with the absence of theasm/rtc.hheader file, to avoid getting a build error:
drivers/rtc/rtc-generic.c:12:21: fatal error:asm/rtc.h: No such file or directoryThis creates an alternative use of the driver, allowing architectures to pass a set of
rtc_class_opsin platform data. We can convert the four architectures to use this and then remove the original code.Signed-off-by Arnd Bergmann <[email protected]>--- drivers/rtc/rtc-generic.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)drivers/rtc/rtc-generic.c +4
-0@@ -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
drivers/rtc/rtc-generic.c static const struct rtc_class_ops generic_rtc_ops = { · line 49
Quoted 10 lines
drivers/rtc/rtc-generic.c +6
-0+#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?
drivers/rtc/rtc-generic.c static const struct rtc_class_ops generic_rtc_ops = { · line 54
Quoted 6 lines
drivers/rtc/rtc-generic.c +1
-1rtc =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 -- [email protected]
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
PATCH 2/6 m68k: rtc: provide rtc_class_ops directly
In reply to Arnd BergmannThe 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.
--- arch/m68k/kernel/time.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
arch/m68k/kernel/time.c +21 -1
@@ -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); }
Signature · 1 line
2.7.0
PATCH 2/6 m68k: rtc: provide rtc_class_ops directly
In reply to Arnd BergmannThe 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.
--- arch/m68k/kernel/time.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
arch/m68k/kernel/time.c +21 -1
@@ -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); }
Signature · 1 line
2.7.0
PATCH 3/6 powerpc: rtc: provide rtc_class_ops directly
In reply to Arnd BergmannThe 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.
--- arch/powerpc/kernel/time.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
arch/powerpc/kernel/time.c +25 -1
@@ -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); }
Signature · 1 line
2.7.0
kbuild test robot
build botRe: [PATCH 3/6] powerpc: rtc: provide rtc_class_ops directly
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…
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 5708 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160302/fb4fdc17/attachment.obj>
Re: [PATCH 3/6] powerpc: rtc: provide rtc_class_ops directly
Quoted 13 lines · 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
Quoted 5 lines
All errors (new ones prefixed by >>):
arch/powerpc/kernel/built-in.o: In function `rtc_generic_get_time':Quoted 1 line
Quoted 1 line
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
Re: [PATCH 3/6] powerpc: rtc: provide rtc_class_ops directly
In reply to kbuild test robotQuoted 13 lines · 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
Quoted 5 lines
All errors (new ones prefixed by >>):
arch/powerpc/kernel/built-in.o: In function `rtc_generic_get_time':Quoted 1 line
Quoted 1 line
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
PATCH 3/6 powerpc: rtc: provide rtc_class_ops directly
In reply to Arnd BergmannThe 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.
--- arch/powerpc/kernel/time.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
arch/powerpc/kernel/time.c +25 -1
@@ -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); }
Signature · 1 line
2.7.0
PATCH 4/6 parisc: rtc: provide rtc_class_ops directly
In reply to Arnd BergmannThe 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.
--- arch/parisc/kernel/time.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
arch/parisc/kernel/time.c +34 -1
@@ -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);
Signature · 1 line
2.7.0
kbuild test robot
build botRe: [PATCH 4/6] parisc: rtc: provide rtc_class_ops directly
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…
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 43840 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160302/ca67cfe1/attachment-0001.obj>
kbuild test robot
build botRe: [PATCH 4/6] parisc: rtc: provide rtc_class_ops directly
In reply to Arnd Bergmannreproduce: 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…
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
Re: [PATCH 4/6] parisc: rtc: provide rtc_class_ops directly
In reply to Arnd Bergmannarch/parisc/kernel/time.c void __init start_cpu_itimer(void) · line 264
Quoted 6 lines · Arnd Bergmann
arch/parisc/kernel/time.c +5
-1- 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
Quoted 6 lines
return
PTR_ERR_OR_ZERO(pdev);
}
device_initcall(rtc_init);Signature · 1 line
2.7.0
Signature · 3 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 4/6 parisc: rtc: provide rtc_class_ops directly
In reply to Arnd BergmannThe 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.
--- arch/parisc/kernel/time.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
arch/parisc/kernel/time.c +34 -1
@@ -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);
Signature · 1 line
2.7.0
PATCH 5/6 sh: rtc: provide rtc_class_ops directly
In reply to Arnd BergmannThe 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.
--- arch/sh/kernel/time.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-)
arch/sh/kernel/time.c +19 -13
@@ -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); }
Signature · 1 line
2.7.0
PATCH 5/6 sh: rtc: provide rtc_class_ops directly
In reply to Arnd BergmannThe 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.
--- arch/sh/kernel/time.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-)
arch/sh/kernel/time.c +19 -13
@@ -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); }
Signature · 1 line
2.7.0
PATCH 6/6 rtc: generic: remove get_rtc_time/set_rtc_time wrappers
In reply to Arnd BergmannAll 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.
--- drivers/rtc/rtc-generic.c | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-)
drivers/rtc/rtc-generic.c +1 -35
@@ -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 );
Signature · 1 line
2.7.0
cover rtc: generic: follow up for COMPILE_TEST
In reply to Arnd BergmannHi,
Quoted 10 lines · Arnd Bergmann
Today's linux-next kernel allowed building the rtc-generic driver (and most other rtc drivers) on all architectures, but this caused some errors on architectures without
asm/rtc.h.This series reworks that driver to avoid the dependency, and simplifies all four implementations. My first approach was to split the driver into four separate drivers, but that didn't feel right when three of them have their own multiplexors.
Quoted 6 lines
The first five patches can be applied independent of one other, while patch 6 is optional and can be applied when all others are merged. Alternatively, they can all go in through the rtc tree. I compile-tested only the powerpc and sh targets for which I happened to have cross-compilers installed.
I like this approach. Maybe you can also remove the now unnecessary definitions from the various asm/rtc.h.
I have a small nitpick on the parisc patch.
I'll take the first patch, no need to resend that one.
Signature · 3 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
Hi,
Quoted 10 lines · Arnd Bergmann
Today's linux-next kernel allowed building the rtc-generic driver (and most other rtc drivers) on all architectures, but this caused some errors on architectures without
asm/rtc.h.This series reworks that driver to avoid the dependency, and simplifies all four implementations. My first approach was to split the driver into four separate drivers, but that didn't feel right when three of them have their own multiplexors.
Quoted 6 lines
The first five patches can be applied independent of one other, while patch 6 is optional and can be applied when all others are merged. Alternatively, they can all go in through the rtc tree. I compile-tested only the powerpc and sh targets for which I happened to have cross-compilers installed.
I like this approach. Maybe you can also remove the now unnecessary definitions from the various asm/rtc.h.
I have a small nitpick on the parisc patch.
I'll take the first patch, no need to resend that one.
Signature · 3 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com