aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
authorAlessandro Zummo <a.zummo@towertech.it>2009-01-06 17:42:21 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-06 18:59:25 -0500
commitbbccf83f6c4e1a0de5bdf51ec9ec708d3a1ce933 (patch)
tree8c9797c7914b0f7fc78e5878ef33ae5f3219a202 /drivers/rtc
parentf60091575d43e5a27b26f4d6fa4251cdd6b9ae8a (diff)
rtc: use set_mmss when set_time is not available
Drivers should only need to implement either set_mmss (counter based RTCs) or set_time (most RTCs). The RTC subsystem will handle them appropriately. Signed-off-by: Alessandro Zummo <a.zummo@towertech.it> Cc: Kumar Gala <galak@kernel.crashing.org> Cc: David Brownell <david-b@pacbell.net> Cc: Lennert Buytenhek <buytenh@wantstofly.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/interface.c11
-rw-r--r--drivers/rtc/rtc-ds1672.c22
-rw-r--r--drivers/rtc/rtc-ep93xx.c13
-rw-r--r--drivers/rtc/rtc-test.c8
4 files changed, 9 insertions, 45 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 50482d1321e8..4348c4b0d453 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -50,10 +50,15 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
50 50
51 if (!rtc->ops) 51 if (!rtc->ops)
52 err = -ENODEV; 52 err = -ENODEV;
53 else if (!rtc->ops->set_time) 53 else if (rtc->ops->set_time)
54 err = -EINVAL;
55 else
56 err = rtc->ops->set_time(rtc->dev.parent, tm); 54 err = rtc->ops->set_time(rtc->dev.parent, tm);
55 else if (rtc->ops->set_mmss) {
56 unsigned long secs;
57 err = rtc_tm_to_time(tm, &secs);
58 if (err == 0)
59 err = rtc->ops->set_mmss(rtc->dev.parent, secs);
60 } else
61 err = -EINVAL;
57 62
58 mutex_unlock(&rtc->ops_lock); 63 mutex_unlock(&rtc->ops_lock);
59 return err; 64 return err;
diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c
index 4e91419e8911..06dfb54f99b6 100644
--- a/drivers/rtc/rtc-ds1672.c
+++ b/drivers/rtc/rtc-ds1672.c
@@ -83,32 +83,11 @@ static int ds1672_set_mmss(struct i2c_client *client, unsigned long secs)
83 return 0; 83 return 0;
84} 84}
85 85
86static int ds1672_set_datetime(struct i2c_client *client, struct rtc_time *tm)
87{
88 unsigned long secs;
89
90 dev_dbg(&client->dev,
91 "%s: secs=%d, mins=%d, hours=%d, "
92 "mday=%d, mon=%d, year=%d, wday=%d\n",
93 __func__,
94 tm->tm_sec, tm->tm_min, tm->tm_hour,
95 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
96
97 rtc_tm_to_time(tm, &secs);
98
99 return ds1672_set_mmss(client, secs);
100}
101
102static int ds1672_rtc_read_time(struct device *dev, struct rtc_time *tm) 86static int ds1672_rtc_read_time(struct device *dev, struct rtc_time *tm)
103{ 87{
104 return ds1672_get_datetime(to_i2c_client(dev), tm); 88 return ds1672_get_datetime(to_i2c_client(dev), tm);
105} 89}
106 90
107static int ds1672_rtc_set_time(struct device *dev, struct rtc_time *tm)
108{
109 return ds1672_set_datetime(to_i2c_client(dev), tm);
110}
111
112static int ds1672_rtc_set_mmss(struct device *dev, unsigned long secs) 91static int ds1672_rtc_set_mmss(struct device *dev, unsigned long secs)
113{ 92{
114 return ds1672_set_mmss(to_i2c_client(dev), secs); 93 return ds1672_set_mmss(to_i2c_client(dev), secs);
@@ -152,7 +131,6 @@ static DEVICE_ATTR(control, S_IRUGO, show_control, NULL);
152 131
153static const struct rtc_class_ops ds1672_rtc_ops = { 132static const struct rtc_class_ops ds1672_rtc_ops = {
154 .read_time = ds1672_rtc_read_time, 133 .read_time = ds1672_rtc_read_time,
155 .set_time = ds1672_rtc_set_time,
156 .set_mmss = ds1672_rtc_set_mmss, 134 .set_mmss = ds1672_rtc_set_mmss,
157}; 135};
158 136
diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c
index 36e4ac0bd69c..f7a3283dd029 100644
--- a/drivers/rtc/rtc-ep93xx.c
+++ b/drivers/rtc/rtc-ep93xx.c
@@ -49,18 +49,6 @@ static int ep93xx_rtc_set_mmss(struct device *dev, unsigned long secs)
49 return 0; 49 return 0;
50} 50}
51 51
52static int ep93xx_rtc_set_time(struct device *dev, struct rtc_time *tm)
53{
54 int err;
55 unsigned long secs;
56
57 err = rtc_tm_to_time(tm, &secs);
58 if (err != 0)
59 return err;
60
61 return ep93xx_rtc_set_mmss(dev, secs);
62}
63
64static int ep93xx_rtc_proc(struct device *dev, struct seq_file *seq) 52static int ep93xx_rtc_proc(struct device *dev, struct seq_file *seq)
65{ 53{
66 unsigned short preload, delete; 54 unsigned short preload, delete;
@@ -75,7 +63,6 @@ static int ep93xx_rtc_proc(struct device *dev, struct seq_file *seq)
75 63
76static const struct rtc_class_ops ep93xx_rtc_ops = { 64static const struct rtc_class_ops ep93xx_rtc_ops = {
77 .read_time = ep93xx_rtc_read_time, 65 .read_time = ep93xx_rtc_read_time,
78 .set_time = ep93xx_rtc_set_time,
79 .set_mmss = ep93xx_rtc_set_mmss, 66 .set_mmss = ep93xx_rtc_set_mmss,
80 .proc = ep93xx_rtc_proc, 67 .proc = ep93xx_rtc_proc,
81}; 68};
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
index bc930022004a..e478280ff628 100644
--- a/drivers/rtc/rtc-test.c
+++ b/drivers/rtc/rtc-test.c
@@ -34,14 +34,9 @@ static int test_rtc_read_time(struct device *dev,
34 return 0; 34 return 0;
35} 35}
36 36
37static int test_rtc_set_time(struct device *dev,
38 struct rtc_time *tm)
39{
40 return 0;
41}
42
43static int test_rtc_set_mmss(struct device *dev, unsigned long secs) 37static int test_rtc_set_mmss(struct device *dev, unsigned long secs)
44{ 38{
39 dev_info(dev, "%s, secs = %lu\n", __func__, secs);
45 return 0; 40 return 0;
46} 41}
47 42
@@ -78,7 +73,6 @@ static int test_rtc_ioctl(struct device *dev, unsigned int cmd,
78static const struct rtc_class_ops test_rtc_ops = { 73static const struct rtc_class_ops test_rtc_ops = {
79 .proc = test_rtc_proc, 74 .proc = test_rtc_proc,
80 .read_time = test_rtc_read_time, 75 .read_time = test_rtc_read_time,
81 .set_time = test_rtc_set_time,
82 .read_alarm = test_rtc_read_alarm, 76 .read_alarm = test_rtc_read_alarm,
83 .set_alarm = test_rtc_set_alarm, 77 .set_alarm = test_rtc_set_alarm,
84 .set_mmss = test_rtc_set_mmss, 78 .set_mmss = test_rtc_set_mmss,