summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-12-11 12:12:30 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2016-01-07 08:46:09 +0100
commite25911524369db851d3d2f1d2f048e6d85a221b6 (patch)
tree1841f3167af8ad2dbfc3c7b23627b8981d55385d
parentdb80eaf6d2dfdfa258bb0c2e3d971b08d549d04f (diff)
downloadbarebox-e25911524369db851d3d2f1d2f048e6d85a221b6.tar.gz
rtc: Fill in weekdays before setting time
Some rtcs store the weekday. Make sure it's filled in correctly before passinf the time to the driver. This is easily done by converting it to seconds-since-epoch and back to struct rtc_time. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/rtc/class.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index e87f5f7..8b047a6 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -46,10 +46,16 @@ EXPORT_SYMBOL(rtc_read_time);
int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
{
+ struct rtc_time time;
+ unsigned long secs;
+
if (rtc_valid_tm(tm))
return -EINVAL;
- return rtc->ops->set_time(rtc, tm);
+ rtc_tm_to_time(tm, &secs);
+ rtc_time_to_tm(secs, &time);
+
+ return rtc->ops->set_time(rtc, &time);
}
EXPORT_SYMBOL(rtc_set_time);