Commit 5548cbf7 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Alexandre Belloni

rtc: Switch to use %ptR

Use %ptR instead of open coded variant to print content of
struct rtc_time in human readable format.

Note, we drop the validation option. This is only used in
a deprecated ABI and is mostly wrong as many RTCs will still be valid
after 2100.

Cc: Arnd Bergmann <arnd@arndb.de>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
parent 4d42c447
...@@ -1125,11 +1125,10 @@ static int rtc_proc_show(struct seq_file *seq, void *v) ...@@ -1125,11 +1125,10 @@ static int rtc_proc_show(struct seq_file *seq, void *v)
* time or for Universal Standard Time (GMT). Probably local though. * time or for Universal Standard Time (GMT). Probably local though.
*/ */
seq_printf(seq, seq_printf(seq,
"rtc_time\t: %02d:%02d:%02d\n" "rtc_time\t: %ptRt\n"
"rtc_date\t: %04d-%02d-%02d\n" "rtc_date\t: %ptRd\n"
"rtc_epoch\t: %04lu\n", "rtc_epoch\t: %04lu\n",
tm.tm_hour, tm.tm_min, tm.tm_sec, &tm, &tm, epoch);
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, epoch);
get_rtc_alm_time(&tm); get_rtc_alm_time(&tm);
......
...@@ -56,12 +56,8 @@ static int __init rtc_hctosys(void) ...@@ -56,12 +56,8 @@ static int __init rtc_hctosys(void)
err = do_settimeofday64(&tv64); err = do_settimeofday64(&tv64);
dev_info(rtc->dev.parent, dev_info(rtc->dev.parent, "setting system clock to %ptR UTC (%lld)\n",
"setting system clock to " &tm, (long long)tv64.tv_sec);
"%d-%02d-%02d %02d:%02d:%02d UTC (%lld)\n",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec,
(long long) tv64.tv_sec);
err_read: err_read:
rtc_class_close(rtc); rtc_class_close(rtc);
......
...@@ -368,12 +368,8 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) ...@@ -368,12 +368,8 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
err = rtc_valid_tm(&alarm->time); err = rtc_valid_tm(&alarm->time);
done: done:
if (err) { if (err)
dev_warn(&rtc->dev, "invalid alarm value: %d-%d-%d %d:%d:%d\n", dev_warn(&rtc->dev, "invalid alarm value: %ptR\n", &alarm->time);
alarm->time.tm_year + 1900, alarm->time.tm_mon + 1,
alarm->time.tm_mday, alarm->time.tm_hour, alarm->time.tm_min,
alarm->time.tm_sec);
}
return err; return err;
} }
......
...@@ -50,41 +50,15 @@ static int rtc_proc_show(struct seq_file *seq, void *offset) ...@@ -50,41 +50,15 @@ static int rtc_proc_show(struct seq_file *seq, void *offset)
err = rtc_read_time(rtc, &tm); err = rtc_read_time(rtc, &tm);
if (err == 0) { if (err == 0) {
seq_printf(seq, seq_printf(seq,
"rtc_time\t: %02d:%02d:%02d\n" "rtc_time\t: %ptRt\n"
"rtc_date\t: %04d-%02d-%02d\n", "rtc_date\t: %ptRd\n",
tm.tm_hour, tm.tm_min, tm.tm_sec, &tm, &tm);
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
} }
err = rtc_read_alarm(rtc, &alrm); err = rtc_read_alarm(rtc, &alrm);
if (err == 0) { if (err == 0) {
seq_printf(seq, "alrm_time\t: "); seq_printf(seq, "alrm_time\t: %ptRt\n", &alrm.time);
if ((unsigned int)alrm.time.tm_hour <= 24) seq_printf(seq, "alrm_date\t: %ptRd\n", &alrm.time);
seq_printf(seq, "%02d:", alrm.time.tm_hour);
else
seq_printf(seq, "**:");
if ((unsigned int)alrm.time.tm_min <= 59)
seq_printf(seq, "%02d:", alrm.time.tm_min);
else
seq_printf(seq, "**:");
if ((unsigned int)alrm.time.tm_sec <= 59)
seq_printf(seq, "%02d\n", alrm.time.tm_sec);
else
seq_printf(seq, "**\n");
seq_printf(seq, "alrm_date\t: ");
if ((unsigned int)alrm.time.tm_year <= 200)
seq_printf(seq, "%04d-", alrm.time.tm_year + 1900);
else
seq_printf(seq, "****-");
if ((unsigned int)alrm.time.tm_mon <= 11)
seq_printf(seq, "%02d-", alrm.time.tm_mon + 1);
else
seq_printf(seq, "**-");
if (alrm.time.tm_mday && (unsigned int)alrm.time.tm_mday <= 31)
seq_printf(seq, "%02d\n", alrm.time.tm_mday);
else
seq_printf(seq, "**\n");
seq_printf(seq, "alarm_IRQ\t: %s\n", seq_printf(seq, "alarm_IRQ\t: %s\n",
alrm.enabled ? "yes" : "no"); alrm.enabled ? "yes" : "no");
seq_printf(seq, "alrm_pending\t: %s\n", seq_printf(seq, "alrm_pending\t: %s\n",
......
...@@ -39,12 +39,10 @@ date_show(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -39,12 +39,10 @@ date_show(struct device *dev, struct device_attribute *attr, char *buf)
struct rtc_time tm; struct rtc_time tm;
retval = rtc_read_time(to_rtc_device(dev), &tm); retval = rtc_read_time(to_rtc_device(dev), &tm);
if (retval == 0) { if (retval)
retval = sprintf(buf, "%04d-%02d-%02d\n", return retval;
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
}
return retval; return sprintf(buf, "%ptRd\n", &tm);
} }
static DEVICE_ATTR_RO(date); static DEVICE_ATTR_RO(date);
...@@ -55,12 +53,10 @@ time_show(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -55,12 +53,10 @@ time_show(struct device *dev, struct device_attribute *attr, char *buf)
struct rtc_time tm; struct rtc_time tm;
retval = rtc_read_time(to_rtc_device(dev), &tm); retval = rtc_read_time(to_rtc_device(dev), &tm);
if (retval == 0) { if (retval)
retval = sprintf(buf, "%02d:%02d:%02d\n", return retval;
tm.tm_hour, tm.tm_min, tm.tm_sec);
}
return retval; return sprintf(buf, "%ptRt\n", &tm);
} }
static DEVICE_ATTR_RO(time); static DEVICE_ATTR_RO(time);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment