rtc: use set_mmss when set_time is not available
authorAlessandro Zummo <a.zummo@towertech.it>
Tue, 6 Jan 2009 22:42:21 +0000 (14:42 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 6 Jan 2009 23:59:25 +0000 (15:59 -0800)
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>
drivers/rtc/interface.c
drivers/rtc/rtc-ds1672.c
drivers/rtc/rtc-ep93xx.c
drivers/rtc/rtc-test.c

index 50482d1321e8130e96d0bac111e14b1b107bcba9..4348c4b0d4536dde8fb556ad3fe34cfc2f37b611 100644 (file)
@@ -50,10 +50,15 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
 
        if (!rtc->ops)
                err = -ENODEV;
-       else if (!rtc->ops->set_time)
-               err = -EINVAL;
-       else
+       else if (rtc->ops->set_time)
                err = rtc->ops->set_time(rtc->dev.parent, tm);
+       else if (rtc->ops->set_mmss) {
+               unsigned long secs;
+               err = rtc_tm_to_time(tm, &secs);
+               if (err == 0)
+                       err = rtc->ops->set_mmss(rtc->dev.parent, secs);
+       } else
+               err = -EINVAL;
 
        mutex_unlock(&rtc->ops_lock);
        return err;
index 4e91419e8911c50bcfbc18aa1d536e88c41178c0..06dfb54f99b6a6579424ec36627020311dca80cb 100644 (file)
@@ -83,32 +83,11 @@ static int ds1672_set_mmss(struct i2c_client *client, unsigned long secs)
        return 0;
 }
 
-static int ds1672_set_datetime(struct i2c_client *client, struct rtc_time *tm)
-{
-       unsigned long secs;
-
-       dev_dbg(&client->dev,
-               "%s: secs=%d, mins=%d, hours=%d, "
-               "mday=%d, mon=%d, year=%d, wday=%d\n",
-               __func__,
-               tm->tm_sec, tm->tm_min, tm->tm_hour,
-               tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
-
-       rtc_tm_to_time(tm, &secs);
-
-       return ds1672_set_mmss(client, secs);
-}
-
 static int ds1672_rtc_read_time(struct device *dev, struct rtc_time *tm)
 {
        return ds1672_get_datetime(to_i2c_client(dev), tm);
 }
 
-static int ds1672_rtc_set_time(struct device *dev, struct rtc_time *tm)
-{
-       return ds1672_set_datetime(to_i2c_client(dev), tm);
-}
-
 static int ds1672_rtc_set_mmss(struct device *dev, unsigned long secs)
 {
        return ds1672_set_mmss(to_i2c_client(dev), secs);
@@ -152,7 +131,6 @@ static DEVICE_ATTR(control, S_IRUGO, show_control, NULL);
 
 static const struct rtc_class_ops ds1672_rtc_ops = {
        .read_time = ds1672_rtc_read_time,
-       .set_time = ds1672_rtc_set_time,
        .set_mmss = ds1672_rtc_set_mmss,
 };
 
index 36e4ac0bd69c98b67054a5934eb3efcf3678b508..f7a3283dd02947962ce5c71d3a221b121231a728 100644 (file)
@@ -49,18 +49,6 @@ static int ep93xx_rtc_set_mmss(struct device *dev, unsigned long secs)
        return 0;
 }
 
-static int ep93xx_rtc_set_time(struct device *dev, struct rtc_time *tm)
-{
-       int err;
-       unsigned long secs;
-
-       err = rtc_tm_to_time(tm, &secs);
-       if (err != 0)
-               return err;
-
-       return ep93xx_rtc_set_mmss(dev, secs);
-}
-
 static int ep93xx_rtc_proc(struct device *dev, struct seq_file *seq)
 {
        unsigned short preload, delete;
@@ -75,7 +63,6 @@ static int ep93xx_rtc_proc(struct device *dev, struct seq_file *seq)
 
 static const struct rtc_class_ops ep93xx_rtc_ops = {
        .read_time      = ep93xx_rtc_read_time,
-       .set_time       = ep93xx_rtc_set_time,
        .set_mmss       = ep93xx_rtc_set_mmss,
        .proc           = ep93xx_rtc_proc,
 };
index bc930022004a58fc2dcb344c86bf9da180abd317..e478280ff6283d130c9cd456d09189a17f5f472c 100644 (file)
@@ -34,14 +34,9 @@ static int test_rtc_read_time(struct device *dev,
        return 0;
 }
 
-static int test_rtc_set_time(struct device *dev,
-       struct rtc_time *tm)
-{
-       return 0;
-}
-
 static int test_rtc_set_mmss(struct device *dev, unsigned long secs)
 {
+       dev_info(dev, "%s, secs = %lu\n", __func__, secs);
        return 0;
 }
 
@@ -78,7 +73,6 @@ static int test_rtc_ioctl(struct device *dev, unsigned int cmd,
 static const struct rtc_class_ops test_rtc_ops = {
        .proc = test_rtc_proc,
        .read_time = test_rtc_read_time,
-       .set_time = test_rtc_set_time,
        .read_alarm = test_rtc_read_alarm,
        .set_alarm = test_rtc_set_alarm,
        .set_mmss = test_rtc_set_mmss,