Commit bbccf83f6c4e1a0de5bdf51ec9ec708d3a1ce933
Committed by
Linus Torvalds
1 parent
f60091575d
Exists in
master
and in
39 other branches
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>
Showing 4 changed files with 9 additions and 45 deletions Side-by-side Diff
drivers/rtc/interface.c
... | ... | @@ -50,10 +50,15 @@ |
50 | 50 | |
51 | 51 | if (!rtc->ops) |
52 | 52 | err = -ENODEV; |
53 | - else if (!rtc->ops->set_time) | |
54 | - err = -EINVAL; | |
55 | - else | |
53 | + else if (rtc->ops->set_time) | |
56 | 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 | 63 | mutex_unlock(&rtc->ops_lock); |
59 | 64 | return err; |
drivers/rtc/rtc-ds1672.c
... | ... | @@ -83,32 +83,11 @@ |
83 | 83 | return 0; |
84 | 84 | } |
85 | 85 | |
86 | -static 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 | - | |
102 | 86 | static int ds1672_rtc_read_time(struct device *dev, struct rtc_time *tm) |
103 | 87 | { |
104 | 88 | return ds1672_get_datetime(to_i2c_client(dev), tm); |
105 | 89 | } |
106 | 90 | |
107 | -static 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 | - | |
112 | 91 | static int ds1672_rtc_set_mmss(struct device *dev, unsigned long secs) |
113 | 92 | { |
114 | 93 | return ds1672_set_mmss(to_i2c_client(dev), secs); |
... | ... | @@ -152,7 +131,6 @@ |
152 | 131 | |
153 | 132 | static const struct rtc_class_ops ds1672_rtc_ops = { |
154 | 133 | .read_time = ds1672_rtc_read_time, |
155 | - .set_time = ds1672_rtc_set_time, | |
156 | 134 | .set_mmss = ds1672_rtc_set_mmss, |
157 | 135 | }; |
158 | 136 |
drivers/rtc/rtc-ep93xx.c
... | ... | @@ -49,18 +49,6 @@ |
49 | 49 | return 0; |
50 | 50 | } |
51 | 51 | |
52 | -static 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 | - | |
64 | 52 | static int ep93xx_rtc_proc(struct device *dev, struct seq_file *seq) |
65 | 53 | { |
66 | 54 | unsigned short preload, delete; |
... | ... | @@ -75,7 +63,6 @@ |
75 | 63 | |
76 | 64 | static const struct rtc_class_ops ep93xx_rtc_ops = { |
77 | 65 | .read_time = ep93xx_rtc_read_time, |
78 | - .set_time = ep93xx_rtc_set_time, | |
79 | 66 | .set_mmss = ep93xx_rtc_set_mmss, |
80 | 67 | .proc = ep93xx_rtc_proc, |
81 | 68 | }; |
drivers/rtc/rtc-test.c
... | ... | @@ -34,14 +34,9 @@ |
34 | 34 | return 0; |
35 | 35 | } |
36 | 36 | |
37 | -static int test_rtc_set_time(struct device *dev, | |
38 | - struct rtc_time *tm) | |
39 | -{ | |
40 | - return 0; | |
41 | -} | |
42 | - | |
43 | 37 | static int test_rtc_set_mmss(struct device *dev, unsigned long secs) |
44 | 38 | { |
39 | + dev_info(dev, "%s, secs = %lu\n", __func__, secs); | |
45 | 40 | return 0; |
46 | 41 | } |
47 | 42 | |
... | ... | @@ -78,7 +73,6 @@ |
78 | 73 | static const struct rtc_class_ops test_rtc_ops = { |
79 | 74 | .proc = test_rtc_proc, |
80 | 75 | .read_time = test_rtc_read_time, |
81 | - .set_time = test_rtc_set_time, | |
82 | 76 | .read_alarm = test_rtc_read_alarm, |
83 | 77 | .set_alarm = test_rtc_set_alarm, |
84 | 78 | .set_mmss = test_rtc_set_mmss, |