The kernel uses 32-bit signed value(time_t) for seconds since 1970-01-01:00:00:00, thus it
will overflow at 2038-01-19 03:14:08 on 32-bit systems. We call this "2038 safety" issue.
As part of addressing 2038 saftey for in-kernel uses, this patch adds the safe mktime() using
time64_t. After this patch, mktime_unsafe() should be replaced by mktime() one by one.
Eventually, mktime_unsafe() will be removed from the kernel when it has no users.
Signed-off-by: pang.xunlei <[email protected]>
---
include/linux/time.h | 8 ++++++--
kernel/time/time.c | 39 ++++++++++++++++++++++++++-------------
2 files changed, 32 insertions(+), 15 deletions(-)
diff --git a/include/linux/time.h b/include/linux/time.h
index e49d421..08f413c 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -39,9 +39,13 @@ static inline int timeval_compare(const struct timeval *lhs, const struct timeva
return lhs->tv_usec - rhs->tv_usec;
}
+extern time64_t mktime(const unsigned int year, const unsigned int mon,
+ const unsigned int day, const unsigned int hour,
+ const unsigned int min, const unsigned int sec);
+
extern unsigned long mktime_unsafe(const unsigned int year, const unsigned int mon,
- const unsigned int day, const unsigned int hour,
- const unsigned int min, const unsigned int sec);
+ const unsigned int day, const unsigned int hour,
+ const unsigned int min, const unsigned int sec);
extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec);
diff --git a/kernel/time/time.c b/kernel/time/time.c
index d6a4464..f9521fa 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -304,7 +304,8 @@ struct timespec timespec_trunc(struct timespec t, unsigned gran)
}
EXPORT_SYMBOL(timespec_trunc);
-/* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
+/*
+ * Converts Gregorian date to seconds since 1970-01-01 00:00:00.
* Assumes input in normal date format, i.e. 1980-12-31 23:59:59
* => year=1980, mon=12, day=31, hour=23, min=59, sec=59.
*
@@ -314,16 +315,13 @@ EXPORT_SYMBOL(timespec_trunc);
* -year/100+year/400 terms, and add 10.]
*
* This algorithm was first published by Gauss (I think).
- *
- * WARNING: this function will overflow on 2106-02-07 06:28:16 on
- * machines where long is 32-bit! (However, as time_t is signed, we
- * will already get problems at other places on 2038-01-19 03:14:08)
*/
-unsigned long
-mktime_unsafe(const unsigned int year0, const unsigned int mon0,
+time64_t
+mktime(const unsigned int year0, const unsigned int mon0,
const unsigned int day, const unsigned int hour,
const unsigned int min, const unsigned int sec)
{
+ time64_t ret;
unsigned int mon = mon0, year = year0;
/* 1..12 -> 11,12,1..10 */
@@ -332,12 +330,27 @@ mktime_unsafe(const unsigned int year0, const unsigned int mon0,
year -= 1;
}
- return ((((unsigned long)
- (year/4 - year/100 + year/400 + 367*mon/12 + day) +
- year*365 - 719499
- )*24 + hour /* now have hours */
- )*60 + min /* now have minutes */
- )*60 + sec; /* finally seconds */
+ ret = (year/4 - year/100 + year/400 + 367*mon/12 + day) + year*365 - 719499;
+ ret = ret*24 + hour; /* now have hours */
+ ret = ret*60 + min; /* now have minutes */
+ ret = ret*60 + sec; /* finally seconds */
+
+ return ret;
+}
+
+EXPORT_SYMBOL(mktime);
+
+/*
+ * TODO: [2038 safety] 2038 unsafe for legacy, replace it by mktime().
+ * WARNING: mktime_unsafe() will overflow on 2106-02-07 06:28:16 on
+ * machines where long is 32-bit! (However, as time_t is signed, we
+ * will already get problems at other places on 2038-01-19 03:14:08)
+ */
+unsigned long mktime_unsafe(const unsigned int year0, const unsigned int mon0,
+ const unsigned int day, const unsigned int hour,
+ const unsigned int min, const unsigned int sec)
+{
+ return (unsigned long) mktime(year0, mon0, day, hour, min, sec);
}
EXPORT_SYMBOL(mktime_unsafe);
--
1.7.9.5
The kernel uses 32-bit signed value(time_t) for seconds since 1970-01-01:00:00:00, thus it
will overflow at 2038-01-19 03:14:08 on 32-bit systems. We call this "2038 safety" issue.
Currently, rtc_tm_to_time() deals with "unsigned long" which is 2038 unsafe on 32-bit systems.
As part of addressing 2038 saftey for in-kernel uses, this patch creates no creates no functional
change in existing users, renames rtc_tm_to_time() to rtc_tm_to_time_unsafe(), and changes all its
calling users correspondingly. The safe version of rtc_tm_to_time() will be added in the following patch.
Signed-off-by: pang.xunlei <[email protected]>
---
arch/sh/kernel/time.c | 2 +-
drivers/power/charger-manager.c | 8 ++++----
drivers/rtc/class.c | 4 ++--
drivers/rtc/hctosys.c | 2 +-
drivers/rtc/interface.c | 10 +++++-----
drivers/rtc/rtc-88pm80x.c | 10 +++++-----
drivers/rtc/rtc-88pm860x.c | 10 +++++-----
drivers/rtc/rtc-ab3100.c | 2 +-
drivers/rtc/rtc-ab8500.c | 10 +++++-----
drivers/rtc/rtc-at32ap700x.c | 4 ++--
drivers/rtc/rtc-at91sam9.c | 4 ++--
drivers/rtc/rtc-au1xxx.c | 2 +-
drivers/rtc/rtc-bfin.c | 4 ++--
drivers/rtc/rtc-coh901331.c | 2 +-
drivers/rtc/rtc-da9052.c | 2 +-
drivers/rtc/rtc-da9063.c | 4 ++--
drivers/rtc/rtc-davinci.c | 4 ++--
drivers/rtc/rtc-dev.c | 4 ++--
drivers/rtc/rtc-dm355evm.c | 2 +-
drivers/rtc/rtc-ds1305.c | 4 ++--
drivers/rtc/rtc-ds1374.c | 6 +++---
drivers/rtc/rtc-imxdi.c | 2 +-
drivers/rtc/rtc-isl1208.c | 4 ++--
drivers/rtc/rtc-jz4740.c | 2 +-
drivers/rtc/rtc-lib.c | 8 ++++----
drivers/rtc/rtc-lpc32xx.c | 2 +-
drivers/rtc/rtc-mc13xxx.c | 2 +-
drivers/rtc/rtc-mpc5121.c | 2 +-
drivers/rtc/rtc-mxc.c | 4 ++--
drivers/rtc/rtc-pcap.c | 2 +-
drivers/rtc/rtc-pl030.c | 4 ++--
drivers/rtc/rtc-pl031.c | 6 +++---
drivers/rtc/rtc-pm8xxx.c | 4 ++--
drivers/rtc/rtc-ps3.c | 2 +-
drivers/rtc/rtc-puv3.c | 4 ++--
drivers/rtc/rtc-sa1100.c | 4 ++--
drivers/rtc/rtc-sirfsoc.c | 4 ++--
drivers/rtc/rtc-snvs.c | 4 ++--
drivers/rtc/rtc-stmp3xxx.c | 2 +-
drivers/rtc/rtc-sun4v.c | 2 +-
drivers/rtc/rtc-sun6i.c | 4 ++--
drivers/rtc/rtc-sunxi.c | 4 ++--
drivers/rtc/rtc-sysfs.c | 8 ++++----
drivers/rtc/rtc-tegra.c | 4 ++--
drivers/rtc/rtc-tps6586x.c | 4 ++--
drivers/rtc/rtc-tx4939.c | 2 +-
drivers/rtc/rtc-wm831x.c | 4 ++--
drivers/rtc/rtc-xgene.c | 2 +-
include/linux/rtc.h | 2 +-
kernel/power/suspend_test.c | 2 +-
50 files changed, 100 insertions(+), 100 deletions(-)
diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c
index ec1d24b..78a1632 100644
--- a/arch/sh/kernel/time.c
+++ b/arch/sh/kernel/time.c
@@ -67,7 +67,7 @@ int set_rtc_time(struct rtc_time *tm)
{
unsigned long secs;
- rtc_tm_to_time(tm, &secs);
+ rtc_tm_to_time_unsafe(tm, &secs);
return rtc_sh_set_time(secs);
}
EXPORT_SYMBOL(set_rtc_time);
diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
index 7098a1c..060aa2c 100644
--- a/drivers/power/charger-manager.c
+++ b/drivers/power/charger-manager.c
@@ -1031,7 +1031,7 @@ static bool cm_setup_timer(void)
*/
tmp.enabled = 1;
rtc_read_time(rtc_dev, &tmp.time);
- rtc_tm_to_time(&tmp.time, &now);
+ rtc_tm_to_time_unsafe(&tmp.time, &now);
if (add < CM_RTC_SMALL)
add = CM_RTC_SMALL;
time = now + add;
@@ -1120,7 +1120,7 @@ out:
struct rtc_time tmp;
rtc_read_time(rtc_dev, &tmp);
- rtc_tm_to_time(&tmp, &now);
+ rtc_tm_to_time_unsafe(&tmp, &now);
if (rtc_wkalarm_save_time &&
now + CM_RTC_SMALL >= rtc_wkalarm_save_time)
@@ -1948,9 +1948,9 @@ static int cm_suspend_prepare(struct device *dev)
rtc_read_time(rtc_dev, &tmp);
if (rtc_wkalarm_save.enabled) {
- rtc_tm_to_time(&rtc_wkalarm_save.time,
+ rtc_tm_to_time_unsafe(&rtc_wkalarm_save.time,
&rtc_wkalarm_save_time);
- rtc_tm_to_time(&tmp, &now);
+ rtc_tm_to_time_unsafe(&tmp, &now);
if (now > rtc_wkalarm_save_time)
rtc_wkalarm_save_time = 0;
} else {
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index 38e26be..cde2c8d 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -69,7 +69,7 @@ static int rtc_suspend(struct device *dev)
}
getnstimeofday(&old_system);
- rtc_tm_to_time(&tm, &old_rtc.tv_sec);
+ rtc_tm_to_time_unsafe(&tm, &old_rtc.tv_sec);
/*
@@ -121,7 +121,7 @@ static int rtc_resume(struct device *dev)
pr_debug("%s: bogus resume time\n", dev_name(&rtc->dev));
return 0;
}
- rtc_tm_to_time(&tm, &new_rtc.tv_sec);
+ rtc_tm_to_time_unsafe(&tm, &new_rtc.tv_sec);
new_rtc.tv_nsec = 0;
if (new_rtc.tv_sec < old_rtc.tv_sec) {
diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c
index 4aa60d7..4e9a5c6 100644
--- a/drivers/rtc/hctosys.c
+++ b/drivers/rtc/hctosys.c
@@ -52,7 +52,7 @@ static int __init rtc_hctosys(void)
goto err_invalid;
}
- rtc_tm_to_time(&tm, &tv.tv_sec);
+ rtc_tm_to_time_unsafe(&tm, &tv.tv_sec);
err = do_settimeofday(&tv);
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 5b2717f..eff42e9 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -66,7 +66,7 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
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);
+ err = rtc_tm_to_time_unsafe(tm, &secs);
if (err == 0)
err = rtc->ops->set_mmss(rtc->dev.parent, secs);
} else
@@ -250,8 +250,8 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
}
/* with luck, no rollover is needed */
- rtc_tm_to_time(&now, &t_now);
- rtc_tm_to_time(&alarm->time, &t_alm);
+ rtc_tm_to_time_unsafe(&now, &t_now);
+ rtc_tm_to_time_unsafe(&alarm->time, &t_alm);
if (t_now < t_alm)
goto done;
@@ -344,13 +344,13 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
err = rtc_valid_tm(&alarm->time);
if (err)
return err;
- rtc_tm_to_time(&alarm->time, &scheduled);
+ rtc_tm_to_time_unsafe(&alarm->time, &scheduled);
/* Make sure we're not setting alarms in the past */
err = __rtc_read_time(rtc, &tm);
if (err)
return err;
- rtc_tm_to_time(&tm, &now);
+ rtc_tm_to_time_unsafe(&tm, &now);
if (scheduled <= now)
return -ETIME;
/*
diff --git a/drivers/rtc/rtc-88pm80x.c b/drivers/rtc/rtc-88pm80x.c
index 0916089..ad10664 100644
--- a/drivers/rtc/rtc-88pm80x.c
+++ b/drivers/rtc/rtc-88pm80x.c
@@ -100,8 +100,8 @@ static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now,
next->tm_min = alrm->tm_min;
next->tm_sec = alrm->tm_sec;
- rtc_tm_to_time(now, &now_time);
- rtc_tm_to_time(next, &next_time);
+ rtc_tm_to_time_unsafe(now, &now_time);
+ rtc_tm_to_time_unsafe(next, &next_time);
if (next_time < now_time) {
/* Advance one day */
@@ -140,7 +140,7 @@ static int pm80x_rtc_set_time(struct device *dev, struct rtc_time *tm)
1900 + tm->tm_year);
return -EINVAL;
}
- rtc_tm_to_time(tm, &ticks);
+ rtc_tm_to_time_unsafe(tm, &ticks);
/* load 32-bit read-only counter */
regmap_raw_read(info->map, PM800_RTC_COUNTER1, buf, 4);
@@ -206,7 +206,7 @@ static int pm80x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
dev_dbg(info->dev, "%s, now time : %lu\n", __func__, ticks);
rtc_next_alarm_time(&alarm_tm, &now_tm, &alrm->time);
/* get new ticks for alarm in 24 hours */
- rtc_tm_to_time(&alarm_tm, &ticks);
+ rtc_tm_to_time_unsafe(&alarm_tm, &ticks);
dev_dbg(info->dev, "%s, alarm time: %lu\n", __func__, ticks);
data = ticks - base;
@@ -311,7 +311,7 @@ static int pm80x_rtc_probe(struct platform_device *pdev)
goto out_rtc;
}
}
- rtc_tm_to_time(&tm, &ticks);
+ rtc_tm_to_time_unsafe(&tm, &ticks);
info->rtc_dev = devm_rtc_device_register(&pdev->dev, "88pm80x-rtc",
&pm80x_rtc_ops, THIS_MODULE);
diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c
index 0c6add1..4fabd6f 100644
--- a/drivers/rtc/rtc-88pm860x.c
+++ b/drivers/rtc/rtc-88pm860x.c
@@ -96,8 +96,8 @@ static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now,
next->tm_min = alrm->tm_min;
next->tm_sec = alrm->tm_sec;
- rtc_tm_to_time(now, &now_time);
- rtc_tm_to_time(next, &next_time);
+ rtc_tm_to_time_unsafe(now, &now_time);
+ rtc_tm_to_time_unsafe(next, &next_time);
if (next_time < now_time) {
/* Advance one day */
@@ -141,7 +141,7 @@ static int pm860x_rtc_set_time(struct device *dev, struct rtc_time *tm)
1900 + tm->tm_year);
return -EINVAL;
}
- rtc_tm_to_time(tm, &ticks);
+ rtc_tm_to_time_unsafe(tm, &ticks);
/* load 32-bit read-only counter */
pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf);
@@ -210,7 +210,7 @@ static int pm860x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
rtc_time_to_tm(ticks, &now_tm);
rtc_next_alarm_time(&alarm_tm, &now_tm, &alrm->time);
/* get new ticks for alarm in 24 hours */
- rtc_tm_to_time(&alarm_tm, &ticks);
+ rtc_tm_to_time_unsafe(&alarm_tm, &ticks);
data = ticks - base;
buf[0] = data & 0xff;
@@ -367,7 +367,7 @@ static int pm860x_rtc_probe(struct platform_device *pdev)
return ret;
}
}
- rtc_tm_to_time(&tm, &ticks);
+ rtc_tm_to_time_unsafe(&tm, &ticks);
if (pm860x_rtc_dt_init(pdev, info)) {
if (pdata && pdata->sync) {
pdata->sync(ticks);
diff --git a/drivers/rtc/rtc-ab3100.c b/drivers/rtc/rtc-ab3100.c
index ff43534..0beb865 100644
--- a/drivers/rtc/rtc-ab3100.c
+++ b/drivers/rtc/rtc-ab3100.c
@@ -152,7 +152,7 @@ static int ab3100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
int err;
int i;
- rtc_tm_to_time(&alarm->time, &secs);
+ rtc_tm_to_time_unsafe(&alarm->time, &secs);
fat_time = (u64) secs * AB3100_RTC_CLOCK_RATE * 2;
buf[0] = (fat_time >> 16) & 0xFF;
buf[1] = (fat_time >> 24) & 0xFF;
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c
index 727e2f5..1d326dc 100644
--- a/drivers/rtc/rtc-ab8500.c
+++ b/drivers/rtc/rtc-ab8500.c
@@ -80,7 +80,7 @@ static unsigned long get_elapsed_seconds(int year)
* This function calculates secs from 1970 and not from
* 1900, even if we supply the offset from year 1900.
*/
- rtc_tm_to_time(&tm, &secs);
+ rtc_tm_to_time_unsafe(&tm, &secs);
return secs;
}
@@ -146,7 +146,7 @@ static int ab8500_rtc_set_time(struct device *dev, struct rtc_time *tm)
}
/* Get the number of seconds since 1970 */
- rtc_tm_to_time(tm, &secs);
+ rtc_tm_to_time_unsafe(tm, &secs);
/*
* Convert it to the number of seconds since 01-01-2000 00:00:00, since
@@ -239,7 +239,7 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
}
/* Get the number of seconds since 1970 */
- rtc_tm_to_time(&alarm->time, &secs);
+ rtc_tm_to_time_unsafe(&alarm->time, &secs);
/*
* Check whether alarm is set less than 1min.
@@ -247,7 +247,7 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
* return -EINVAL, so UIE EMUL can take it up, incase of UIE_ON
*/
ab8500_rtc_read_time(dev, &curtm); /* Read current time */
- rtc_tm_to_time(&curtm, &cursec);
+ rtc_tm_to_time_unsafe(&curtm, &cursec);
if ((secs - cursec) < 59) {
dev_dbg(dev, "Alarm less than 1 minute not supported\r\n");
return -EINVAL;
@@ -289,7 +289,7 @@ static int ab8540_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
}
/* Get the number of seconds since 1970 */
- rtc_tm_to_time(&alarm->time, &secs);
+ rtc_tm_to_time_unsafe(&alarm->time, &secs);
/*
* Convert it to the number of seconds since 01-01-2000 00:00:00
diff --git a/drivers/rtc/rtc-at32ap700x.c b/drivers/rtc/rtc-at32ap700x.c
index aee3387..26500c0 100644
--- a/drivers/rtc/rtc-at32ap700x.c
+++ b/drivers/rtc/rtc-at32ap700x.c
@@ -84,7 +84,7 @@ static int at32_rtc_settime(struct device *dev, struct rtc_time *tm)
unsigned long now;
int ret;
- ret = rtc_tm_to_time(tm, &now);
+ ret = rtc_tm_to_time_unsafe(tm, &now);
if (ret == 0)
rtc_writel(rtc, VAL, now);
@@ -113,7 +113,7 @@ static int at32_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
rtc_unix_time = rtc_readl(rtc, VAL);
- ret = rtc_tm_to_time(&alrm->time, &alarm_unix_time);
+ ret = rtc_tm_to_time_unsafe(&alrm->time, &alarm_unix_time);
if (ret)
return ret;
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
index 5963743..6d83959 100644
--- a/drivers/rtc/rtc-at91sam9.c
+++ b/drivers/rtc/rtc-at91sam9.c
@@ -115,7 +115,7 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm)
1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
- err = rtc_tm_to_time(tm, &secs);
+ err = rtc_tm_to_time_unsafe(tm, &secs);
if (err != 0)
return err;
@@ -189,7 +189,7 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
u32 mr;
int err;
- err = rtc_tm_to_time(tm, &secs);
+ err = rtc_tm_to_time_unsafe(tm, &secs);
if (err != 0)
return err;
diff --git a/drivers/rtc/rtc-au1xxx.c b/drivers/rtc/rtc-au1xxx.c
index fd25e23..4949259 100644
--- a/drivers/rtc/rtc-au1xxx.c
+++ b/drivers/rtc/rtc-au1xxx.c
@@ -43,7 +43,7 @@ static int au1xtoy_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
unsigned long t;
- rtc_tm_to_time(tm, &t);
+ rtc_tm_to_time_unsafe(tm, &t);
alchemy_wrsys(t, AU1000_SYS_TOYWRITE);
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c
index fe4bdb0..7910191 100644
--- a/drivers/rtc/rtc-bfin.c
+++ b/drivers/rtc/rtc-bfin.c
@@ -276,7 +276,7 @@ static int bfin_rtc_set_time(struct device *dev, struct rtc_time *tm)
dev_dbg_stamp(dev);
- ret = rtc_tm_to_time(tm, &now);
+ ret = rtc_tm_to_time_unsafe(tm, &now);
if (ret == 0) {
if (rtc->rtc_wrote_regs & 0x1)
bfin_rtc_sync_pending(dev);
@@ -304,7 +304,7 @@ static int bfin_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
dev_dbg_stamp(dev);
- if (rtc_tm_to_time(&alrm->time, &rtc_alarm))
+ if (rtc_tm_to_time_unsafe(&alrm->time, &rtc_alarm))
return -EINVAL;
rtc->rtc_alarm = alrm->time;
diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c
index 869cae2..4d6e290 100644
--- a/drivers/rtc/rtc-coh901331.c
+++ b/drivers/rtc/rtc-coh901331.c
@@ -117,7 +117,7 @@ static int coh901331_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
struct coh901331_port *rtap = dev_get_drvdata(dev);
unsigned long time;
- rtc_tm_to_time(&alarm->time, &time);
+ rtc_tm_to_time_unsafe(&alarm->time, &time);
clk_enable(rtap->clk);
writel(time, rtap->virtbase + COH901331_ALARM);
writel(alarm->enabled, rtap->virtbase + COH901331_IRQ_MASK);
diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c
index e5c9486..23dce8a 100644
--- a/drivers/rtc/rtc-da9052.c
+++ b/drivers/rtc/rtc-da9052.c
@@ -83,7 +83,7 @@ static int da9052_set_alarm(struct da9052_rtc *rtc, struct rtc_time *rtc_tm)
int ret;
uint8_t v[3];
- ret = rtc_tm_to_time(rtc_tm, &alm_time);
+ ret = rtc_tm_to_time_unsafe(rtc_tm, &alm_time);
if (ret != 0)
return ret;
diff --git a/drivers/rtc/rtc-da9063.c b/drivers/rtc/rtc-da9063.c
index 731ed1a..b35bc48 100644
--- a/drivers/rtc/rtc-da9063.c
+++ b/drivers/rtc/rtc-da9063.c
@@ -123,8 +123,8 @@ static int da9063_rtc_read_time(struct device *dev, struct rtc_time *tm)
da9063_data_to_tm(data, tm);
- rtc_tm_to_time(tm, &tm_secs);
- rtc_tm_to_time(&rtc->alarm_time, &al_secs);
+ rtc_tm_to_time_unsafe(tm, &tm_secs);
+ rtc_tm_to_time_unsafe(&rtc->alarm_time, &al_secs);
/* handle the rtc synchronisation delay */
if (rtc->rtc_sync == true && al_secs - tm_secs == 1)
diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c
index c0a3b59..915d625 100644
--- a/drivers/rtc/rtc-davinci.c
+++ b/drivers/rtc/rtc-davinci.c
@@ -430,12 +430,12 @@ static int davinci_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
unsigned long now, then;
davinci_rtc_read_time(dev, &tm);
- rtc_tm_to_time(&tm, &now);
+ rtc_tm_to_time_unsafe(&tm, &now);
alm->time.tm_mday = tm.tm_mday;
alm->time.tm_mon = tm.tm_mon;
alm->time.tm_year = tm.tm_year;
- rtc_tm_to_time(&alm->time, &then);
+ rtc_tm_to_time_unsafe(&alm->time, &then);
if (then < now) {
rtc_time_to_tm(now + 24 * 60 * 60, &tm);
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index d049393..6145ba9 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -309,7 +309,7 @@ static long rtc_dev_ioctl(struct file *file,
err = rtc_read_time(rtc, &tm);
if (err < 0)
return err;
- rtc_tm_to_time(&tm, &now);
+ rtc_tm_to_time_unsafe(&tm, &now);
alarm.time.tm_mday = tm.tm_mday;
alarm.time.tm_mon = tm.tm_mon;
@@ -317,7 +317,7 @@ static long rtc_dev_ioctl(struct file *file,
err = rtc_valid_tm(&alarm.time);
if (err < 0)
return err;
- rtc_tm_to_time(&alarm.time, &then);
+ rtc_tm_to_time_unsafe(&alarm.time, &then);
/* alarm may need to wrap into tomorrow */
if (then < now) {
diff --git a/drivers/rtc/rtc-dm355evm.c b/drivers/rtc/rtc-dm355evm.c
index 1aca083..b07d0ee 100644
--- a/drivers/rtc/rtc-dm355evm.c
+++ b/drivers/rtc/rtc-dm355evm.c
@@ -88,7 +88,7 @@ static int dm355evm_rtc_set_time(struct device *dev, struct rtc_time *tm)
unsigned long value;
int status;
- rtc_tm_to_time(tm, &value);
+ rtc_tm_to_time_unsafe(tm, &value);
time.value = cpu_to_le32(value);
dev_dbg(dev, "write timestamp %08x\n", time.value);
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c
index 129add77..6bc0ccf 100644
--- a/drivers/rtc/rtc-ds1305.c
+++ b/drivers/rtc/rtc-ds1305.c
@@ -341,7 +341,7 @@ static int ds1305_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
u8 buf[1 + DS1305_ALM_LEN];
/* convert desired alarm to time_t */
- status = rtc_tm_to_time(&alm->time, &later);
+ status = rtc_tm_to_time_unsafe(&alm->time, &later);
if (status < 0)
return status;
@@ -349,7 +349,7 @@ static int ds1305_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
status = ds1305_get_time(dev, &tm);
if (status < 0)
return status;
- status = rtc_tm_to_time(&tm, &now);
+ status = rtc_tm_to_time_unsafe(&tm, &now);
if (status < 0)
return status;
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index 9e6e14f..12e3b26 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -158,7 +158,7 @@ static int ds1374_set_time(struct device *dev, struct rtc_time *time)
struct i2c_client *client = to_i2c_client(dev);
unsigned long itime;
- rtc_tm_to_time(time, &itime);
+ rtc_tm_to_time_unsafe(time, &itime);
return ds1374_write_rtc(client, itime, DS1374_REG_TOD0, 4);
}
@@ -220,8 +220,8 @@ static int ds1374_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
if (ret < 0)
return ret;
- rtc_tm_to_time(&alarm->time, &new_alarm);
- rtc_tm_to_time(&now, &itime);
+ rtc_tm_to_time_unsafe(&alarm->time, &new_alarm);
+ rtc_tm_to_time_unsafe(&now, &itime);
/* This can happen due to races, in addition to dates that are
* truly in the past. To avoid requiring the caller to check for
diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index cd741c7..53fc4bc 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -271,7 +271,7 @@ static int dryice_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
unsigned long alarm_time;
int rc;
- rc = rtc_tm_to_time(&alarm->time, &alarm_time);
+ rc = rtc_tm_to_time_unsafe(&alarm->time, &alarm_time);
if (rc)
return rc;
diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index c3c549d..d998420 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -377,10 +377,10 @@ isl1208_i2c_set_alarm(struct i2c_client *client, struct rtc_wkalrm *alarm)
err = isl1208_i2c_read_time(client, &rtc_tm);
if (err)
return err;
- err = rtc_tm_to_time(&rtc_tm, &rtc_secs);
+ err = rtc_tm_to_time_unsafe(&rtc_tm, &rtc_secs);
if (err)
return err;
- err = rtc_tm_to_time(alarm_tm, &alarm_secs);
+ err = rtc_tm_to_time_unsafe(alarm_tm, &alarm_secs);
if (err)
return err;
diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c
index 08f5160..a1379cc 100644
--- a/drivers/rtc/rtc-jz4740.c
+++ b/drivers/rtc/rtc-jz4740.c
@@ -158,7 +158,7 @@ static int jz4740_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
struct jz4740_rtc *rtc = dev_get_drvdata(dev);
unsigned long secs;
- rtc_tm_to_time(&alrm->time, &secs);
+ rtc_tm_to_time_unsafe(&alrm->time, &secs);
ret = jz4740_rtc_reg_write(rtc, JZ_REG_RTC_SEC_ALARM, secs);
if (!ret)
diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c
index a0b473a..168d2a2 100644
--- a/drivers/rtc/rtc-lib.c
+++ b/drivers/rtc/rtc-lib.c
@@ -111,13 +111,13 @@ EXPORT_SYMBOL(rtc_valid_tm);
/*
* Convert Gregorian date to seconds since 01-01-1970 00:00:00.
*/
-int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time)
+int rtc_tm_to_time_unsafe(struct rtc_time *tm, unsigned long *time)
{
- *time = mktime_unsafe(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
+ *time = (unsigned long) mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
return 0;
}
-EXPORT_SYMBOL(rtc_tm_to_time);
+EXPORT_SYMBOL(rtc_tm_to_time_unsafe);
/*
* Convert rtc_time to ktime
@@ -125,7 +125,7 @@ EXPORT_SYMBOL(rtc_tm_to_time);
ktime_t rtc_tm_to_ktime(struct rtc_time tm)
{
time_t time;
- rtc_tm_to_time(&tm, &time);
+ rtc_tm_to_time_unsafe(&tm, &time);
return ktime_set(time, 0);
}
EXPORT_SYMBOL_GPL(rtc_tm_to_ktime);
diff --git a/drivers/rtc/rtc-lpc32xx.c b/drivers/rtc/rtc-lpc32xx.c
index f130c08..da235f2 100644
--- a/drivers/rtc/rtc-lpc32xx.c
+++ b/drivers/rtc/rtc-lpc32xx.c
@@ -113,7 +113,7 @@ static int lpc32xx_rtc_set_alarm(struct device *dev,
u32 tmp;
int ret;
- ret = rtc_tm_to_time(&wkalrm->time, &alarmsecs);
+ ret = rtc_tm_to_time_unsafe(&wkalrm->time, &alarmsecs);
if (ret < 0) {
dev_warn(dev, "Failed to convert time: %d\n", ret);
return ret;
diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c
index 0765606..78ec451 100644
--- a/drivers/rtc/rtc-mc13xxx.c
+++ b/drivers/rtc/rtc-mc13xxx.c
@@ -215,7 +215,7 @@ static int mc13xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
if (unlikely(ret))
goto out;
- ret = rtc_tm_to_time(&alarm->time, &s1970);
+ ret = rtc_tm_to_time_unsafe(&alarm->time, &s1970);
if (unlikely(ret))
goto out;
diff --git a/drivers/rtc/rtc-mpc5121.c b/drivers/rtc/rtc-mpc5121.c
index 3b965ad..508a1ed 100644
--- a/drivers/rtc/rtc-mpc5121.c
+++ b/drivers/rtc/rtc-mpc5121.c
@@ -136,7 +136,7 @@ static int mpc5121_rtc_set_time(struct device *dev, struct rtc_time *tm)
* The actual_time register is read only so we write the offset
* between it and linux time to the target_time register.
*/
- ret = rtc_tm_to_time(tm, &now);
+ ret = rtc_tm_to_time_unsafe(tm, &now);
if (ret == 0)
out_be32(®s->target_time, now - in_be32(®s->actual_time));
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
index 419874f..7bc66ab 100644
--- a/drivers/rtc/rtc-mxc.c
+++ b/drivers/rtc/rtc-mxc.c
@@ -189,7 +189,7 @@ static int rtc_update_alarm(struct device *dev, struct rtc_time *alrm)
alarm_tm.tm_hour = alrm->tm_hour;
alarm_tm.tm_min = alrm->tm_min;
alarm_tm.tm_sec = alrm->tm_sec;
- rtc_tm_to_time(&alarm_tm, &time);
+ rtc_tm_to_time_unsafe(&alarm_tm, &time);
/* clear all the interrupt status bits */
writew(readw(ioaddr + RTC_RTCISR), ioaddr + RTC_RTCISR);
@@ -311,7 +311,7 @@ static int mxc_rtc_set_mmss(struct device *dev, unsigned long time)
rtc_time_to_tm(time, &tm);
tm.tm_year = 70;
- rtc_tm_to_time(&tm, &time);
+ rtc_tm_to_time_unsafe(&tm, &time);
}
/* Avoid roll-over from reading the different registers */
diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c
index 40b5c63..d8bfe37 100644
--- a/drivers/rtc/rtc-pcap.c
+++ b/drivers/rtc/rtc-pcap.c
@@ -69,7 +69,7 @@ static int pcap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
unsigned long secs;
u32 tod, days;
- rtc_tm_to_time(tm, &secs);
+ rtc_tm_to_time_unsafe(tm, &secs);
tod = secs % SEC_PER_DAY;
ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_TODA, tod);
diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c
index f85a1a9..5c2c1c8 100644
--- a/drivers/rtc/rtc-pl030.c
+++ b/drivers/rtc/rtc-pl030.c
@@ -54,7 +54,7 @@ static int pl030_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
*/
ret = rtc_valid_tm(&alrm->time);
if (ret == 0)
- ret = rtc_tm_to_time(&alrm->time, &time);
+ ret = rtc_tm_to_time_unsafe(&alrm->time, &time);
if (ret == 0)
writel(time, rtc->base + RTC_MR);
return ret;
@@ -83,7 +83,7 @@ static int pl030_set_time(struct device *dev, struct rtc_time *tm)
unsigned long time;
int ret;
- ret = rtc_tm_to_time(tm, &time);
+ ret = rtc_tm_to_time_unsafe(tm, &time);
if (ret == 0)
writel(time + 1, rtc->base + RTC_LR);
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index 99181fff..5a73252 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -129,7 +129,7 @@ static int pl031_stv2_tm_to_time(struct device *dev,
unsigned long time;
struct rtc_time calc_tm;
- rtc_tm_to_time(tm, &time);
+ rtc_tm_to_time_unsafe(tm, &time);
rtc_time_to_tm(time, &calc_tm);
wday = calc_tm.tm_wday;
}
@@ -262,7 +262,7 @@ static int pl031_set_time(struct device *dev, struct rtc_time *tm)
struct pl031_local *ldata = dev_get_drvdata(dev);
int ret;
- ret = rtc_tm_to_time(tm, &time);
+ ret = rtc_tm_to_time_unsafe(tm, &time);
if (ret == 0)
writel(time, ldata->base + RTC_LR);
@@ -291,7 +291,7 @@ static int pl031_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
/* At the moment, we can only deal with non-wildcarded alarm times. */
ret = rtc_valid_tm(&alarm->time);
if (ret == 0) {
- ret = rtc_tm_to_time(&alarm->time, &time);
+ ret = rtc_tm_to_time_unsafe(&alarm->time, &time);
if (ret == 0) {
writel(time, ldata->base + RTC_MR);
pl031_alarm_irq_enable(dev, alarm->enabled);
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index 197699f..76d5b84 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -77,7 +77,7 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
if (!rtc_dd->allow_set_time)
return -EACCES;
- rtc_tm_to_time(tm, &secs);
+ rtc_tm_to_time_unsafe(tm, &secs);
for (i = 0; i < NUM_8_BIT_RTC_REGS; i++) {
value[i] = secs & 0xFF;
@@ -199,7 +199,7 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
unsigned long secs, irq_flags;
struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
- rtc_tm_to_time(&alarm->time, &secs);
+ rtc_tm_to_time_unsafe(&alarm->time, &secs);
for (i = 0; i < NUM_8_BIT_RTC_REGS; i++) {
value[i] = secs & 0xFF;
diff --git a/drivers/rtc/rtc-ps3.c b/drivers/rtc/rtc-ps3.c
index 554ada5..e6f3fe6 100644
--- a/drivers/rtc/rtc-ps3.c
+++ b/drivers/rtc/rtc-ps3.c
@@ -48,7 +48,7 @@ static int ps3_set_time(struct device *dev, struct rtc_time *tm)
{
unsigned long now;
- rtc_tm_to_time(tm, &now);
+ rtc_tm_to_time_unsafe(tm, &now);
ps3_os_area_set_rtc_diff(now - read_rtc());
return 0;
}
diff --git a/drivers/rtc/rtc-puv3.c b/drivers/rtc/rtc-puv3.c
index 1cff2a2..ae8b7e8 100644
--- a/drivers/rtc/rtc-puv3.c
+++ b/drivers/rtc/rtc-puv3.c
@@ -105,7 +105,7 @@ static int puv3_rtc_settime(struct device *dev, struct rtc_time *tm)
tm->tm_year, tm->tm_mon, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
- rtc_tm_to_time(tm, &rtc_count);
+ rtc_tm_to_time_unsafe(tm, &rtc_count);
writel(rtc_count, RTC_RCNR);
return 0;
@@ -137,7 +137,7 @@ static int puv3_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
tm->tm_mday & 0xff, tm->tm_mon & 0xff, tm->tm_year & 0xff,
tm->tm_hour & 0xff, tm->tm_min & 0xff, tm->tm_sec);
- rtc_tm_to_time(tm, &rtcalarm_count);
+ rtc_tm_to_time_unsafe(tm, &rtcalarm_count);
writel(rtcalarm_count, RTC_RTAR);
puv3_rtc_setaie(dev, alrm->enabled);
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index b6e1ca0..b736f1e 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -166,7 +166,7 @@ static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm)
unsigned long time;
int ret;
- ret = rtc_tm_to_time(tm, &time);
+ ret = rtc_tm_to_time_unsafe(tm, &time);
if (ret == 0)
RCNR = time;
return ret;
@@ -189,7 +189,7 @@ static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
int ret;
spin_lock_irq(&info->lock);
- ret = rtc_tm_to_time(&alrm->time, &time);
+ ret = rtc_tm_to_time_unsafe(&alrm->time, &time);
if (ret != 0)
goto out;
RTSR = RTSR & (RTSR_HZE|RTSR_ALE|RTSR_AL);
diff --git a/drivers/rtc/rtc-sirfsoc.c b/drivers/rtc/rtc-sirfsoc.c
index 76e3800..8579970 100644
--- a/drivers/rtc/rtc-sirfsoc.c
+++ b/drivers/rtc/rtc-sirfsoc.c
@@ -97,7 +97,7 @@ static int sirfsoc_rtc_set_alarm(struct device *dev,
rtcdrv = dev_get_drvdata(dev);
if (alrm->enabled) {
- rtc_tm_to_time(&(alrm->time), &rtc_alarm);
+ rtc_tm_to_time_unsafe(&(alrm->time), &rtc_alarm);
local_irq_disable();
@@ -180,7 +180,7 @@ static int sirfsoc_rtc_set_time(struct device *dev,
struct sirfsoc_rtc_drv *rtcdrv;
rtcdrv = dev_get_drvdata(dev);
- rtc_tm_to_time(tm, &rtc_time);
+ rtc_tm_to_time_unsafe(tm, &rtc_time);
rtcdrv->overflow_rtc = rtc_time >> (BITS_PER_LONG - RTC_SHIFT);
diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c
index fa384fe..198377a 100644
--- a/drivers/rtc/rtc-snvs.c
+++ b/drivers/rtc/rtc-snvs.c
@@ -131,7 +131,7 @@ static int snvs_rtc_set_time(struct device *dev, struct rtc_time *tm)
struct snvs_rtc_data *data = dev_get_drvdata(dev);
unsigned long time;
- rtc_tm_to_time(tm, &time);
+ rtc_tm_to_time_unsafe(tm, &time);
/* Disable RTC first */
snvs_rtc_enable(data, false);
@@ -190,7 +190,7 @@ static int snvs_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
unsigned long flags;
u32 lpcr;
- rtc_tm_to_time(alrm_tm, &time);
+ rtc_tm_to_time_unsafe(alrm_tm, &time);
spin_lock_irqsave(&data->lock, flags);
diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c
index ea96492..f9a0c46 100644
--- a/drivers/rtc/rtc-stmp3xxx.c
+++ b/drivers/rtc/rtc-stmp3xxx.c
@@ -214,7 +214,7 @@ static int stmp3xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
unsigned long t;
struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev);
- rtc_tm_to_time(&alm->time, &t);
+ rtc_tm_to_time_unsafe(&alm->time, &t);
writel(t, rtc_data->io + STMP3XXX_RTC_ALARM);
stmp3xxx_alarm_irq_enable(dev, alm->enabled);
diff --git a/drivers/rtc/rtc-sun4v.c b/drivers/rtc/rtc-sun4v.c
index bc97ff9..ed041ed 100644
--- a/drivers/rtc/rtc-sun4v.c
+++ b/drivers/rtc/rtc-sun4v.c
@@ -67,7 +67,7 @@ static int sun4v_set_time(struct device *dev, struct rtc_time *tm)
unsigned long secs;
int err;
- err = rtc_tm_to_time(tm, &secs);
+ err = rtc_tm_to_time_unsafe(tm, &secs);
if (err)
return err;
diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
index c169a2c..c49c399 100644
--- a/drivers/rtc/rtc-sun6i.c
+++ b/drivers/rtc/rtc-sun6i.c
@@ -219,8 +219,8 @@ static int sun6i_rtc_setalarm(struct device *dev, struct rtc_wkalrm *wkalrm)
return -EINVAL;
}
- rtc_tm_to_time(alrm_tm, &time_set);
- rtc_tm_to_time(&tm_now, &time_now);
+ rtc_tm_to_time_unsafe(alrm_tm, &time_set);
+ rtc_tm_to_time_unsafe(&tm_now, &time_now);
if (time_set <= time_now) {
dev_err(dev, "Date to set in the past\n");
return -EINVAL;
diff --git a/drivers/rtc/rtc-sunxi.c b/drivers/rtc/rtc-sunxi.c
index b6f21f7..1124b3f 100644
--- a/drivers/rtc/rtc-sunxi.c
+++ b/drivers/rtc/rtc-sunxi.c
@@ -284,8 +284,8 @@ static int sunxi_rtc_setalarm(struct device *dev, struct rtc_wkalrm *wkalrm)
return -EINVAL;
}
- rtc_tm_to_time(alrm_tm, &time_set);
- rtc_tm_to_time(&tm_now, &time_now);
+ rtc_tm_to_time_unsafe(alrm_tm, &time_set);
+ rtc_tm_to_time_unsafe(&tm_now, &time_now);
if (time_set <= time_now) {
dev_err(dev, "Date to set in the past\n");
return -EINVAL;
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index babd43b..b9695f3 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -72,7 +72,7 @@ since_epoch_show(struct device *dev, struct device_attribute *attr, char *buf)
retval = rtc_read_time(to_rtc_device(dev), &tm);
if (retval == 0) {
unsigned long time;
- rtc_tm_to_time(&tm, &time);
+ rtc_tm_to_time_unsafe(&tm, &time);
retval = sprintf(buf, "%lu\n", time);
}
@@ -151,7 +151,7 @@ rtc_sysfs_show_wakealarm(struct device *dev, struct device_attribute *attr,
*/
retval = rtc_read_alarm(to_rtc_device(dev), &alm);
if (retval == 0 && alm.enabled) {
- rtc_tm_to_time(&alm.time, &alarm);
+ rtc_tm_to_time_unsafe(&alm.time, &alarm);
retval = sprintf(buf, "%lu\n", alarm);
}
@@ -176,7 +176,7 @@ rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr,
retval = rtc_read_time(rtc, &alm.time);
if (retval < 0)
return retval;
- rtc_tm_to_time(&alm.time, &now);
+ rtc_tm_to_time_unsafe(&alm.time, &now);
buf_ptr = (char *)buf;
if (*buf_ptr == '+') {
@@ -201,7 +201,7 @@ rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr,
return retval;
if (alm.enabled) {
if (push) {
- rtc_tm_to_time(&alm.time, &push);
+ rtc_tm_to_time_unsafe(&alm.time, &push);
alarm += push;
} else
return -EBUSY;
diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c
index 76af92a..409b4a0 100644
--- a/drivers/rtc/rtc-tegra.c
+++ b/drivers/rtc/rtc-tegra.c
@@ -145,7 +145,7 @@ static int tegra_rtc_set_time(struct device *dev, struct rtc_time *tm)
if (ret)
return ret;
- rtc_tm_to_time(tm, &sec);
+ rtc_tm_to_time_unsafe(tm, &sec);
dev_vdbg(dev, "time set to %lu. %d/%d/%d %d:%02u:%02u\n",
sec,
@@ -226,7 +226,7 @@ static int tegra_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
unsigned long sec;
if (alarm->enabled)
- rtc_tm_to_time(&alarm->time, &sec);
+ rtc_tm_to_time_unsafe(&alarm->time, &sec);
else
sec = 0;
diff --git a/drivers/rtc/rtc-tps6586x.c b/drivers/rtc/rtc-tps6586x.c
index 5f8d726..341b000 100644
--- a/drivers/rtc/rtc-tps6586x.c
+++ b/drivers/rtc/rtc-tps6586x.c
@@ -102,7 +102,7 @@ static int tps6586x_rtc_set_time(struct device *dev, struct rtc_time *tm)
u8 buff[5];
int ret;
- rtc_tm_to_time(tm, &seconds);
+ rtc_tm_to_time_unsafe(tm, &seconds);
if (seconds < rtc->epoch_start) {
dev_err(dev, "requested time unsupported\n");
return -EINVAL;
@@ -166,7 +166,7 @@ static int tps6586x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
int ret;
int i;
- rtc_tm_to_time(&alrm->time, &seconds);
+ rtc_tm_to_time_unsafe(&alrm->time, &seconds);
if (alrm->enabled && (seconds < rtc->epoch_start)) {
dev_err(dev, "can't set alarm to requested time\n");
diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c
index 2e678c6..b3cf814 100644
--- a/drivers/rtc/rtc-tx4939.c
+++ b/drivers/rtc/rtc-tx4939.c
@@ -106,7 +106,7 @@ static int tx4939_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
alrm->time.tm_mon < 0 ||
alrm->time.tm_year < 0)
return -EINVAL;
- rtc_tm_to_time(&alrm->time, &sec);
+ rtc_tm_to_time_unsafe(&alrm->time, &sec);
buf[0] = 0;
buf[1] = 0;
buf[2] = sec;
diff --git a/drivers/rtc/rtc-wm831x.c b/drivers/rtc/rtc-wm831x.c
index 75aea4c..5d6a877 100644
--- a/drivers/rtc/rtc-wm831x.c
+++ b/drivers/rtc/rtc-wm831x.c
@@ -215,7 +215,7 @@ static int wm831x_rtc_set_mmss(struct device *dev, unsigned long time)
if (ret < 0)
return ret;
- ret = rtc_tm_to_time(&new_tm, &new_time);
+ ret = rtc_tm_to_time_unsafe(&new_tm, &new_time);
if (ret < 0) {
dev_err(dev, "Failed to convert time: %d\n", ret);
return ret;
@@ -288,7 +288,7 @@ static int wm831x_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
int ret;
unsigned long time;
- ret = rtc_tm_to_time(&alrm->time, &time);
+ ret = rtc_tm_to_time_unsafe(&alrm->time, &time);
if (ret < 0) {
dev_err(dev, "Failed to convert time: %d\n", ret);
return ret;
diff --git a/drivers/rtc/rtc-xgene.c b/drivers/rtc/rtc-xgene.c
index 14129cc..2da0616 100644
--- a/drivers/rtc/rtc-xgene.c
+++ b/drivers/rtc/rtc-xgene.c
@@ -111,7 +111,7 @@ static int xgene_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
unsigned long alarm_time;
rtc_time = readl(pdata->csr_base + RTC_CCVR);
- rtc_tm_to_time(&alrm->time, &alarm_time);
+ rtc_tm_to_time_unsafe(&alrm->time, &alarm_time);
pdata->alarm_time = alarm_time;
writel((u32) pdata->alarm_time, pdata->csr_base + RTC_CMR);
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index c2c2897..97bbb6f 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -19,7 +19,7 @@
extern int rtc_month_days(unsigned int month, unsigned int year);
extern int rtc_year_days(unsigned int day, unsigned int month, unsigned int year);
extern int rtc_valid_tm(struct rtc_time *tm);
-extern int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time);
+extern int rtc_tm_to_time_unsafe(struct rtc_time *tm, unsigned long *time);
extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm);
ktime_t rtc_tm_to_ktime(struct rtc_time tm);
struct rtc_time rtc_ktime_to_tm(ktime_t kt);
diff --git a/kernel/power/suspend_test.c b/kernel/power/suspend_test.c
index 084452e..f82b228 100644
--- a/kernel/power/suspend_test.c
+++ b/kernel/power/suspend_test.c
@@ -82,7 +82,7 @@ repeat:
printk(err_readtime, dev_name(&rtc->dev), status);
return;
}
- rtc_tm_to_time(&alm.time, &now);
+ rtc_tm_to_time_unsafe(&alm.time, &now);
memset(&alm, 0, sizeof alm);
rtc_time_to_tm(now + TEST_SUSPEND_SECONDS, &alm.time);
--
1.7.9.5
The kernel uses 32-bit signed value(time_t) for seconds since 1970-01-01:00:00:00, so it
will overflow at 2038-01-19 03:14:08 on 32-bit systems. We call this "2038 safety" issue.
As part of addressing 2038 saftey for in-kernel uses, this patch creates no functional change
in existing users, and converts rtc_tm_to_time_unsafe() to rtc_tm_to_time() in rtc_hctosys().
Signed-off-by: pang.xunlei <[email protected]>
---
drivers/rtc/hctosys.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c
index 4e9a5c6..c80723f 100644
--- a/drivers/rtc/hctosys.c
+++ b/drivers/rtc/hctosys.c
@@ -26,9 +26,10 @@ static int __init rtc_hctosys(void)
{
int err = -ENODEV;
struct rtc_time tm;
- struct timespec tv = {
+ struct timespec64 tv = {
.tv_nsec = NSEC_PER_SEC >> 1,
};
+ struct timespec ts32;
struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
if (rtc == NULL) {
@@ -52,16 +53,17 @@ static int __init rtc_hctosys(void)
goto err_invalid;
}
- rtc_tm_to_time_unsafe(&tm, &tv.tv_sec);
+ rtc_tm_to_time(&tm, &tv.tv_sec);
- err = do_settimeofday(&tv);
+ ts32 = timespec64_to_timespec(tv);
+ err = do_settimeofday(&ts32);
dev_info(rtc->dev.parent,
"setting system clock to "
- "%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
+ "%d-%02d-%02d %02d:%02d:%02d UTC (%llu)\n",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec,
- (unsigned int) tv.tv_sec);
+ (unsigned long long) tv.tv_sec);
err_invalid:
err_read:
--
1.7.9.5
The kernel uses 32-bit signed value(time_t) for seconds since 1970-01-01:00:00:00, thus it
will overflow at 2038-01-19 03:14:08 on 32-bit systems. We call this "2038 safety" issue.
Currently, rtc_time_to_tm() deals with "unsigned long" which is 2038 unsafe on 32-bit systems.
As part of addressing 2038 saftey for in-kernel uses, this patch creates no creates no functional
change in existing users, renames rtc_time_to_tm() to rtc_time_to_tm_unsafe(), and changes all its
calling users correspondingly. The safe version of rtc_time_to_tm() will be added in the following patch.
Signed-off-by: pang.xunlei <[email protected]>
---
arch/mips/sibyte/swarm/rtc_m41t81.c | 2 +-
arch/mips/sibyte/swarm/rtc_xicor1241.c | 2 +-
arch/sh/kernel/time.c | 2 +-
arch/x86/kernel/rtc.c | 2 +-
arch/x86/platform/intel-mid/intel_mid_vrtc.c | 2 +-
drivers/power/charger-manager.c | 2 +-
drivers/rtc/interface.c | 4 ++--
drivers/rtc/rtc-88pm80x.c | 8 ++++----
drivers/rtc/rtc-88pm860x.c | 8 ++++----
drivers/rtc/rtc-ab3100.c | 4 ++--
drivers/rtc/rtc-ab8500.c | 4 ++--
drivers/rtc/rtc-at32ap700x.c | 4 ++--
drivers/rtc/rtc-at91sam9.c | 4 ++--
drivers/rtc/rtc-au1xxx.c | 2 +-
drivers/rtc/rtc-bfin.c | 2 +-
drivers/rtc/rtc-coh901331.c | 4 ++--
drivers/rtc/rtc-da9052.c | 2 +-
drivers/rtc/rtc-davinci.c | 2 +-
drivers/rtc/rtc-dev.c | 2 +-
drivers/rtc/rtc-dm355evm.c | 2 +-
drivers/rtc/rtc-ds1374.c | 4 ++--
drivers/rtc/rtc-ds1511.c | 2 +-
drivers/rtc/rtc-ds1553.c | 2 +-
drivers/rtc/rtc-ds1672.c | 2 +-
drivers/rtc/rtc-ds2404.c | 2 +-
drivers/rtc/rtc-ep93xx.c | 2 +-
drivers/rtc/rtc-imxdi.c | 4 ++--
drivers/rtc/rtc-jz4740.c | 4 ++--
drivers/rtc/rtc-lib.c | 6 +++---
drivers/rtc/rtc-lpc32xx.c | 4 ++--
drivers/rtc/rtc-ls1x.c | 2 +-
drivers/rtc/rtc-mc13xxx.c | 4 ++--
drivers/rtc/rtc-mpc5121.c | 2 +-
drivers/rtc/rtc-mv.c | 2 +-
drivers/rtc/rtc-mxc.c | 8 ++++----
drivers/rtc/rtc-pcap.c | 4 ++--
drivers/rtc/rtc-pl030.c | 4 ++--
drivers/rtc/rtc-pl031.c | 6 +++---
drivers/rtc/rtc-pm8xxx.c | 4 ++--
drivers/rtc/rtc-ps3.c | 2 +-
drivers/rtc/rtc-puv3.c | 4 ++--
drivers/rtc/rtc-rs5c348.c | 4 ++--
drivers/rtc/rtc-rx8025.c | 2 +-
drivers/rtc/rtc-sa1100.c | 2 +-
drivers/rtc/rtc-sh.c | 2 +-
drivers/rtc/rtc-sirfsoc.c | 6 +++---
drivers/rtc/rtc-snvs.c | 4 ++--
drivers/rtc/rtc-starfire.c | 2 +-
drivers/rtc/rtc-stk17ta8.c | 2 +-
drivers/rtc/rtc-stmp3xxx.c | 4 ++--
drivers/rtc/rtc-sun4v.c | 2 +-
drivers/rtc/rtc-sun6i.c | 2 +-
drivers/rtc/rtc-sysfs.c | 2 +-
drivers/rtc/rtc-tegra.c | 4 ++--
drivers/rtc/rtc-test.c | 2 +-
drivers/rtc/rtc-tps6586x.c | 4 ++--
drivers/rtc/rtc-tx4939.c | 4 ++--
drivers/rtc/rtc-vr41xx.c | 4 ++--
drivers/rtc/rtc-wm831x.c | 4 ++--
drivers/rtc/rtc-xgene.c | 4 ++--
drivers/rtc/systohc.c | 4 ++--
drivers/staging/android/alarm-dev.c | 2 +-
include/linux/rtc.h | 2 +-
kernel/power/suspend_test.c | 2 +-
64 files changed, 104 insertions(+), 104 deletions(-)
diff --git a/arch/mips/sibyte/swarm/rtc_m41t81.c b/arch/mips/sibyte/swarm/rtc_m41t81.c
index c117804..9b239f1 100644
--- a/arch/mips/sibyte/swarm/rtc_m41t81.c
+++ b/arch/mips/sibyte/swarm/rtc_m41t81.c
@@ -147,7 +147,7 @@ int m41t81_set_time(unsigned long t)
unsigned long flags;
/* Note we don't care about the century */
- rtc_time_to_tm(t, &tm);
+ rtc_time_to_tm_unsafe(t, &tm);
/*
* Note the write order matters as it ensures the correctness.
diff --git a/arch/mips/sibyte/swarm/rtc_xicor1241.c b/arch/mips/sibyte/swarm/rtc_xicor1241.c
index ba9e4b40..a62787c 100644
--- a/arch/mips/sibyte/swarm/rtc_xicor1241.c
+++ b/arch/mips/sibyte/swarm/rtc_xicor1241.c
@@ -115,7 +115,7 @@ int xicor_set_time(unsigned long t)
int tmp;
unsigned long flags;
- rtc_time_to_tm(t, &tm);
+ rtc_time_to_tm_unsafe(t, &tm);
tm.tm_year += 1900;
spin_lock_irqsave(&rtc_lock, flags);
diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c
index 78a1632..06e6321 100644
--- a/arch/sh/kernel/time.c
+++ b/arch/sh/kernel/time.c
@@ -56,7 +56,7 @@ unsigned int get_rtc_time(struct rtc_time *tm)
struct timespec tv;
rtc_sh_get_time(&tv);
- rtc_time_to_tm(tv.tv_sec, tm);
+ rtc_time_to_tm_unsafe(tv.tv_sec, tm);
}
return RTC_24H;
diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
index 820958d..e7f1bb9 100644
--- a/arch/x86/kernel/rtc.c
+++ b/arch/x86/kernel/rtc.c
@@ -44,7 +44,7 @@ int mach_set_rtc_mmss(const struct timespec *now)
struct rtc_time tm;
int retval = 0;
- rtc_time_to_tm(nowtime, &tm);
+ rtc_time_to_tm_unsafe(nowtime, &tm);
if (!rtc_valid_tm(&tm)) {
retval = set_rtc_time(&tm);
if (retval)
diff --git a/arch/x86/platform/intel-mid/intel_mid_vrtc.c b/arch/x86/platform/intel-mid/intel_mid_vrtc.c
index 5685ca2..f5020b1 100644
--- a/arch/x86/platform/intel-mid/intel_mid_vrtc.c
+++ b/arch/x86/platform/intel-mid/intel_mid_vrtc.c
@@ -93,7 +93,7 @@ int vrtc_set_mmss(const struct timespec *now)
int year;
int retval = 0;
- rtc_time_to_tm(now->tv_sec, &tm);
+ rtc_time_to_tm_unsafe(now->tv_sec, &tm);
if (!rtc_valid_tm(&tm) && tm.tm_year >= 72) {
/*
* tm.year is the number of years since 1900, and the
diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
index 060aa2c..0fc2cbb 100644
--- a/drivers/power/charger-manager.c
+++ b/drivers/power/charger-manager.c
@@ -1052,7 +1052,7 @@ static bool cm_setup_timer(void)
pr_info("Waking up after %lu secs\n", time - now);
- rtc_time_to_tm(time, &tmp.time);
+ rtc_time_to_tm_unsafe(time, &tmp.time);
rtc_set_alarm(rtc_dev, &tmp);
cm_suspend_duration_ms += wakeup_ms;
return ret;
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index eff42e9..d728234 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -97,7 +97,7 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs)
err = rtc->ops->read_time(rtc->dev.parent, &old);
if (err == 0) {
- rtc_time_to_tm(secs, &new);
+ rtc_time_to_tm_unsafe(secs, &new);
/*
* avoid writing when we're going to change the day of
@@ -265,7 +265,7 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
case day:
dev_dbg(&rtc->dev, "alarm rollover: %s\n", "day");
t_alm += 24 * 60 * 60;
- rtc_time_to_tm(t_alm, &alarm->time);
+ rtc_time_to_tm_unsafe(t_alm, &alarm->time);
break;
/* Month rollover ... if it's the 31th, an alarm on the 3rd will
diff --git a/drivers/rtc/rtc-88pm80x.c b/drivers/rtc/rtc-88pm80x.c
index ad10664..12404f0 100644
--- a/drivers/rtc/rtc-88pm80x.c
+++ b/drivers/rtc/rtc-88pm80x.c
@@ -106,7 +106,7 @@ static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now,
if (next_time < now_time) {
/* Advance one day */
next_time += 60 * 60 * 24;
- rtc_time_to_tm(next_time, next);
+ rtc_time_to_tm_unsafe(next_time, next);
}
}
@@ -125,7 +125,7 @@ static int pm80x_rtc_read_time(struct device *dev, struct rtc_time *tm)
ticks = base + data;
dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
base, data, ticks);
- rtc_time_to_tm(ticks, tm);
+ rtc_time_to_tm_unsafe(ticks, tm);
return 0;
}
@@ -174,7 +174,7 @@ static int pm80x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
base, data, ticks);
- rtc_time_to_tm(ticks, &alrm->time);
+ rtc_time_to_tm_unsafe(ticks, &alrm->time);
regmap_read(info->map, PM800_RTC_CONTROL, &ret);
alrm->enabled = (ret & PM800_ALARM1_EN) ? 1 : 0;
alrm->pending = (ret & (PM800_ALARM | PM800_ALARM_WAKEUP)) ? 1 : 0;
@@ -202,7 +202,7 @@ static int pm80x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
base, data, ticks);
- rtc_time_to_tm(ticks, &now_tm);
+ rtc_time_to_tm_unsafe(ticks, &now_tm);
dev_dbg(info->dev, "%s, now time : %lu\n", __func__, ticks);
rtc_next_alarm_time(&alarm_tm, &now_tm, &alrm->time);
/* get new ticks for alarm in 24 hours */
diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c
index 4fabd6f..fc88177 100644
--- a/drivers/rtc/rtc-88pm860x.c
+++ b/drivers/rtc/rtc-88pm860x.c
@@ -102,7 +102,7 @@ static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now,
if (next_time < now_time) {
/* Advance one day */
next_time += 60 * 60 * 24;
- rtc_time_to_tm(next_time, next);
+ rtc_time_to_tm_unsafe(next_time, next);
}
}
@@ -124,7 +124,7 @@ static int pm860x_rtc_read_time(struct device *dev, struct rtc_time *tm)
dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
base, data, ticks);
- rtc_time_to_tm(ticks, tm);
+ rtc_time_to_tm_unsafe(ticks, tm);
return 0;
}
@@ -178,7 +178,7 @@ static int pm860x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
base, data, ticks);
- rtc_time_to_tm(ticks, &alrm->time);
+ rtc_time_to_tm_unsafe(ticks, &alrm->time);
ret = pm860x_reg_read(info->i2c, PM8607_RTC1);
alrm->enabled = (ret & ALARM_EN) ? 1 : 0;
alrm->pending = (ret & (ALARM | ALARM_WAKEUP)) ? 1 : 0;
@@ -207,7 +207,7 @@ static int pm860x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
base, data, ticks);
- rtc_time_to_tm(ticks, &now_tm);
+ rtc_time_to_tm_unsafe(ticks, &now_tm);
rtc_next_alarm_time(&alarm_tm, &now_tm, &alrm->time);
/* get new ticks for alarm in 24 hours */
rtc_tm_to_time_unsafe(&alarm_tm, &ticks);
diff --git a/drivers/rtc/rtc-ab3100.c b/drivers/rtc/rtc-ab3100.c
index 0beb865..dcc954d 100644
--- a/drivers/rtc/rtc-ab3100.c
+++ b/drivers/rtc/rtc-ab3100.c
@@ -105,7 +105,7 @@ static int ab3100_rtc_read_time(struct device *dev, struct rtc_time *tm)
(u64) (AB3100_RTC_CLOCK_RATE * 2));
}
- rtc_time_to_tm(time, tm);
+ rtc_time_to_tm_unsafe(time, tm);
return rtc_valid_tm(tm);
}
@@ -138,7 +138,7 @@ static int ab3100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
((u64) buf[1] << 24) | ((u64) buf[0] << 16);
time = (unsigned long) (fat_time / (u64) (AB3100_RTC_CLOCK_RATE * 2));
- rtc_time_to_tm(time, &alarm->time);
+ rtc_time_to_tm_unsafe(time, &alarm->time);
return rtc_valid_tm(&alarm->time);
}
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c
index 1d326dc..4ecb940 100644
--- a/drivers/rtc/rtc-ab8500.c
+++ b/drivers/rtc/rtc-ab8500.c
@@ -129,7 +129,7 @@ static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm)
/* Add back the initially subtracted number of seconds */
secs += get_elapsed_seconds(AB8500_RTC_EPOCH);
- rtc_time_to_tm(secs, tm);
+ rtc_time_to_tm_unsafe(secs, tm);
return rtc_valid_tm(tm);
}
@@ -213,7 +213,7 @@ static int ab8500_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
/* Add back the initially subtracted number of seconds */
secs += get_elapsed_seconds(AB8500_RTC_EPOCH);
- rtc_time_to_tm(secs, &alarm->time);
+ rtc_time_to_tm_unsafe(secs, &alarm->time);
return rtc_valid_tm(&alarm->time);
}
diff --git a/drivers/rtc/rtc-at32ap700x.c b/drivers/rtc/rtc-at32ap700x.c
index 26500c0..9875937 100644
--- a/drivers/rtc/rtc-at32ap700x.c
+++ b/drivers/rtc/rtc-at32ap700x.c
@@ -73,7 +73,7 @@ static int at32_rtc_readtime(struct device *dev, struct rtc_time *tm)
unsigned long now;
now = rtc_readl(rtc, VAL);
- rtc_time_to_tm(now, tm);
+ rtc_time_to_tm_unsafe(now, tm);
return 0;
}
@@ -96,7 +96,7 @@ static int at32_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
struct rtc_at32ap700x *rtc = dev_get_drvdata(dev);
spin_lock_irq(&rtc->lock);
- rtc_time_to_tm(rtc->alarm_time, &alrm->time);
+ rtc_time_to_tm_unsafe(rtc->alarm_time, &alrm->time);
alrm->enabled = rtc_readl(rtc, IMR) & RTC_BIT(IMR_TOPI) ? 1 : 0;
alrm->pending = rtc_readl(rtc, ISR) & RTC_BIT(ISR_TOPI) ? 1 : 0;
spin_unlock_irq(&rtc->lock);
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
index 6d83959..ddfaa40 100644
--- a/drivers/rtc/rtc-at91sam9.c
+++ b/drivers/rtc/rtc-at91sam9.c
@@ -92,7 +92,7 @@ static int at91_rtc_readtime(struct device *dev, struct rtc_time *tm)
if (secs != secs2)
secs = rtt_readl(rtc, VR);
- rtc_time_to_tm(offset + secs, tm);
+ rtc_time_to_tm_unsafe(offset + secs, tm);
dev_dbg(dev, "%s: %4d-%02d-%02d %02d:%02d:%02d\n", "readtime",
1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
@@ -167,7 +167,7 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
memset(alrm, 0, sizeof(*alrm));
if (alarm != ALARM_DISABLED && offset != 0) {
- rtc_time_to_tm(offset + alarm, tm);
+ rtc_time_to_tm_unsafe(offset + alarm, tm);
dev_dbg(dev, "%s: %4d-%02d-%02d %02d:%02d:%02d\n", "readalarm",
1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
diff --git a/drivers/rtc/rtc-au1xxx.c b/drivers/rtc/rtc-au1xxx.c
index 4949259..3bcff88 100644
--- a/drivers/rtc/rtc-au1xxx.c
+++ b/drivers/rtc/rtc-au1xxx.c
@@ -34,7 +34,7 @@ static int au1xtoy_rtc_read_time(struct device *dev, struct rtc_time *tm)
t = alchemy_rdsys(AU1000_SYS_TOYREAD);
- rtc_time_to_tm(t, tm);
+ rtc_time_to_tm_unsafe(t, tm);
return rtc_valid_tm(tm);
}
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c
index 7910191..78ee806 100644
--- a/drivers/rtc/rtc-bfin.c
+++ b/drivers/rtc/rtc-bfin.c
@@ -103,7 +103,7 @@ static inline unsigned long rtc_bfin_to_time(u32 rtc_bfin)
}
static inline void rtc_bfin_to_tm(u32 rtc_bfin, struct rtc_time *tm)
{
- rtc_time_to_tm(rtc_bfin_to_time(rtc_bfin), tm);
+ rtc_time_to_tm_unsafe(rtc_bfin_to_time(rtc_bfin), tm);
}
/**
diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c
index 4d6e290..da9cb8b 100644
--- a/drivers/rtc/rtc-coh901331.c
+++ b/drivers/rtc/rtc-coh901331.c
@@ -80,7 +80,7 @@ static int coh901331_read_time(struct device *dev, struct rtc_time *tm)
clk_enable(rtap->clk);
/* Check if the time is valid */
if (readl(rtap->virtbase + COH901331_VALID)) {
- rtc_time_to_tm(readl(rtap->virtbase + COH901331_CUR_TIME), tm);
+ rtc_time_to_tm_unsafe(readl(rtap->virtbase + COH901331_CUR_TIME), tm);
clk_disable(rtap->clk);
return rtc_valid_tm(tm);
}
@@ -104,7 +104,7 @@ static int coh901331_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
struct coh901331_port *rtap = dev_get_drvdata(dev);
clk_enable(rtap->clk);
- rtc_time_to_tm(readl(rtap->virtbase + COH901331_ALARM), &alarm->time);
+ rtc_time_to_tm_unsafe(readl(rtap->virtbase + COH901331_ALARM), &alarm->time);
alarm->pending = readl(rtap->virtbase + COH901331_IRQ_EVENT) & 1U;
alarm->enabled = readl(rtap->virtbase + COH901331_IRQ_MASK) & 1U;
clk_disable(rtap->clk);
diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c
index 23dce8a..715f816 100644
--- a/drivers/rtc/rtc-da9052.c
+++ b/drivers/rtc/rtc-da9052.c
@@ -89,7 +89,7 @@ static int da9052_set_alarm(struct da9052_rtc *rtc, struct rtc_time *rtc_tm)
if (rtc_tm->tm_sec > 0) {
alm_time += 60 - rtc_tm->tm_sec;
- rtc_time_to_tm(alm_time, rtc_tm);
+ rtc_time_to_tm_unsafe(alm_time, rtc_tm);
}
BUG_ON(rtc_tm->tm_sec); /* it will cause repeated irqs if not zero */
diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c
index 915d625..a1c3afe 100644
--- a/drivers/rtc/rtc-davinci.c
+++ b/drivers/rtc/rtc-davinci.c
@@ -438,7 +438,7 @@ static int davinci_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
rtc_tm_to_time_unsafe(&alm->time, &then);
if (then < now) {
- rtc_time_to_tm(now + 24 * 60 * 60, &tm);
+ rtc_time_to_tm_unsafe(now + 24 * 60 * 60, &tm);
alm->time.tm_mday = tm.tm_mday;
alm->time.tm_mon = tm.tm_mon;
alm->time.tm_year = tm.tm_year;
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index 6145ba9..aefcad9 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -321,7 +321,7 @@ static long rtc_dev_ioctl(struct file *file,
/* alarm may need to wrap into tomorrow */
if (then < now) {
- rtc_time_to_tm(now + 24 * 60 * 60, &tm);
+ rtc_time_to_tm_unsafe(now + 24 * 60 * 60, &tm);
alarm.time.tm_mday = tm.tm_mday;
alarm.time.tm_mon = tm.tm_mon;
alarm.time.tm_year = tm.tm_year;
diff --git a/drivers/rtc/rtc-dm355evm.c b/drivers/rtc/rtc-dm355evm.c
index b07d0ee..729f981 100644
--- a/drivers/rtc/rtc-dm355evm.c
+++ b/drivers/rtc/rtc-dm355evm.c
@@ -78,7 +78,7 @@ static int dm355evm_rtc_read_time(struct device *dev, struct rtc_time *tm)
dev_dbg(dev, "read timestamp %08x\n", time.value);
- rtc_time_to_tm(le32_to_cpu(time.value), tm);
+ rtc_time_to_tm_unsafe(le32_to_cpu(time.value), tm);
return 0;
}
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index 12e3b26..398a97e 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -148,7 +148,7 @@ static int ds1374_read_time(struct device *dev, struct rtc_time *time)
ret = ds1374_read_rtc(client, &itime, DS1374_REG_TOD0, 4);
if (!ret)
- rtc_time_to_tm(itime, time);
+ rtc_time_to_tm_unsafe(itime, time);
return ret;
}
@@ -195,7 +195,7 @@ static int ds1374_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
if (ret)
goto out;
- rtc_time_to_tm(now + cur_alarm, &alarm->time);
+ rtc_time_to_tm_unsafe(now + cur_alarm, &alarm->time);
alarm->enabled = !!(cr & DS1374_REG_CR_WACE);
alarm->pending = !!(sr & DS1374_REG_SR_AF);
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c
index b13d139..ed6116c 100644
--- a/drivers/rtc/rtc-ds1511.c
+++ b/drivers/rtc/rtc-ds1511.c
@@ -281,7 +281,7 @@ static int ds1511_rtc_read_time(struct device *dev, struct rtc_time *rtc_tm)
if (rtc_valid_tm(rtc_tm) < 0) {
dev_err(dev, "retrieved date/time is not valid.\n");
- rtc_time_to_tm(0, rtc_tm);
+ rtc_time_to_tm_unsafe(0, rtc_tm);
}
return 0;
}
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c
index ab56893..6e27f9d 100644
--- a/drivers/rtc/rtc-ds1553.c
+++ b/drivers/rtc/rtc-ds1553.c
@@ -131,7 +131,7 @@ static int ds1553_rtc_read_time(struct device *dev, struct rtc_time *tm)
if (rtc_valid_tm(tm) < 0) {
dev_err(dev, "retrieved date/time is not valid.\n");
- rtc_time_to_tm(0, tm);
+ rtc_time_to_tm_unsafe(0, tm);
}
return 0;
}
diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c
index a4888db..c03bbb3 100644
--- a/drivers/rtc/rtc-ds1672.c
+++ b/drivers/rtc/rtc-ds1672.c
@@ -62,7 +62,7 @@ static int ds1672_get_datetime(struct i2c_client *client, struct rtc_time *tm)
time = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
- rtc_time_to_tm(time, tm);
+ rtc_time_to_tm_unsafe(time, tm);
dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, "
"mday=%d, mon=%d, year=%d, wday=%d\n",
diff --git a/drivers/rtc/rtc-ds2404.c b/drivers/rtc/rtc-ds2404.c
index fc209dc..adf7804 100644
--- a/drivers/rtc/rtc-ds2404.c
+++ b/drivers/rtc/rtc-ds2404.c
@@ -206,7 +206,7 @@ static int ds2404_read_time(struct device *dev, struct rtc_time *dt)
ds2404_read_memory(dev, 0x203, 4, (u8 *)&time);
time = le32_to_cpu(time);
- rtc_time_to_tm(time, dt);
+ rtc_time_to_tm_unsafe(time, dt);
return rtc_valid_tm(dt);
}
diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c
index 5e4f5dc..68bd63a 100644
--- a/drivers/rtc/rtc-ep93xx.c
+++ b/drivers/rtc/rtc-ep93xx.c
@@ -65,7 +65,7 @@ static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm)
time = __raw_readl(ep93xx_rtc->mmio_base + EP93XX_RTC_DATA);
- rtc_time_to_tm(time, tm);
+ rtc_time_to_tm_unsafe(time, tm);
return 0;
}
diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index 53fc4bc..7dc501f 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -200,7 +200,7 @@ static int dryice_rtc_read_time(struct device *dev, struct rtc_time *tm)
unsigned long now;
now = __raw_readl(imxdi->ioaddr + DTCMR);
- rtc_time_to_tm(now, tm);
+ rtc_time_to_tm_unsafe(now, tm);
return 0;
}
@@ -245,7 +245,7 @@ static int dryice_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
u32 dcamr;
dcamr = __raw_readl(imxdi->ioaddr + DCAMR);
- rtc_time_to_tm(dcamr, &alarm->time);
+ rtc_time_to_tm_unsafe(dcamr, &alarm->time);
/* alarm is enabled if the interrupt is enabled */
alarm->enabled = (__raw_readl(imxdi->ioaddr + DIER) & DIER_CAIE) != 0;
diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c
index a1379cc..9f3b559 100644
--- a/drivers/rtc/rtc-jz4740.c
+++ b/drivers/rtc/rtc-jz4740.c
@@ -122,7 +122,7 @@ static int jz4740_rtc_read_time(struct device *dev, struct rtc_time *time)
if (timeout == 0)
return -EIO;
- rtc_time_to_tm(secs, time);
+ rtc_time_to_tm_unsafe(secs, time);
return rtc_valid_tm(time);
}
@@ -147,7 +147,7 @@ static int jz4740_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
alrm->enabled = !!(ctrl & JZ_RTC_CTRL_AE);
alrm->pending = !!(ctrl & JZ_RTC_CTRL_AF);
- rtc_time_to_tm(secs, &alrm->time);
+ rtc_time_to_tm_unsafe(secs, &alrm->time);
return rtc_valid_tm(&alrm->time);
}
diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c
index 829eef8..34bcca9 100644
--- a/drivers/rtc/rtc-lib.c
+++ b/drivers/rtc/rtc-lib.c
@@ -48,7 +48,7 @@ EXPORT_SYMBOL(rtc_year_days);
/*
* Convert seconds since 01-01-1970 00:00:00 to Gregorian date.
*/
-void rtc_time_to_tm(unsigned long time, struct rtc_time *tm)
+void rtc_time_to_tm_unsafe(unsigned long time, struct rtc_time *tm)
{
unsigned int month, year;
int days;
@@ -88,7 +88,7 @@ void rtc_time_to_tm(unsigned long time, struct rtc_time *tm)
tm->tm_isdst = 0;
}
-EXPORT_SYMBOL(rtc_time_to_tm);
+EXPORT_SYMBOL(rtc_time_to_tm_unsafe);
/*
* Does the rtc_time represent a valid date/time?
@@ -151,7 +151,7 @@ struct rtc_time rtc_ktime_to_tm(ktime_t kt)
/* Round up any ns */
if (ts.tv_nsec)
ts.tv_sec++;
- rtc_time_to_tm(ts.tv_sec, &ret);
+ rtc_time_to_tm_unsafe(ts.tv_sec, &ret);
return ret;
}
EXPORT_SYMBOL_GPL(rtc_ktime_to_tm);
diff --git a/drivers/rtc/rtc-lpc32xx.c b/drivers/rtc/rtc-lpc32xx.c
index da235f2..38c8ebe 100644
--- a/drivers/rtc/rtc-lpc32xx.c
+++ b/drivers/rtc/rtc-lpc32xx.c
@@ -68,7 +68,7 @@ static int lpc32xx_rtc_read_time(struct device *dev, struct rtc_time *time)
struct lpc32xx_rtc *rtc = dev_get_drvdata(dev);
elapsed_sec = rtc_readl(rtc, LPC32XX_RTC_UCOUNT);
- rtc_time_to_tm(elapsed_sec, time);
+ rtc_time_to_tm_unsafe(elapsed_sec, time);
return rtc_valid_tm(time);
}
@@ -97,7 +97,7 @@ static int lpc32xx_rtc_read_alarm(struct device *dev,
{
struct lpc32xx_rtc *rtc = dev_get_drvdata(dev);
- rtc_time_to_tm(rtc_readl(rtc, LPC32XX_RTC_MATCH0), &wkalrm->time);
+ rtc_time_to_tm_unsafe(rtc_readl(rtc, LPC32XX_RTC_MATCH0), &wkalrm->time);
wkalrm->enabled = rtc->alarm_enabled;
wkalrm->pending = !!(rtc_readl(rtc, LPC32XX_RTC_INTSTAT) &
LPC32XX_RTC_INTSTAT_MATCH0);
diff --git a/drivers/rtc/rtc-ls1x.c b/drivers/rtc/rtc-ls1x.c
index 04687c9..a9f6d08 100644
--- a/drivers/rtc/rtc-ls1x.c
+++ b/drivers/rtc/rtc-ls1x.c
@@ -96,7 +96,7 @@ static int ls1x_rtc_read_time(struct device *dev, struct rtc_time *rtm)
t = mktime_unsafe((t & LS1X_YEAR_MASK), ls1x_get_month(v),
ls1x_get_day(v), ls1x_get_hour(v),
ls1x_get_min(v), ls1x_get_sec(v));
- rtc_time_to_tm(t, rtm);
+ rtc_time_to_tm_unsafe(t, rtm);
return rtc_valid_tm(rtm);
}
diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c
index 78ec451..3c384dd 100644
--- a/drivers/rtc/rtc-mc13xxx.c
+++ b/drivers/rtc/rtc-mc13xxx.c
@@ -83,7 +83,7 @@ static int mc13xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
return ret;
} while (days1 != days2);
- rtc_time_to_tm(days1 * SEC_PER_DAY + seconds, tm);
+ rtc_time_to_tm_unsafe(days1 * SEC_PER_DAY + seconds, tm);
return rtc_valid_tm(tm);
}
@@ -191,7 +191,7 @@ out:
s1970 = days * SEC_PER_DAY + seconds;
- rtc_time_to_tm(s1970, &alarm->time);
+ rtc_time_to_tm_unsafe(s1970, &alarm->time);
dev_dbg(dev, "%s: %lu\n", __func__, s1970);
return 0;
diff --git a/drivers/rtc/rtc-mpc5121.c b/drivers/rtc/rtc-mpc5121.c
index 508a1ed..430d379 100644
--- a/drivers/rtc/rtc-mpc5121.c
+++ b/drivers/rtc/rtc-mpc5121.c
@@ -114,7 +114,7 @@ static int mpc5121_rtc_read_time(struct device *dev, struct rtc_time *tm)
*/
now = in_be32(®s->actual_time) + in_be32(®s->target_time);
- rtc_time_to_tm(now, tm);
+ rtc_time_to_tm_unsafe(now, tm);
/*
* update second minute hour registers
diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c
index 6aaec2f..c0e519b 100644
--- a/drivers/rtc/rtc-mv.c
+++ b/drivers/rtc/rtc-mv.c
@@ -126,7 +126,7 @@ static int mv_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
if (rtc_valid_tm(&alm->time) < 0) {
dev_err(dev, "retrieved alarm date/time is not valid.\n");
- rtc_time_to_tm(0, &alm->time);
+ rtc_time_to_tm_unsafe(0, &alm->time);
}
alm->enabled = !!readl(ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS);
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
index 7bc66ab..6c11775 100644
--- a/drivers/rtc/rtc-mxc.c
+++ b/drivers/rtc/rtc-mxc.c
@@ -182,7 +182,7 @@ static int rtc_update_alarm(struct device *dev, struct rtc_time *alrm)
void __iomem *ioaddr = pdata->ioaddr;
now = get_alarm_or_time(dev, MXC_RTC_TIME);
- rtc_time_to_tm(now, &now_tm);
+ rtc_time_to_tm_unsafe(now, &now_tm);
alarm_tm.tm_year = now_tm.tm_year;
alarm_tm.tm_mon = now_tm.tm_mon;
alarm_tm.tm_mday = now_tm.tm_mday;
@@ -290,7 +290,7 @@ static int mxc_rtc_read_time(struct device *dev, struct rtc_time *tm)
val = get_alarm_or_time(dev, MXC_RTC_TIME);
} while (val != get_alarm_or_time(dev, MXC_RTC_TIME));
- rtc_time_to_tm(val, tm);
+ rtc_time_to_tm_unsafe(val, tm);
return 0;
}
@@ -309,7 +309,7 @@ static int mxc_rtc_set_mmss(struct device *dev, unsigned long time)
if (is_imx1_rtc(pdata)) {
struct rtc_time tm;
- rtc_time_to_tm(time, &tm);
+ rtc_time_to_tm_unsafe(time, &tm);
tm.tm_year = 70;
rtc_tm_to_time_unsafe(&tm, &time);
}
@@ -333,7 +333,7 @@ static int mxc_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
void __iomem *ioaddr = pdata->ioaddr;
- rtc_time_to_tm(get_alarm_or_time(dev, MXC_RTC_ALARM), &alrm->time);
+ rtc_time_to_tm_unsafe(get_alarm_or_time(dev, MXC_RTC_ALARM), &alrm->time);
alrm->pending = ((readw(ioaddr + RTC_RTCISR) & RTC_ALM_BIT)) ? 1 : 0;
return 0;
diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c
index d8bfe37..162bc2d 100644
--- a/drivers/rtc/rtc-pcap.c
+++ b/drivers/rtc/rtc-pcap.c
@@ -56,7 +56,7 @@ static int pcap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, &days);
secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY;
- rtc_time_to_tm(secs, tm);
+ rtc_time_to_tm_unsafe(secs, tm);
return 0;
}
@@ -93,7 +93,7 @@ static int pcap_rtc_read_time(struct device *dev, struct rtc_time *tm)
ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAY, &days);
secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY;
- rtc_time_to_tm(secs, tm);
+ rtc_time_to_tm_unsafe(secs, tm);
return rtc_valid_tm(tm);
}
diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c
index 5c2c1c8..6a0f901 100644
--- a/drivers/rtc/rtc-pl030.c
+++ b/drivers/rtc/rtc-pl030.c
@@ -39,7 +39,7 @@ static int pl030_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct pl030_rtc *rtc = dev_get_drvdata(dev);
- rtc_time_to_tm(readl(rtc->base + RTC_MR), &alrm->time);
+ rtc_time_to_tm_unsafe(readl(rtc->base + RTC_MR), &alrm->time);
return 0;
}
@@ -64,7 +64,7 @@ static int pl030_read_time(struct device *dev, struct rtc_time *tm)
{
struct pl030_rtc *rtc = dev_get_drvdata(dev);
- rtc_time_to_tm(readl(rtc->base + RTC_DR), tm);
+ rtc_time_to_tm_unsafe(readl(rtc->base + RTC_DR), tm);
return 0;
}
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index 5a73252..b7f70aa 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -130,7 +130,7 @@ static int pl031_stv2_tm_to_time(struct device *dev,
struct rtc_time calc_tm;
rtc_tm_to_time_unsafe(tm, &time);
- rtc_time_to_tm(time, &calc_tm);
+ rtc_time_to_tm_unsafe(time, &calc_tm);
wday = calc_tm.tm_wday;
}
@@ -251,7 +251,7 @@ static int pl031_read_time(struct device *dev, struct rtc_time *tm)
{
struct pl031_local *ldata = dev_get_drvdata(dev);
- rtc_time_to_tm(readl(ldata->base + RTC_DR), tm);
+ rtc_time_to_tm_unsafe(readl(ldata->base + RTC_DR), tm);
return 0;
}
@@ -274,7 +274,7 @@ static int pl031_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{
struct pl031_local *ldata = dev_get_drvdata(dev);
- rtc_time_to_tm(readl(ldata->base + RTC_MR), &alarm->time);
+ rtc_time_to_tm_unsafe(readl(ldata->base + RTC_MR), &alarm->time);
alarm->pending = readl(ldata->base + RTC_RIS) & RTC_BIT_AI;
alarm->enabled = readl(ldata->base + RTC_IMSC) & RTC_BIT_AI;
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index 76d5b84..0bc746b 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -177,7 +177,7 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
secs = value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24);
- rtc_time_to_tm(secs, tm);
+ rtc_time_to_tm_unsafe(secs, tm);
rc = rtc_valid_tm(tm);
if (rc < 0) {
@@ -255,7 +255,7 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
secs = value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24);
- rtc_time_to_tm(secs, &alarm->time);
+ rtc_time_to_tm_unsafe(secs, &alarm->time);
rc = rtc_valid_tm(&alarm->time);
if (rc < 0) {
diff --git a/drivers/rtc/rtc-ps3.c b/drivers/rtc/rtc-ps3.c
index e6f3fe6..4de455e 100644
--- a/drivers/rtc/rtc-ps3.c
+++ b/drivers/rtc/rtc-ps3.c
@@ -40,7 +40,7 @@ static u64 read_rtc(void)
static int ps3_get_time(struct device *dev, struct rtc_time *tm)
{
- rtc_time_to_tm(read_rtc() + ps3_os_area_get_rtc_diff(), tm);
+ rtc_time_to_tm_unsafe(read_rtc() + ps3_os_area_get_rtc_diff(), tm);
return rtc_valid_tm(tm);
}
diff --git a/drivers/rtc/rtc-puv3.c b/drivers/rtc/rtc-puv3.c
index ae8b7e8..242e0cf 100644
--- a/drivers/rtc/rtc-puv3.c
+++ b/drivers/rtc/rtc-puv3.c
@@ -88,7 +88,7 @@ static int puv3_rtc_setpie(struct device *dev, int enabled)
/* Time read/write */
static int puv3_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm)
{
- rtc_time_to_tm(readl(RTC_RCNR), rtc_tm);
+ rtc_time_to_tm_unsafe(readl(RTC_RCNR), rtc_tm);
dev_dbg(dev, "read time %02x.%02x.%02x %02x/%02x/%02x\n",
rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday,
@@ -115,7 +115,7 @@ static int puv3_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct rtc_time *alm_tm = &alrm->time;
- rtc_time_to_tm(readl(RTC_RTAR), alm_tm);
+ rtc_time_to_tm_unsafe(readl(RTC_RTAR), alm_tm);
alrm->enabled = readl(RTC_RTSR) & RTC_RTSR_ALE;
diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c
index 090a101..091c8dd 100644
--- a/drivers/rtc/rtc-rs5c348.c
+++ b/drivers/rtc/rtc-rs5c348.c
@@ -139,7 +139,7 @@ rs5c348_rtc_read_time(struct device *dev, struct rtc_time *tm)
if (rtc_valid_tm(tm) < 0) {
dev_err(&spi->dev, "retrieved date/time is not valid.\n");
- rtc_time_to_tm(0, tm);
+ rtc_time_to_tm_unsafe(0, tm);
}
return 0;
@@ -186,7 +186,7 @@ static int rs5c348_probe(struct spi_device *spi)
dev_warn(&spi->dev, "voltage-low detected.\n");
if (ret & RS5C348_BIT_XSTP)
dev_warn(&spi->dev, "oscillator-stop detected.\n");
- rtc_time_to_tm(0, &tm); /* 1970/1/1 */
+ rtc_time_to_tm_unsafe(0, &tm); /* 1970/1/1 */
ret = rs5c348_rtc_set_time(&spi->dev, &tm);
if (ret < 0)
goto kfree_exit;
diff --git a/drivers/rtc/rtc-rx8025.c b/drivers/rtc/rtc-rx8025.c
index e6298e0..02ae3d1 100644
--- a/drivers/rtc/rtc-rx8025.c
+++ b/drivers/rtc/rtc-rx8025.c
@@ -567,7 +567,7 @@ static int rx8025_probe(struct i2c_client *client,
struct rtc_time tm;
dev_info(&client->dev,
"bad conditions detected, resetting date\n");
- rtc_time_to_tm(0, &tm); /* 1970/1/1 */
+ rtc_time_to_tm_unsafe(0, &tm); /* 1970/1/1 */
rx8025_set_time(&client->dev, &tm);
}
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index b736f1e..379df46 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -157,7 +157,7 @@ static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
- rtc_time_to_tm(RCNR, tm);
+ rtc_time_to_tm_unsafe(RCNR, tm);
return 0;
}
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index d0d2b04..edda8d7 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -719,7 +719,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev)
/* reset rtc to epoch 0 if time is invalid */
if (rtc_read_time(rtc->rtc_dev, &r) < 0) {
- rtc_time_to_tm(0, &r);
+ rtc_time_to_tm_unsafe(0, &r);
rtc_set_time(rtc->rtc_dev, &r);
}
diff --git a/drivers/rtc/rtc-sirfsoc.c b/drivers/rtc/rtc-sirfsoc.c
index 8579970..33dcd68 100644
--- a/drivers/rtc/rtc-sirfsoc.c
+++ b/drivers/rtc/rtc-sirfsoc.c
@@ -74,11 +74,11 @@ static int sirfsoc_rtc_read_alarm(struct device *dev,
*/
/* if alarm is in next overflow cycle */
if (rtc_count > rtc_alarm)
- rtc_time_to_tm((rtcdrv->overflow_rtc + 1)
+ rtc_time_to_tm_unsafe((rtcdrv->overflow_rtc + 1)
<< (BITS_PER_LONG - RTC_SHIFT)
| rtc_alarm >> RTC_SHIFT, &(alrm->time));
else
- rtc_time_to_tm(rtcdrv->overflow_rtc
+ rtc_time_to_tm_unsafe(rtcdrv->overflow_rtc
<< (BITS_PER_LONG - RTC_SHIFT)
| rtc_alarm >> RTC_SHIFT, &(alrm->time));
if (sirfsoc_rtc_iobrg_readl(
@@ -168,7 +168,7 @@ static int sirfsoc_rtc_read_time(struct device *dev,
cpu_relax();
} while (tmp_rtc != sirfsoc_rtc_iobrg_readl(rtcdrv->rtc_base + RTC_CN));
- rtc_time_to_tm(rtcdrv->overflow_rtc << (BITS_PER_LONG - RTC_SHIFT) |
+ rtc_time_to_tm_unsafe(rtcdrv->overflow_rtc << (BITS_PER_LONG - RTC_SHIFT) |
tmp_rtc >> RTC_SHIFT, tm);
return 0;
}
diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c
index 198377a..5d9fe5d 100644
--- a/drivers/rtc/rtc-snvs.c
+++ b/drivers/rtc/rtc-snvs.c
@@ -121,7 +121,7 @@ static int snvs_rtc_read_time(struct device *dev, struct rtc_time *tm)
struct snvs_rtc_data *data = dev_get_drvdata(dev);
unsigned long time = rtc_read_lp_counter(data->ioaddr);
- rtc_time_to_tm(time, tm);
+ rtc_time_to_tm_unsafe(time, tm);
return 0;
}
@@ -152,7 +152,7 @@ static int snvs_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
u32 lptar, lpsr;
lptar = readl(data->ioaddr + SNVS_LPTAR);
- rtc_time_to_tm(lptar, &alrm->time);
+ rtc_time_to_tm_unsafe(lptar, &alrm->time);
lpsr = readl(data->ioaddr + SNVS_LPSR);
alrm->pending = (lpsr & SNVS_LPSR_LPTA) ? 1 : 0;
diff --git a/drivers/rtc/rtc-starfire.c b/drivers/rtc/rtc-starfire.c
index f7d8a6d..bb8de2b 100644
--- a/drivers/rtc/rtc-starfire.c
+++ b/drivers/rtc/rtc-starfire.c
@@ -29,7 +29,7 @@ static u32 starfire_get_time(void)
static int starfire_read_time(struct device *dev, struct rtc_time *tm)
{
- rtc_time_to_tm(starfire_get_time(), tm);
+ rtc_time_to_tm_unsafe(starfire_get_time(), tm);
return rtc_valid_tm(tm);
}
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c
index 35ed49e..f915c89 100644
--- a/drivers/rtc/rtc-stk17ta8.c
+++ b/drivers/rtc/rtc-stk17ta8.c
@@ -133,7 +133,7 @@ static int stk17ta8_rtc_read_time(struct device *dev, struct rtc_time *tm)
if (rtc_valid_tm(tm) < 0) {
dev_err(dev, "retrieved date/time is not valid.\n");
- rtc_time_to_tm(0, tm);
+ rtc_time_to_tm_unsafe(0, tm);
}
return 0;
}
diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c
index f9a0c46..2aed30a 100644
--- a/drivers/rtc/rtc-stmp3xxx.c
+++ b/drivers/rtc/rtc-stmp3xxx.c
@@ -153,7 +153,7 @@ static int stmp3xxx_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm)
if (ret)
return ret;
- rtc_time_to_tm(readl(rtc_data->io + STMP3XXX_RTC_SECONDS), rtc_tm);
+ rtc_time_to_tm_unsafe(readl(rtc_data->io + STMP3XXX_RTC_SECONDS), rtc_tm);
return 0;
}
@@ -205,7 +205,7 @@ static int stmp3xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
{
struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev);
- rtc_time_to_tm(readl(rtc_data->io + STMP3XXX_RTC_ALARM), &alm->time);
+ rtc_time_to_tm_unsafe(readl(rtc_data->io + STMP3XXX_RTC_ALARM), &alm->time);
return 0;
}
diff --git a/drivers/rtc/rtc-sun4v.c b/drivers/rtc/rtc-sun4v.c
index ed041ed..5143c74 100644
--- a/drivers/rtc/rtc-sun4v.c
+++ b/drivers/rtc/rtc-sun4v.c
@@ -37,7 +37,7 @@ retry:
static int sun4v_read_time(struct device *dev, struct rtc_time *tm)
{
- rtc_time_to_tm(hypervisor_get_time(), tm);
+ rtc_time_to_tm_unsafe(hypervisor_get_time(), tm);
return 0;
}
diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
index c49c399..a71a48a 100644
--- a/drivers/rtc/rtc-sun6i.c
+++ b/drivers/rtc/rtc-sun6i.c
@@ -198,7 +198,7 @@ static int sun6i_rtc_getalarm(struct device *dev, struct rtc_wkalrm *wkalrm)
alrm_st = readl(chip->base + SUN6I_ALRM_IRQ_STA);
wkalrm->enabled = !!(alrm_en & SUN6I_ALRM_EN_CNT_EN);
wkalrm->pending = !!(alrm_st & SUN6I_ALRM_EN_CNT_EN);
- rtc_time_to_tm(chip->alarm, &wkalrm->time);
+ rtc_time_to_tm_unsafe(chip->alarm, &wkalrm->time);
return 0;
}
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index b9695f3..3a6749c7 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -216,7 +216,7 @@ rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr,
*/
alarm = now + 300;
}
- rtc_time_to_tm(alarm, &alm.time);
+ rtc_time_to_tm_unsafe(alarm, &alm.time);
retval = rtc_set_alarm(rtc, &alm);
return (retval < 0) ? retval : n;
diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c
index 409b4a0..ce4a49a 100644
--- a/drivers/rtc/rtc-tegra.c
+++ b/drivers/rtc/rtc-tegra.c
@@ -119,7 +119,7 @@ static int tegra_rtc_read_time(struct device *dev, struct rtc_time *tm)
spin_unlock_irqrestore(&info->tegra_rtc_lock, sl_irq_flags);
- rtc_time_to_tm(sec, tm);
+ rtc_time_to_tm_unsafe(sec, tm);
dev_vdbg(dev, "time read as %lu. %d/%d/%d %d:%02u:%02u\n",
sec,
@@ -188,7 +188,7 @@ static int tegra_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
} else {
/* alarm is enabled. */
alarm->enabled = 1;
- rtc_time_to_tm(sec, &alarm->time);
+ rtc_time_to_tm_unsafe(sec, &alarm->time);
}
tmp = readl(info->rtc_base + TEGRA_RTC_REG_INTR_STATUS);
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
index 6599c20..01b8441 100644
--- a/drivers/rtc/rtc-test.c
+++ b/drivers/rtc/rtc-test.c
@@ -30,7 +30,7 @@ static int test_rtc_set_alarm(struct device *dev,
static int test_rtc_read_time(struct device *dev,
struct rtc_time *tm)
{
- rtc_time_to_tm(get_seconds(), tm);
+ rtc_time_to_tm_unsafe(get_seconds(), tm);
return 0;
}
diff --git a/drivers/rtc/rtc-tps6586x.c b/drivers/rtc/rtc-tps6586x.c
index 341b000..c90e38e 100644
--- a/drivers/rtc/rtc-tps6586x.c
+++ b/drivers/rtc/rtc-tps6586x.c
@@ -89,7 +89,7 @@ static int tps6586x_rtc_read_time(struct device *dev, struct rtc_time *tm)
seconds = ticks >> 10;
seconds += rtc->epoch_start;
- rtc_time_to_tm(seconds, tm);
+ rtc_time_to_tm_unsafe(seconds, tm);
return rtc_valid_tm(tm);
}
@@ -227,7 +227,7 @@ static int tps6586x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
seconds = ticks >> 10;
seconds += rtc->epoch_start;
- rtc_time_to_tm(seconds, &alrm->time);
+ rtc_time_to_tm_unsafe(seconds, &alrm->time);
return 0;
}
diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c
index b3cf814..47a380a 100644
--- a/drivers/rtc/rtc-tx4939.c
+++ b/drivers/rtc/rtc-tx4939.c
@@ -87,7 +87,7 @@ static int tx4939_rtc_read_time(struct device *dev, struct rtc_time *tm)
buf[i] = __raw_readl(&rtcreg->dat);
spin_unlock_irq(&pdata->lock);
sec = (buf[5] << 24) | (buf[4] << 16) | (buf[3] << 8) | buf[2];
- rtc_time_to_tm(sec, tm);
+ rtc_time_to_tm_unsafe(sec, tm);
return rtc_valid_tm(tm);
}
@@ -148,7 +148,7 @@ static int tx4939_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
alrm->pending = (ctl & TX4939_RTCCTL_ALMD) ? 1 : 0;
spin_unlock_irq(&pdata->lock);
sec = (buf[5] << 24) | (buf[4] << 16) | (buf[3] << 8) | buf[2];
- rtc_time_to_tm(sec, &alrm->time);
+ rtc_time_to_tm_unsafe(sec, &alrm->time);
return rtc_valid_tm(&alrm->time);
}
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c
index a3d5772..9abeff7 100644
--- a/drivers/rtc/rtc-vr41xx.c
+++ b/drivers/rtc/rtc-vr41xx.c
@@ -143,7 +143,7 @@ static int vr41xx_rtc_read_time(struct device *dev, struct rtc_time *time)
epoch_sec = mktime_unsafe(epoch, 1, 1, 0, 0, 0);
elapsed_sec = read_elapsed_second();
- rtc_time_to_tm(epoch_sec + elapsed_sec, time);
+ rtc_time_to_tm_unsafe(epoch_sec + elapsed_sec, time);
return 0;
}
@@ -175,7 +175,7 @@ static int vr41xx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
spin_unlock_irq(&rtc_lock);
- rtc_time_to_tm((high << 17) | (mid << 1) | (low >> 15), time);
+ rtc_time_to_tm_unsafe((high << 17) | (mid << 1) | (low >> 15), time);
return 0;
}
diff --git a/drivers/rtc/rtc-wm831x.c b/drivers/rtc/rtc-wm831x.c
index 5d6a877..a0d3234 100644
--- a/drivers/rtc/rtc-wm831x.c
+++ b/drivers/rtc/rtc-wm831x.c
@@ -155,7 +155,7 @@ static int wm831x_rtc_readtime(struct device *dev, struct rtc_time *tm)
if (memcmp(time1, time2, sizeof(time1)) == 0) {
u32 time = (time1[0] << 16) | time1[1];
- rtc_time_to_tm(time, tm);
+ rtc_time_to_tm_unsafe(time, tm);
return rtc_valid_tm(tm);
}
@@ -249,7 +249,7 @@ static int wm831x_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
time = (data[0] << 16) | data[1];
- rtc_time_to_tm(time, &alrm->time);
+ rtc_time_to_tm_unsafe(time, &alrm->time);
ret = wm831x_reg_read(wm831x_rtc->wm831x, WM831X_RTC_CONTROL);
if (ret < 0) {
diff --git a/drivers/rtc/rtc-xgene.c b/drivers/rtc/rtc-xgene.c
index 2da0616..95b60b4 100644
--- a/drivers/rtc/rtc-xgene.c
+++ b/drivers/rtc/rtc-xgene.c
@@ -58,7 +58,7 @@ static int xgene_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
struct xgene_rtc_dev *pdata = dev_get_drvdata(dev);
- rtc_time_to_tm(readl(pdata->csr_base + RTC_CCVR), tm);
+ rtc_time_to_tm_unsafe(readl(pdata->csr_base + RTC_CCVR), tm);
return rtc_valid_tm(tm);
}
@@ -80,7 +80,7 @@ static int xgene_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct xgene_rtc_dev *pdata = dev_get_drvdata(dev);
- rtc_time_to_tm(pdata->alarm_time, &alrm->time);
+ rtc_time_to_tm_unsafe(pdata->alarm_time, &alrm->time);
alrm->enabled = readl(pdata->csr_base + RTC_CCR) & RTC_CCR_IE;
return 0;
diff --git a/drivers/rtc/systohc.c b/drivers/rtc/systohc.c
index bf3e242..f5796d3 100644
--- a/drivers/rtc/systohc.c
+++ b/drivers/rtc/systohc.c
@@ -27,9 +27,9 @@ int rtc_set_ntp_time(struct timespec now)
int err = -ENODEV;
if (now.tv_nsec < (NSEC_PER_SEC >> 1))
- rtc_time_to_tm(now.tv_sec, &tm);
+ rtc_time_to_tm_unsafe(now.tv_sec, &tm);
else
- rtc_time_to_tm(now.tv_sec + 1, &tm);
+ rtc_time_to_tm_unsafe(now.tv_sec + 1, &tm);
rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
if (rtc) {
diff --git a/drivers/staging/android/alarm-dev.c b/drivers/staging/android/alarm-dev.c
index ff4b3e8..3f95f80e 100644
--- a/drivers/staging/android/alarm-dev.c
+++ b/drivers/staging/android/alarm-dev.c
@@ -159,7 +159,7 @@ static int alarm_set_rtc(struct timespec *ts)
unsigned long flags;
int rv = 0;
- rtc_time_to_tm(ts->tv_sec, &new_rtc_tm);
+ rtc_time_to_tm_unsafe(ts->tv_sec, &new_rtc_tm);
rtc_dev = alarmtimer_get_rtcdev();
rv = do_settimeofday(ts);
if (rv < 0)
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index ffd22e9..d1f878c 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -21,7 +21,7 @@ extern int rtc_year_days(unsigned int day, unsigned int month, unsigned int year
extern int rtc_valid_tm(struct rtc_time *tm);
extern int rtc_tm_to_time(struct rtc_time *tm, time64_t *time);
extern int rtc_tm_to_time_unsafe(struct rtc_time *tm, unsigned long *time);
-extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm);
+extern void rtc_time_to_tm_unsafe(unsigned long time, struct rtc_time *tm);
ktime_t rtc_tm_to_ktime(struct rtc_time tm);
struct rtc_time rtc_ktime_to_tm(ktime_t kt);
diff --git a/kernel/power/suspend_test.c b/kernel/power/suspend_test.c
index f82b228..b6bc0e8 100644
--- a/kernel/power/suspend_test.c
+++ b/kernel/power/suspend_test.c
@@ -85,7 +85,7 @@ repeat:
rtc_tm_to_time_unsafe(&alm.time, &now);
memset(&alm, 0, sizeof alm);
- rtc_time_to_tm(now + TEST_SUSPEND_SECONDS, &alm.time);
+ rtc_time_to_tm_unsafe(now + TEST_SUSPEND_SECONDS, &alm.time);
alm.enabled = true;
status = rtc_set_alarm(rtc, &alm);
--
1.7.9.5
The kernel uses 32-bit signed value(time_t) for seconds since 1970-01-01:00:00:00, thus it
will overflow at 2038-01-19 03:14:08 on 32-bit systems. We call this "2038 safety" issue.
As part of addressing 2038 saftey for in-kernel uses, this patch adds the safe rtc_time_to_tm()
using time64_t. After this patch, rtc_time_to_tm_unsafe() should be replaced by rtc_time_to_tm()
one by one.
Eventually, rtc_time_to_tm_unsafe() will be removed from the kernel when it has no users.
Signed-off-by: pang.xunlei <[email protected]>
---
drivers/rtc/rtc-lib.c | 18 ++++++++++++++----
include/linux/rtc.h | 1 +
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c
index 34bcca9..cbbc9a6 100644
--- a/drivers/rtc/rtc-lib.c
+++ b/drivers/rtc/rtc-lib.c
@@ -48,12 +48,12 @@ EXPORT_SYMBOL(rtc_year_days);
/*
* Convert seconds since 01-01-1970 00:00:00 to Gregorian date.
*/
-void rtc_time_to_tm_unsafe(unsigned long time, struct rtc_time *tm)
+void rtc_time_to_tm(time64_t time, struct rtc_time *tm)
{
unsigned int month, year;
int days;
- days = time / 86400;
+ days = div_s64(time, 86400);
time -= (unsigned int) days * 86400;
/* day of the week, 1970-01-01 was a Thursday */
@@ -81,13 +81,23 @@ void rtc_time_to_tm_unsafe(unsigned long time, struct rtc_time *tm)
tm->tm_mon = month;
tm->tm_mday = days + 1;
- tm->tm_hour = time / 3600;
+ tm->tm_hour = div_s64(time, 3600);
time -= tm->tm_hour * 3600;
- tm->tm_min = time / 60;
+ tm->tm_min = div_s64(time, 60);
tm->tm_sec = time - tm->tm_min * 60;
tm->tm_isdst = 0;
}
+EXPORT_SYMBOL(rtc_time_to_tm);
+
+/* TODO: [2038 safety] unsafe for legacy, and should be replaced by rtc_time_to_tm() */
+void rtc_time_to_tm_unsafe(unsigned long time, struct rtc_time *tm)
+{
+ time64_t time64;
+
+ time64 = (time64_t)time;
+ rtc_time_to_tm(time64, tm);
+}
EXPORT_SYMBOL(rtc_time_to_tm_unsafe);
/*
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index d1f878c..1994399 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -21,6 +21,7 @@ extern int rtc_year_days(unsigned int day, unsigned int month, unsigned int year
extern int rtc_valid_tm(struct rtc_time *tm);
extern int rtc_tm_to_time(struct rtc_time *tm, time64_t *time);
extern int rtc_tm_to_time_unsafe(struct rtc_time *tm, unsigned long *time);
+extern void rtc_time_to_tm(time64_t time, struct rtc_time *tm);
extern void rtc_time_to_tm_unsafe(unsigned long time, struct rtc_time *tm);
ktime_t rtc_tm_to_ktime(struct rtc_time tm);
struct rtc_time rtc_ktime_to_tm(ktime_t kt);
--
1.7.9.5
The kernel uses 32-bit signed value(time_t) for seconds since 1970-01-01:00:00:00, so it
will overflow at 2038-01-19 03:14:08 on 32-bit systems. We call this "2038 safety" issue.
As part of addressing 2038 safety for in-kernel uses, convert do_settimeofday()
to use the timespec64 structure, and modify all users of do_settimeofday() to
provide timespec64 structures (via timespec_to_timespec64() as needed).
Signed-off-by: pang.xunlei <[email protected]>
---
arch/x86/xen/time.c | 10 ++++++++--
drivers/hv/hv_util.c | 4 ++--
drivers/rtc/hctosys.c | 4 +---
drivers/staging/android/alarm-dev.c | 8 +++++---
include/linux/timekeeping.h | 2 +-
kernel/compat.c | 4 +++-
kernel/time/time.c | 13 ++++++++++---
kernel/time/timekeeping.c | 15 +++++++--------
8 files changed, 37 insertions(+), 23 deletions(-)
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index a1d430b..cf1b591 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -486,6 +486,7 @@ static void __init xen_time_init(void)
{
int cpu = smp_processor_id();
struct timespec tp;
+ struct timespec64 tp64;
clocksource_register_hz(&xen_clocksource, NSEC_PER_SEC);
@@ -496,9 +497,14 @@ static void __init xen_time_init(void)
xen_clockevent = &xen_vcpuop_clockevent;
}
- /* Set initial system time with full resolution */
+ /*
+ * Set initial system time with full resolution.
+ * TODO: [2038 safety] xen_read_wallclock() should be changed to use
+ * timespec64 for 2038 safety as soon as possible.
+ */
xen_read_wallclock(&tp);
- do_settimeofday(&tp);
+ tp64 = timespec_to_timespec64(tp);
+ do_settimeofday(&tp64);
setup_force_cpu_cap(X86_FEATURE_TSC);
diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c
index 3b9c9ef..73b0962 100644
--- a/drivers/hv/hv_util.c
+++ b/drivers/hv/hv_util.c
@@ -166,10 +166,10 @@ static void shutdown_onchannelcallback(void *context)
static inline void do_adj_guesttime(u64 hosttime)
{
s64 host_tns;
- struct timespec host_ts;
+ struct timespec64 host_ts;
host_tns = (hosttime - WLTIMEDELTA) * 100;
- host_ts = ns_to_timespec(host_tns);
+ host_ts = ns_to_timespec64(host_tns);
do_settimeofday(&host_ts);
}
diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c
index c80723f..db71f47 100644
--- a/drivers/rtc/hctosys.c
+++ b/drivers/rtc/hctosys.c
@@ -29,7 +29,6 @@ static int __init rtc_hctosys(void)
struct timespec64 tv = {
.tv_nsec = NSEC_PER_SEC >> 1,
};
- struct timespec ts32;
struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
if (rtc == NULL) {
@@ -55,8 +54,7 @@ static int __init rtc_hctosys(void)
rtc_tm_to_time(&tm, &tv.tv_sec);
- ts32 = timespec64_to_timespec(tv);
- err = do_settimeofday(&ts32);
+ err = do_settimeofday(&tv);
dev_info(rtc->dev.parent,
"setting system clock to "
diff --git a/drivers/staging/android/alarm-dev.c b/drivers/staging/android/alarm-dev.c
index e2729c8..0385a38 100644
--- a/drivers/staging/android/alarm-dev.c
+++ b/drivers/staging/android/alarm-dev.c
@@ -154,7 +154,6 @@ static int alarm_wait(void)
static int alarm_set_rtc(struct timespec64 *ts)
{
- struct timespec ts32;
struct rtc_time new_rtc_tm;
struct rtc_device *rtc_dev;
unsigned long flags;
@@ -162,8 +161,7 @@ static int alarm_set_rtc(struct timespec64 *ts)
rtc_time_to_tm(ts->tv_sec, &new_rtc_tm);
rtc_dev = alarmtimer_get_rtcdev();
- ts32 = timespec64_to_timespec(*ts);
- rv = do_settimeofday(&ts32);
+ rv = do_settimeofday(ts);
if (rv < 0)
return rv;
if (rtc_dev)
@@ -200,6 +198,10 @@ static int alarm_get_time(enum android_alarm_type alarm_type,
return rv;
}
+/*
+ * TODO: [2038 safety] alarm_do_ioctl() should be fixed to use timespec64,
+ * once timespec64 is promoted to userspace.
+ */
static long alarm_do_ioctl(struct file *file, unsigned int cmd,
struct timespec *ts)
{
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 64c9c77..6cb9a77 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -10,7 +10,7 @@ extern int timekeeping_suspended;
* Get and set timeofday
*/
extern void do_gettimeofday(struct timeval *tv);
-extern int do_settimeofday(const struct timespec *tv);
+extern int do_settimeofday(const struct timespec64 *ts);
extern int do_sys_settimeofday(const struct timespec *tv,
const struct timezone *tz);
diff --git a/kernel/compat.c b/kernel/compat.c
index ebb3c36..4362578 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -1047,6 +1047,7 @@ COMPAT_SYSCALL_DEFINE1(time, compat_time_t __user *, tloc)
COMPAT_SYSCALL_DEFINE1(stime, compat_time_t __user *, tptr)
{
struct timespec tv;
+ struct timespec64 tv64;
int err;
if (get_user(tv.tv_sec, tptr))
@@ -1058,7 +1059,8 @@ COMPAT_SYSCALL_DEFINE1(stime, compat_time_t __user *, tptr)
if (err)
return err;
- do_settimeofday(&tv);
+ tv64 = timespec_to_timespec64(tv);
+ do_settimeofday(&tv64);
return 0;
}
diff --git a/kernel/time/time.c b/kernel/time/time.c
index f9521fa..d85fda9 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -82,6 +82,7 @@ SYSCALL_DEFINE1(time, time_t __user *, tloc)
SYSCALL_DEFINE1(stime, time_t __user *, tptr)
{
struct timespec tv;
+ struct timespec64 tv64;
int err;
if (get_user(tv.tv_sec, tptr))
@@ -93,7 +94,8 @@ SYSCALL_DEFINE1(stime, time_t __user *, tptr)
if (err)
return err;
- do_settimeofday(&tv);
+ tv64 = timespec_to_timespec64(tv);
+ do_settimeofday(&tv64);
return 0;
}
@@ -162,6 +164,7 @@ static inline void warp_clock(void)
int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
{
+ struct timespec64 tv64;
static int firsttime = 1;
int error = 0;
@@ -181,8 +184,12 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
warp_clock();
}
}
- if (tv)
- return do_settimeofday(tv);
+
+ if (tv) {
+ tv64 = timespec_to_timespec64(*tv);
+ return do_settimeofday(&tv64);
+ }
+
return 0;
}
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index b58e7cf..fd03819 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -704,17 +704,17 @@ EXPORT_SYMBOL(do_gettimeofday);
/**
* do_settimeofday - Sets the time of day
- * @tv: pointer to the timespec variable containing the new time
+ * @ts: pointer to the timespec64 variable containing the new time
*
* Sets the time of day to the new time and update NTP and notify hrtimers
*/
-int do_settimeofday(const struct timespec *tv)
+int do_settimeofday(const struct timespec64 *ts)
{
struct timekeeper *tk = &tk_core.timekeeper;
- struct timespec64 ts_delta, xt, tmp;
+ struct timespec64 ts_delta, xt;
unsigned long flags;
- if (!timespec_valid_strict(tv))
+ if (!timespec64_valid_strict(ts))
return -EINVAL;
raw_spin_lock_irqsave(&timekeeper_lock, flags);
@@ -723,13 +723,12 @@ int do_settimeofday(const struct timespec *tv)
timekeeping_forward_now(tk);
xt = tk_xtime(tk);
- ts_delta.tv_sec = tv->tv_sec - xt.tv_sec;
- ts_delta.tv_nsec = tv->tv_nsec - xt.tv_nsec;
+ ts_delta.tv_sec = ts->tv_sec - xt.tv_sec;
+ ts_delta.tv_nsec = ts->tv_nsec - xt.tv_nsec;
tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, ts_delta));
- tmp = timespec_to_timespec64(*tv);
- tk_set_xtime(tk, &tmp);
+ tk_set_xtime(tk, ts);
timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET);
--
1.7.9.5
The kernel uses 32-bit signed value(time_t) for seconds since 1970-01-01:00:00:00, so it
will overflow at 2038-01-19 03:14:08 on 32-bit systems. We call this "2038 safety" issue.
As part of addressing 2038 safety for in-kernel uses, this patch creates no functional change
in existing users, converts xen_read_wallclock() to use timespec64 instead of timespec.
Signed-off-by: pang.xunlei <[email protected]>
---
arch/x86/xen/time.c | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index cf1b591..2ce064a 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -169,20 +169,33 @@ static cycle_t xen_clocksource_get_cycles(struct clocksource *cs)
return xen_clocksource_read();
}
-static void xen_read_wallclock(struct timespec *ts)
+static void xen_read_wallclock(struct timespec64 *ts)
{
+ struct timespec ts32;
struct shared_info *s = HYPERVISOR_shared_info;
struct pvclock_wall_clock *wall_clock = &(s->wc);
struct pvclock_vcpu_time_info *vcpu_time;
vcpu_time = &get_cpu_var(xen_vcpu)->time;
- pvclock_read_wallclock(wall_clock, vcpu_time, ts);
+ /*
+ * TODO: [2038 safety] pvclock_read_wallclock() should be changed
+ * to use timespec64 for 2038 safety as soon as possible.
+ */
+ pvclock_read_wallclock(wall_clock, vcpu_time, &ts32);
+ *ts = timespec_to_timespec64(ts32);
put_cpu_var(xen_vcpu);
}
+/*
+ * TODO: [2038 safety] xen_get_wallclock() should be changed to use
+ * timespec64 for 2038 safety as soon as possible.
+ */
static void xen_get_wallclock(struct timespec *now)
{
- xen_read_wallclock(now);
+ struct timespec64 now64;
+
+ xen_read_wallclock(&now64);
+ *now = timespec64_to_timespec(now64);
}
static int xen_set_wallclock(const struct timespec *now)
@@ -485,8 +498,7 @@ static const struct pv_time_ops xen_time_ops __initconst = {
static void __init xen_time_init(void)
{
int cpu = smp_processor_id();
- struct timespec tp;
- struct timespec64 tp64;
+ struct timespec64 tp;
clocksource_register_hz(&xen_clocksource, NSEC_PER_SEC);
@@ -497,14 +509,9 @@ static void __init xen_time_init(void)
xen_clockevent = &xen_vcpuop_clockevent;
}
- /*
- * Set initial system time with full resolution.
- * TODO: [2038 safety] xen_read_wallclock() should be changed to use
- * timespec64 for 2038 safety as soon as possible.
- */
+ /* Set initial system time with full resolution. */
xen_read_wallclock(&tp);
- tp64 = timespec_to_timespec64(tp);
- do_settimeofday(&tp64);
+ do_settimeofday(&tp);
setup_force_cpu_cap(X86_FEATURE_TSC);
--
1.7.9.5
The kernel uses 32-bit signed value(time_t) for seconds since 1970-01-01:00:00:00, so it
will overflow at 2038-01-19 03:14:08 on 32-bit systems. We call this "2038 safety" issue.
As part of addressing 2038 safety for in-kernel uses, this patch creates no functional change
in existing users, converts pvclock_read_wallclock() to use timespec64 instead of timespec.
Signed-off-by: pang.xunlei <[email protected]>
---
arch/x86/include/asm/pvclock.h | 2 +-
arch/x86/kernel/kvmclock.c | 7 +++++--
arch/x86/kernel/pvclock.c | 8 ++++----
arch/x86/xen/time.c | 10 ++--------
4 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h
index d6b078e..3323413 100644
--- a/arch/x86/include/asm/pvclock.h
+++ b/arch/x86/include/asm/pvclock.h
@@ -11,7 +11,7 @@ void pvclock_set_flags(u8 flags);
unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src);
void pvclock_read_wallclock(struct pvclock_wall_clock *wall,
struct pvclock_vcpu_time_info *vcpu,
- struct timespec *ts);
+ struct timespec64 *ts);
void pvclock_resume(void);
void pvclock_touch_watchdogs(void);
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index d9156ce..7cd3511 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -46,10 +46,12 @@ static struct pvclock_wall_clock wall_clock;
/*
* The wallclock is the time of day when we booted. Since then, some time may
* have elapsed since the hypervisor wrote the data. So we try to account for
- * that with system time
+ * that with system time.
+ * TODO: [2038 safety] kvm_get_wallclock() should be fixed to use timespec64.
*/
static void kvm_get_wallclock(struct timespec *now)
{
+ struct timespec64 now64;
struct pvclock_vcpu_time_info *vcpu_time;
int low, high;
int cpu;
@@ -63,7 +65,8 @@ static void kvm_get_wallclock(struct timespec *now)
cpu = smp_processor_id();
vcpu_time = &hv_clock[cpu].pvti;
- pvclock_read_wallclock(&wall_clock, vcpu_time, now);
+ pvclock_read_wallclock(&wall_clock, vcpu_time, &now64);
+ *now = timespec64_to_timespec(now64);
preempt_enable();
}
diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
index 2f355d2..ae3ae07 100644
--- a/arch/x86/kernel/pvclock.c
+++ b/arch/x86/kernel/pvclock.c
@@ -117,17 +117,17 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
void pvclock_read_wallclock(struct pvclock_wall_clock *wall_clock,
struct pvclock_vcpu_time_info *vcpu_time,
- struct timespec *ts)
+ struct timespec64 *ts)
{
u32 version;
u64 delta;
- struct timespec now;
+ struct timespec64 now;
/* get wallclock at system boot */
do {
version = wall_clock->version;
rmb(); /* fetch version before time */
- now.tv_sec = wall_clock->sec;
+ now.tv_sec = (time64_t)wall_clock->sec; /* TODO: [2038 safety] wall_clock->sec uses time64_t */
now.tv_nsec = wall_clock->nsec;
rmb(); /* fetch time before checking version */
} while ((wall_clock->version & 1) || (version != wall_clock->version));
@@ -138,7 +138,7 @@ void pvclock_read_wallclock(struct pvclock_wall_clock *wall_clock,
now.tv_nsec = do_div(delta, NSEC_PER_SEC);
now.tv_sec = delta;
- set_normalized_timespec(ts, now.tv_sec, now.tv_nsec);
+ set_normalized_timespec64(ts, now.tv_sec, now.tv_nsec);
}
#ifdef CONFIG_X86_64
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 2ce064a..97dd201 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -171,18 +171,12 @@ static cycle_t xen_clocksource_get_cycles(struct clocksource *cs)
static void xen_read_wallclock(struct timespec64 *ts)
{
- struct timespec ts32;
struct shared_info *s = HYPERVISOR_shared_info;
struct pvclock_wall_clock *wall_clock = &(s->wc);
- struct pvclock_vcpu_time_info *vcpu_time;
+ struct pvclock_vcpu_time_info *vcpu_time;
vcpu_time = &get_cpu_var(xen_vcpu)->time;
- /*
- * TODO: [2038 safety] pvclock_read_wallclock() should be changed
- * to use timespec64 for 2038 safety as soon as possible.
- */
- pvclock_read_wallclock(wall_clock, vcpu_time, &ts32);
- *ts = timespec_to_timespec64(ts32);
+ pvclock_read_wallclock(wall_clock, vcpu_time, ts);
put_cpu_var(xen_vcpu);
}
--
1.7.9.5
The kernel uses 32-bit signed value(time_t) for seconds since 1970-01-01:00:00:00, so it
will overflow at 2038-01-19 03:14:08 on 32-bit systems. We call this "2038 safety" issue.
As part of addressing 2038 saftey for in-kernel uses, this patch creates no functional change
in existing users, and converts rtc_time_to_tm_unsafe() to rtc_time_to_tm().
Signed-off-by: pang.xunlei <[email protected]>
---
drivers/staging/android/alarm-dev.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/android/alarm-dev.c b/drivers/staging/android/alarm-dev.c
index 3f95f80e..e2729c8 100644
--- a/drivers/staging/android/alarm-dev.c
+++ b/drivers/staging/android/alarm-dev.c
@@ -152,16 +152,18 @@ static int alarm_wait(void)
return rv;
}
-static int alarm_set_rtc(struct timespec *ts)
+static int alarm_set_rtc(struct timespec64 *ts)
{
+ struct timespec ts32;
struct rtc_time new_rtc_tm;
struct rtc_device *rtc_dev;
unsigned long flags;
int rv = 0;
- rtc_time_to_tm_unsafe(ts->tv_sec, &new_rtc_tm);
+ rtc_time_to_tm(ts->tv_sec, &new_rtc_tm);
rtc_dev = alarmtimer_get_rtcdev();
- rv = do_settimeofday(ts);
+ ts32 = timespec64_to_timespec(*ts);
+ rv = do_settimeofday(&ts32);
if (rv < 0)
return rv;
if (rtc_dev)
@@ -201,6 +203,7 @@ static int alarm_get_time(enum android_alarm_type alarm_type,
static long alarm_do_ioctl(struct file *file, unsigned int cmd,
struct timespec *ts)
{
+ struct timespec64 ts64;
int rv = 0;
unsigned long flags;
enum android_alarm_type alarm_type = ANDROID_ALARM_IOCTL_TO_TYPE(cmd);
@@ -238,7 +241,8 @@ static long alarm_do_ioctl(struct file *file, unsigned int cmd,
rv = alarm_wait();
break;
case ANDROID_ALARM_SET_RTC:
- rv = alarm_set_rtc(ts);
+ ts64 = timespec_to_timespec64(*ts);
+ rv = alarm_set_rtc(&ts64);
break;
case ANDROID_ALARM_GET_TIME(0):
rv = alarm_get_time(alarm_type, ts);
--
1.7.9.5
The kernel uses 32-bit signed value(time_t) for seconds since 1970-01-01:00:00:00, so it
will overflow at 2038-01-19 03:14:08 on 32-bit systems. We call this "2038 safety" issue.
This patch fixed the build warnings brought by former patches.
Signed-off-by: pang.xunlei <[email protected]>
---
include/linux/time64.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/time64.h b/include/linux/time64.h
index a383147..02f2c87 100644
--- a/include/linux/time64.h
+++ b/include/linux/time64.h
@@ -3,15 +3,15 @@
#include <uapi/linux/time.h>
-typedef __s64 time64_t;
-
/*
* This wants to go into uapi/linux/time.h once we agreed about the
* userspace interfaces.
*/
#if __BITS_PER_LONG == 64
-# define timespec64 timespec
+typedef __kernel_time_t time64_t;
+#define timespec64 timespec
#else
+typedef __s64 time64_t;
struct timespec64 {
time64_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
--
1.7.9.5
The kernel uses 32-bit signed value(time_t) for seconds since 1970-01-01:00:00:00, thus it
will overflow at 2038-01-19 03:14:08 on 32-bit systems. We call this "2038 safety" issue.
As part of addressing 2038 saftey for in-kernel uses, this patch adds the safe rtc_tm_to_time()
using time64_t. After this patch, rtc_tm_to_time_unsafe() should be replaced by rtc_tm_to_time()
one by one.
Eventually, rtc_tm_to_time_unsafe() will be removed from the kernel when it has no users.
Signed-off-by: pang.xunlei <[email protected]>
---
drivers/rtc/rtc-lib.c | 9 +++++++++
include/linux/rtc.h | 1 +
2 files changed, 10 insertions(+)
diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c
index 168d2a2..829eef8 100644
--- a/drivers/rtc/rtc-lib.c
+++ b/drivers/rtc/rtc-lib.c
@@ -111,6 +111,15 @@ EXPORT_SYMBOL(rtc_valid_tm);
/*
* Convert Gregorian date to seconds since 01-01-1970 00:00:00.
*/
+int rtc_tm_to_time(struct rtc_time *tm, time64_t *time)
+{
+ *time = mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
+ return 0;
+}
+EXPORT_SYMBOL(rtc_tm_to_time);
+
+/* TODO: [2038 safety] unsafe for legacy, and should be replaced by rtc_tm_to_time() */
int rtc_tm_to_time_unsafe(struct rtc_time *tm, unsigned long *time)
{
*time = (unsigned long) mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index 97bbb6f..ffd22e9 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -19,6 +19,7 @@
extern int rtc_month_days(unsigned int month, unsigned int year);
extern int rtc_year_days(unsigned int day, unsigned int month, unsigned int year);
extern int rtc_valid_tm(struct rtc_time *tm);
+extern int rtc_tm_to_time(struct rtc_time *tm, time64_t *time);
extern int rtc_tm_to_time_unsafe(struct rtc_time *tm, unsigned long *time);
extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm);
ktime_t rtc_tm_to_ktime(struct rtc_time tm);
--
1.7.9.5
On Mon, 27 Oct 2014, pang.xunlei wrote:
> The kernel uses 32-bit signed value(time_t) for seconds since 1970-01-01:00:00:00, so it
> will overflow at 2038-01-19 03:14:08 on 32-bit systems. We call this "2038 safety" issue.
>
> This patch fixed the build warnings brought by former patches.
If we know that the previous patch introduced the warning and that
patch has not yet been committed to any immutable git tree then we fix
it in that very patch and not after the fact.
Thanks,
tglx
On Mon, 27 Oct 2014, pang.xunlei wrote:
> The kernel uses 32-bit signed value(time_t) for seconds since 1970-01-01:00:00:00, so it
> will overflow at 2038-01-19 03:14:08 on 32-bit systems. We call this "2038 safety" issue.
We really know that by now. No need to repeat that for every patch.
> As part of addressing 2038 saftey for in-kernel uses, this patch creates no functional change
> in existing users, and converts rtc_tm_to_time_unsafe() to rtc_tm_to_time() in rtc_hctosys().
Please line break your changelogs properly. That's how it should look
like:
> As part of addressing 2038 saftey for in-kernel uses, this patch
> creates no functional change in existing users, and converts
> rtc_tm_to_time_unsafe() to rtc_tm_to_time() in rtc_hctosys().
Can you spot the difference?
> @@ -26,9 +26,10 @@ static int __init rtc_hctosys(void)
> {
> int err = -ENODEV;
> struct rtc_time tm;
> - struct timespec tv = {
> + struct timespec64 tv = {
> .tv_nsec = NSEC_PER_SEC >> 1,
> };
> + struct timespec ts32;
So this is exactly why I dislike this whole flag day conversion
thing. If you add
rtc_tm_to_time64()
do_settimeofday64()
in the first place, you can convert the whole function in one go
without introducing intermediate variables which then need to be
undone later again.
Thanks,
tglx
On Mon, 27 Oct 2014, Thomas Gleixner wrote:
> On Mon, 27 Oct 2014, pang.xunlei wrote:
> > The kernel uses 32-bit signed value(time_t) for seconds since 1970-01-01:00:00:00, so it
> > will overflow at 2038-01-19 03:14:08 on 32-bit systems. We call this "2038 safety" issue.
>
> We really know that by now. No need to repeat that for every patch.
>
> > As part of addressing 2038 saftey for in-kernel uses, this patch creates no functional change
> > in existing users, and converts rtc_tm_to_time_unsafe() to rtc_tm_to_time() in rtc_hctosys().
>
> Please line break your changelogs properly. That's how it should look
> like:
>
> > As part of addressing 2038 saftey for in-kernel uses, this patch
> > creates no functional change in existing users, and converts
> > rtc_tm_to_time_unsafe() to rtc_tm_to_time() in rtc_hctosys().
>
> Can you spot the difference?
>
> > @@ -26,9 +26,10 @@ static int __init rtc_hctosys(void)
> > {
> > int err = -ENODEV;
> > struct rtc_time tm;
> > - struct timespec tv = {
> > + struct timespec64 tv = {
> > .tv_nsec = NSEC_PER_SEC >> 1,
> > };
> > + struct timespec ts32;
>
> So this is exactly why I dislike this whole flag day conversion
> thing. If you add
>
> rtc_tm_to_time64()
> do_settimeofday64()
>
> in the first place, you can convert the whole function in one go
> without introducing intermediate variables which then need to be
> undone later again.
Aside of that ts32 is a complete misnomer because on 64 bit struct
timespec already has a 64bit seconds representation.
Thanks,
tglx
On 27 October 2014 23:35, Stefano Stabellini
<[email protected]> wrote:
> On Mon, 27 Oct 2014, pang.xunlei wrote:
>> The kernel uses 32-bit signed value(time_t) for seconds since 1970-01-01:00:00:00, so it
>> will overflow at 2038-01-19 03:14:08 on 32-bit systems. We call this "2038 safety" issue.
>>
>> As part of addressing 2038 safety for in-kernel uses, this patch creates no functional change
>> in existing users, converts xen_read_wallclock() to use timespec64 instead of timespec.
>>
>> Signed-off-by: pang.xunlei <[email protected]>
>
> Please CC [email protected] for Xen related patches.
Ok, apologies for missing this.
>
>
>> arch/x86/xen/time.c | 31 +++++++++++++++++++------------
>> 1 file changed, 19 insertions(+), 12 deletions(-)
>>
>> diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
>> index cf1b591..2ce064a 100644
>> --- a/arch/x86/xen/time.c
>> +++ b/arch/x86/xen/time.c
>> @@ -169,20 +169,33 @@ static cycle_t xen_clocksource_get_cycles(struct clocksource *cs)
>> return xen_clocksource_read();
>> }
>>
>> -static void xen_read_wallclock(struct timespec *ts)
>> +static void xen_read_wallclock(struct timespec64 *ts)
>> {
>> + struct timespec ts32;
>> struct shared_info *s = HYPERVISOR_shared_info;
>> struct pvclock_wall_clock *wall_clock = &(s->wc);
>> struct pvclock_vcpu_time_info *vcpu_time;
>>
>> vcpu_time = &get_cpu_var(xen_vcpu)->time;
>> - pvclock_read_wallclock(wall_clock, vcpu_time, ts);
>> + /*
>> + * TODO: [2038 safety] pvclock_read_wallclock() should be changed
>> + * to use timespec64 for 2038 safety as soon as possible.
>> + */
>> + pvclock_read_wallclock(wall_clock, vcpu_time, &ts32);
>> + *ts = timespec_to_timespec64(ts32);
>> put_cpu_var(xen_vcpu);
>> }
>>
>> +/*
>> + * TODO: [2038 safety] xen_get_wallclock() should be changed to use
>> + * timespec64 for 2038 safety as soon as possible.
>> + */
>> static void xen_get_wallclock(struct timespec *now)
>
> At this point shouldn't you convert xen_get_wallclock to timespec64 too?
This conversion is in the following patches. I'll send the version 2 tomorrow
which will demonstrate this in the first subset.
>
>
>> {
>> - xen_read_wallclock(now);
>> + struct timespec64 now64;
>> +
>> + xen_read_wallclock(&now64);
>> + *now = timespec64_to_timespec(now64);
>> }
>>
>> static int xen_set_wallclock(const struct timespec *now)
>> @@ -485,8 +498,7 @@ static const struct pv_time_ops xen_time_ops __initconst = {
>> static void __init xen_time_init(void)
>> {
>> int cpu = smp_processor_id();
>> - struct timespec tp;
>> - struct timespec64 tp64;
>> + struct timespec64 tp;
>>
>> clocksource_register_hz(&xen_clocksource, NSEC_PER_SEC);
>>
>> @@ -497,14 +509,9 @@ static void __init xen_time_init(void)
>> xen_clockevent = &xen_vcpuop_clockevent;
>> }
>>
>> - /*
>> - * Set initial system time with full resolution.
>> - * TODO: [2038 safety] xen_read_wallclock() should be changed to use
>> - * timespec64 for 2038 safety as soon as possible.
>> - */
>> + /* Set initial system time with full resolution. */
>> xen_read_wallclock(&tp);
>> - tp64 = timespec_to_timespec64(tp);
>> - do_settimeofday(&tp64);
>> + do_settimeofday(&tp);
>>
>> setup_force_cpu_cap(X86_FEATURE_TSC);
>>
>> --
>> 1.7.9.5
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at http://secure-web.cisco.com/1R3n2I8-gDpn8akesS4B4JN0A1SlyiiKzIT0qgddW4Xm1xtBi5J7nJwhRaPMEkp0VmrMyOlBD5Lz9VdewgeobSUsSzhREJQNT2O0l1LUhfiaNzD2_oHWGA6fP4sD1KCgFB00xHD6jw1ggEqe03cpaKsGQmA-TwOpFD41O8IIqhwY/http%3A%2F%2Fwww.tux.org%2Flkml%2F
>>