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

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>

authored by

Alessandro Zummo and committed by
Linus Torvalds
bbccf83f f6009157

+9 -45
+8 -3
drivers/rtc/interface.c
··· 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;
-22
drivers/rtc/rtc-ds1672.c
··· 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 - } 106 - 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 89 } 111 90 112 91 static int ds1672_rtc_set_mmss(struct device *dev, unsigned long secs) ··· 131 152 132 153 static const struct rtc_class_ops ds1672_rtc_ops = { 133 154 .read_time = ds1672_rtc_read_time, 134 - .set_time = ds1672_rtc_set_time, 135 155 .set_mmss = ds1672_rtc_set_mmss, 136 156 }; 137 157
-13
drivers/rtc/rtc-ep93xx.c
··· 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; ··· 63 75 64 76 static const struct rtc_class_ops ep93xx_rtc_ops = { 65 77 .read_time = ep93xx_rtc_read_time, 66 - .set_time = ep93xx_rtc_set_time, 67 78 .set_mmss = ep93xx_rtc_set_mmss, 68 79 .proc = ep93xx_rtc_proc, 69 80 };
+1 -7
drivers/rtc/rtc-test.c
··· 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 ··· 73 78 static const struct rtc_class_ops test_rtc_ops = { 74 79 .proc = test_rtc_proc, 75 80 .read_time = test_rtc_read_time, 76 - .set_time = test_rtc_set_time, 77 81 .read_alarm = test_rtc_read_alarm, 78 82 .set_alarm = test_rtc_set_alarm, 79 83 .set_mmss = test_rtc_set_mmss,