aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2016-03-01 11:59:57 -0500
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>2016-03-14 12:08:31 -0400
commit64232fc33a5bcc29aeb001e1bee80e17a889b4fb (patch)
treea8cc15a572bb65d32b658c36a6a87748b14dd18c
parentede44c908d44b166a5b6bd7caacd105c2ff5a70f (diff)
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>
-rw-r--r--drivers/rtc/rtc-generic.c12
1 files changed, 11 insertions, 1 deletions
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 @@
9#include <linux/platform_device.h> 9#include <linux/platform_device.h>
10#include <linux/rtc.h> 10#include <linux/rtc.h>
11 11
12#if defined(CONFIG_M68K) || defined(CONFIG_PARISC) || \
13 defined(CONFIG_PPC) || defined(CONFIG_SUPERH32)
12#include <asm/rtc.h> 14#include <asm/rtc.h>
13 15
14static int generic_get_time(struct device *dev, struct rtc_time *tm) 16static int generic_get_time(struct device *dev, struct rtc_time *tm)
@@ -33,13 +35,21 @@ static const struct rtc_class_ops generic_rtc_ops = {
33 .read_time = generic_get_time, 35 .read_time = generic_get_time,
34 .set_time = generic_set_time, 36 .set_time = generic_set_time,
35}; 37};
38#else
39#define generic_rtc_ops *(struct rtc_class_ops*)NULL
40#endif
36 41
37static int __init generic_rtc_probe(struct platform_device *dev) 42static int __init generic_rtc_probe(struct platform_device *dev)
38{ 43{
39 struct rtc_device *rtc; 44 struct rtc_device *rtc;
45 const struct rtc_class_ops *ops;
46
47 ops = dev_get_platdata(&dev->dev);
48 if (!ops)
49 ops = &generic_rtc_ops;
40 50
41 rtc = devm_rtc_device_register(&dev->dev, "rtc-generic", 51 rtc = devm_rtc_device_register(&dev->dev, "rtc-generic",
42 &generic_rtc_ops, THIS_MODULE); 52 ops, THIS_MODULE);
43 if (IS_ERR(rtc)) 53 if (IS_ERR(rtc))
44 return PTR_ERR(rtc); 54 return PTR_ERR(rtc);
45 55