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
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(-)
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(-)
@@ -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));returnPTR_ERR_OR_ZERO(pdev);}
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(-)
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(-)
@@ -224,11 +225,43 @@ void __init start_cpu_itimer(void)per_cpu(cpu_data,cpu).it_value=next_tick;}+staticintrtc_generic_get_time(structdevice*dev,structrtc_time*tm)+{+structpdc_todtod_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);+returnrtc_valid_tm(tm);+}++staticintrtc_generic_set_time(structdevice*dev,structrtc_time*tm)+{+time64_tsecs=rtc_tm_to_time64(tm);++if(pdc_tod_set(secs,0)<0)+return-EOPNOTSUPP;++return0;+}++staticconststructrtc_class_opsrtc_generic_ops={+.read_time=rtc_generic_get_time,+.set_time=rtc_generic_set_time,+};+staticint__initrtc_init(void){structplatform_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));++returnPTR_ERR_OR_ZERO(pdev);}device_initcall(rtc_init);
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(-)
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(-)
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
quoted
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
Hi Arnd,
On Tue, Mar 1, 2016 at 5:59 PM, Arnd Bergmann [off-list ref] wrote:
quoted hunk
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(-)
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
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
Hi,
On 01/03/2016 at 17:59:56 +0100, Arnd Bergmann wrote :
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.
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.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com