Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

authored by

Arnd Bergmann and committed by
Alexandre Belloni
64232fc3 ede44c90

+11 -1
+11 -1
drivers/rtc/rtc-generic.c
··· 9 9 #include <linux/platform_device.h> 10 10 #include <linux/rtc.h> 11 11 12 + #if defined(CONFIG_M68K) || defined(CONFIG_PARISC) || \ 13 + defined(CONFIG_PPC) || defined(CONFIG_SUPERH32) 12 14 #include <asm/rtc.h> 13 15 14 16 static int generic_get_time(struct device *dev, struct rtc_time *tm) ··· 35 33 .read_time = generic_get_time, 36 34 .set_time = generic_set_time, 37 35 }; 36 + #else 37 + #define generic_rtc_ops *(struct rtc_class_ops*)NULL 38 + #endif 38 39 39 40 static int __init generic_rtc_probe(struct platform_device *dev) 40 41 { 41 42 struct rtc_device *rtc; 43 + const struct rtc_class_ops *ops; 44 + 45 + ops = dev_get_platdata(&dev->dev); 46 + if (!ops) 47 + ops = &generic_rtc_ops; 42 48 43 49 rtc = devm_rtc_device_register(&dev->dev, "rtc-generic", 44 - &generic_rtc_ops, THIS_MODULE); 50 + ops, THIS_MODULE); 45 51 if (IS_ERR(rtc)) 46 52 return PTR_ERR(rtc); 47 53