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;
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);
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,
};
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;
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,
};
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;
}
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,