All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv]
@ 2018-02-20 21:43 Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt Andy Shevchenko
                   ` (20 more replies)
  0 siblings, 21 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko

At some point I have noticed too many users of struct rtc_time that
printing its content field by field.

In this series I introduce %ptR[dt][rv] specifier to make life a bit
easier.

There are still users of detailed output of the struct rtc_time, but we
can introduce an additional extension for them in the future if needed,
otherwise they might be converted to the proposed output format.

Some of the changes slightly modify the output. In those cases we are on
the safe side since they are pure debug. Nevertheless I tried to leave
numbers to be the same or quite close: in some cases year is printed +
1900, though month is left in the range [0,11] instead of [1,12].

I didn't compile everything there, though I did a basic smoke test on
some x86 hardware. So, I rely on kbuild test robot as well :-)

Most of the users currently are RTC drivers, thus the patch series is
assumed to go via RTC tree.

The patch series depends on earlier send clean up of lib/vsprintf [1].

[1]: https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1612716.html

Changelog v2:
- split out lib/vsprintf changes to separate series
- build it optionally depending on introduced PRINTK_PEXT_TIMEDATE
- for now support only struct rtc_time
- make an additional letter for different time representations
- make above letter capital to reduce confusion on %ptr vs. %ptR
- drop kdb patch since it's a candidate for time64_t support

Andy Shevchenko (21):
  lib/vsprintf: Print time and date in human readable format via %pt
  rtc: Switch to use %ptR
  rtc: at91rm9200: Switch to use %ptR
  rtc: at91sam9: Switch to use %ptR
  rtc: m41t80: Switch to use %ptR
  rtc: m48t59: Switch to use %ptR
  rtc: mcp795: Switch to use %ptR
  rtc: pcf50633: Switch to use %ptR
  rtc: pic32: Switch to use %ptR
  rtc: pm8xxx: Switch to use %ptR
  rtc: puv3: Switch to use %ptR
  rtc: rk808: Switch to use %ptR
  rtc: rx6110: Switch to use %ptR
  rtc: rx8025: Switch to use %ptR
  rtc: s3c: Switch to use %ptR
  rtc: s5m: Switch to use %ptR
  rtc: tegra: Switch to use %ptR
  ds1302: Switch to use %ptR
  Input: hp_sdc_rtc - Switch to use %ptR
  mk68/mac: Switch to use %ptR
  PM: Switch to use %ptR

 Documentation/core-api/printk-formats.rst |  31 +++++++
 arch/m68k/Kconfig.machine                 |   1 +
 arch/m68k/mac/misc.c                      |   8 +-
 drivers/base/power/trace.c                |   4 +-
 drivers/char/Kconfig                      |   2 +
 drivers/char/ds1302.c                     |  39 +++-----
 drivers/char/rtc.c                        |   7 +-
 drivers/input/misc/Kconfig                |   1 +
 drivers/input/misc/hp_sdc_rtc.c           |   8 +-
 drivers/rtc/Kconfig                       |   1 +
 drivers/rtc/hctosys.c                     |   8 +-
 drivers/rtc/interface.c                   |   8 +-
 drivers/rtc/rtc-at91rm9200.c              |  15 +---
 drivers/rtc/rtc-at91sam9.c                |  16 +---
 drivers/rtc/rtc-m41t80.c                  |   6 +-
 drivers/rtc/rtc-m48t59.c                  |   8 +-
 drivers/rtc/rtc-mcp795.c                  |  18 ++--
 drivers/rtc/rtc-pcf50633.c                |   8 +-
 drivers/rtc/rtc-pic32.c                   |  18 +---
 drivers/rtc/rtc-pm8xxx.c                  |  16 ++--
 drivers/rtc/rtc-proc.c                    |  36 ++------
 drivers/rtc/rtc-puv3.c                    |  18 +---
 drivers/rtc/rtc-rk808.c                   |  20 ++---
 drivers/rtc/rtc-rx6110.c                  |  12 +--
 drivers/rtc/rtc-rx8025.c                  |  19 +---
 drivers/rtc/rtc-s3c.c                     |  21 ++---
 drivers/rtc/rtc-s5m.c                     |  27 ++----
 drivers/rtc/rtc-sysfs.c                   |  12 +--
 drivers/rtc/rtc-tegra.c                   |  30 +------
 kernel/power/Kconfig                      |   1 +
 lib/Kconfig                               |   8 ++
 lib/test_printf.c                         |   6 ++
 lib/vsprintf.c                            | 145 ++++++++++++++++++++++++++++++
 33 files changed, 287 insertions(+), 291 deletions(-)

-- 
2.15.1

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 23:55     ` Joe Perches
  2018-02-21  9:33   ` Geert Uytterhoeven
  2018-02-20 21:43 ` [PATCH v2 02/21] rtc: Switch to use %ptR Andy Shevchenko
                   ` (19 subsequent siblings)
  20 siblings, 2 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko, Bartlomiej Zolnierkiewicz, Dmitry Torokhov,
	Geert Uytterhoeven, Guan Xuetao, Ingo Molnar, Jason Wessel,
	Jonathan Corbet, Jonathan Hunter, Krzysztof Kozlowski,
	Rafael J. Wysocki, Thierry Reding

There are users which print time and date represented by content of
struct rtc_time in human readable format.

Instead of open coding that each time introduce %ptR[dt][rv] specifier.

Note, users have to select PRINTK_PEXT_TIMEDATE option in a Kconfig.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 Documentation/core-api/printk-formats.rst |  31 +++++++
 lib/Kconfig                               |   8 ++
 lib/test_printf.c                         |   6 ++
 lib/vsprintf.c                            | 145 ++++++++++++++++++++++++++++++
 4 files changed, 190 insertions(+)

diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
index 934559b3c130..9aaf0858ddd4 100644
--- a/Documentation/core-api/printk-formats.rst
+++ b/Documentation/core-api/printk-formats.rst
@@ -412,6 +412,37 @@ Examples::
 
 Passed by reference.
 
+Time and date
+-------------
+
+::
+
+	%pt[R]		YYYY-mm-dd HH:MM:SS
+	%pt[R]d		YYYY-mm-dd
+	%pt[R]t		HH:MM:SS
+	%pt[R][dt]
+
+  R for struct rtc_time
+
+Note, users have to select PRINTK_PEXT_TIMEDATE option in a Kconfig.
+
+struct rtc_time
+~~~~~~~~~~~~~~~
+
+::
+
+	%ptR[dt][rv]
+
+For printing date and time as represented by struct rtc_time structure in
+human readable format.
+
+By default year will be incremented by 1900 and month by 1. Use %ptRr (raw)
+to suppress this behaviour. On the other hand when %ptRv is applied
+validation mechanism will be in use, i.e. numbers out of range will be
+replaced by ** or ****.
+
+Passed by reference.
+
 struct clk
 ----------
 
diff --git a/lib/Kconfig b/lib/Kconfig
index e96089499371..e48cb7ba7beb 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -605,3 +605,11 @@ config GENERIC_CMPDI2
 
 config GENERIC_UCMPDI2
 	bool
+
+#
+# %p optional extensions for vsnprintf().
+# Should be selected by users.
+#
+
+config PRINTK_PEXT_TIMEDATE
+	bool
diff --git a/lib/test_printf.c b/lib/test_printf.c
index cea592f402ed..54f8960ea531 100644
--- a/lib/test_printf.c
+++ b/lib/test_printf.c
@@ -398,6 +398,11 @@ struct_va_format(void)
 {
 }
 
+static void __init
+struct_rtc_time(void)
+{
+}
+
 static void __init
 struct_clk(void)
 {
@@ -509,6 +514,7 @@ test_pointer(void)
 	uuid();
 	dentry();
 	struct_va_format();
+	struct_rtc_time();
 	struct_clk();
 	bitmap();
 	netdev_features();
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 28d7aca6a805..90ea28aefc26 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -30,6 +30,7 @@
 #include <linux/ioport.h>
 #include <linux/dcache.h>
 #include <linux/cred.h>
+#include <linux/rtc.h>
 #include <linux/uuid.h>
 #include <linux/of.h>
 #include <net/addrconf.h>
@@ -709,6 +710,20 @@ static const struct printf_spec default_dec_spec = {
 	.precision = -1,
 };
 
+static const struct printf_spec default_dec02_spec = {
+	.base = 10,
+	.field_width = 2,
+	.precision = -1,
+	.flags = ZEROPAD,
+};
+
+static const struct printf_spec default_dec04_spec = {
+	.base = 10,
+	.field_width = 4,
+	.precision = -1,
+	.flags = ZEROPAD,
+};
+
 static noinline_for_stack
 char *resource_string(char *buf, char *end, struct resource *res,
 		      struct printf_spec spec, const char *fmt)
@@ -1443,6 +1458,132 @@ char *address_val(char *buf, char *end, const void *addr, const char *fmt)
 	return special_hex_number(buf, end, num, size);
 }
 
+static noinline_for_stack
+char *date_str(char *buf, char *end, const struct rtc_time *tm, bool v, bool r)
+{
+	int year = tm->tm_year + (r ? 0 : 1900);
+	int mon = tm->tm_mon + (r ? 0 : 1);
+
+	if (unlikely(v && (unsigned int)tm->tm_year > 200))
+		buf = string(buf, end, "****", default_str_spec);
+	else
+		buf = number(buf, end, year, default_dec04_spec);
+
+	if (buf < end)
+		*buf = '-';
+	buf++;
+
+	if (unlikely(v && (unsigned int)tm->tm_mon > 11))
+		buf = string(buf, end, "**", default_str_spec);
+	else
+		buf = number(buf, end, mon, default_dec02_spec);
+
+	if (buf < end)
+		*buf = '-';
+	buf++;
+
+	if (unlikely(v && (unsigned int)tm->tm_mday > 31))
+		buf = string(buf, end, "**", default_str_spec);
+	else
+		buf = number(buf, end, tm->tm_mday, default_dec02_spec);
+
+	return buf;
+}
+
+static noinline_for_stack
+char *time_str(char *buf, char *end, const struct rtc_time *tm, bool v, bool r)
+{
+	if (unlikely(v && (unsigned int)tm->tm_hour > 24))
+		buf = string(buf, end, "**", default_str_spec);
+	else
+		buf = number(buf, end, tm->tm_hour, default_dec02_spec);
+
+	if (buf < end)
+		*buf = ':';
+	buf++;
+
+	if (unlikely(v && (unsigned int)tm->tm_min > 59))
+		buf = string(buf, end, "**", default_str_spec);
+	else
+		buf = number(buf, end, tm->tm_min, default_dec02_spec);
+
+	if (buf < end)
+		*buf = ':';
+	buf++;
+
+	if (unlikely(v && (unsigned int)tm->tm_sec > 59))
+		buf = string(buf, end, "**", default_str_spec);
+	else
+		buf = number(buf, end, tm->tm_sec, default_dec02_spec);
+
+	return buf;
+}
+
+static noinline_for_stack
+char *rtc_str(char *buf, char *end, const struct rtc_time *tm, const char *fmt)
+{
+	bool have_t = true, have_d = true;
+	bool validate = false;
+	bool raw = false;
+	int count = 1;
+	bool found;
+
+	switch (fmt[++count]) {
+	case 'd':
+		have_t = false;
+		break;
+	case 't':
+		have_d = false;
+		break;
+	}
+
+	/* No %pt[dt] supplied */
+	if (have_d && have_t)
+		--count;
+
+	found = true;
+	do {
+		switch (fmt[++count]) {
+		case 'r':
+			raw = true;
+			break;
+		case 'v':
+			validate = true;
+			break;
+		default:
+			found = false;
+			break;
+		}
+	} while (found);
+
+	if (have_d)
+		buf = date_str(buf, end, tm, validate, raw);
+	if (have_d && have_t) {
+		if (buf < end)
+			*buf = ' ';
+		buf++;
+	}
+	if (have_t)
+		buf = time_str(buf, end, tm, validate, raw);
+
+	return buf;
+}
+
+static noinline_for_stack
+char *timeanddate(char *buf, char *end, void *ptr, const char *fmt)
+{
+	if (!IS_ENABLED(CONFIG_PRINTK_PEXT_TIMEDATE))
+		return string(buf, end, NULL, default_str_spec);
+
+	switch (fmt[1]) {
+	case 'R':
+		return rtc_str(buf, end, (const struct rtc_time *)ptr, fmt);
+	default:
+		break;
+	}
+	return special_hex_number(buf, end, (unsigned long)ptr, sizeof(void *));
+}
+
 static noinline_for_stack
 char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
 	    const char *fmt)
@@ -1776,6 +1917,8 @@ static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec)
  * - 'd[234]' For a dentry name (optionally 2-4 last components)
  * - 'D[234]' Same as 'd' but for a struct file
  * - 'g' For block_device name (gendisk + partition number)
+ * - 't[R][dt][rv]' For time and date as represented:
+ *      R    struct rtc_time
  * - 'C' For a clock, it prints the name (Common Clock Framework) or address
  *       (legacy clock framework) of the clock
  * - 'Cn' For a clock, it prints the name (Common Clock Framework) or address
@@ -1906,6 +2049,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
 		return address_val(buf, end, ptr, fmt);
 	case 'd':
 		return dentry_name(buf, end, ptr, spec, fmt);
+	case 't':
+		return timeanddate(buf, end, ptr, fmt);
 	case 'C':
 		return clock(buf, end, ptr, spec, fmt);
 	case 'D':
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 02/21] rtc: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 03/21] rtc: at91rm9200: " Andy Shevchenko
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko

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

Cc: Arnd Bergmann <arnd@arndb.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/char/Kconfig    |  1 +
 drivers/char/rtc.c      |  7 +++----
 drivers/rtc/Kconfig     |  1 +
 drivers/rtc/hctosys.c   |  8 ++------
 drivers/rtc/interface.c |  8 ++------
 drivers/rtc/rtc-proc.c  | 36 +++++-------------------------------
 drivers/rtc/rtc-sysfs.c | 12 ++++--------
 7 files changed, 18 insertions(+), 55 deletions(-)

diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index c28dca0c613d..c96e00ebeae9 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -297,6 +297,7 @@ if RTC_LIB=n
 config RTC
 	tristate "Enhanced Real Time Clock Support (legacy PC RTC driver)"
 	depends on ALPHA || (MIPS && MACH_LOONGSON64)
+	select PRINTK_PEXT_TIMEDATE
 	---help---
 	  If you say Y here and create a character special file /dev/rtc with
 	  major number 10 and minor number 135 using mknod ("man mknod"), you
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index 57dc546628b5..379023328a6f 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -1148,11 +1148,10 @@ static int rtc_proc_show(struct seq_file *seq, void *v)
 	 * time or for Universal Standard Time (GMT). Probably local though.
 	 */
 	seq_printf(seq,
-		   "rtc_time\t: %02d:%02d:%02d\n"
-		   "rtc_date\t: %04d-%02d-%02d\n"
+		   "rtc_time\t: %ptRt\n"
+		   "rtc_date\t: %ptRd\n"
 		   "rtc_epoch\t: %04lu\n",
-		   tm.tm_hour, tm.tm_min, tm.tm_sec,
-		   tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, epoch);
+		   &tm, &tm, epoch);
 
 	get_rtc_alm_time(&tm);
 
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index f6d7e490e714..da9e49e7c30e 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -4,6 +4,7 @@
 
 config RTC_LIB
 	bool
+	select PRINTK_PEXT_TIMEDATE
 
 config RTC_MC146818_LIB
 	bool
diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c
index e1cfa06810ef..9989109781b8 100644
--- a/drivers/rtc/hctosys.c
+++ b/drivers/rtc/hctosys.c
@@ -51,12 +51,8 @@ static int __init rtc_hctosys(void)
 
 	err = do_settimeofday64(&tv64);
 
-	dev_info(rtc->dev.parent,
-		"setting system clock to "
-		"%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);
+	dev_info(rtc->dev.parent, "setting system clock to %ptR UTC (%lld)\n",
+		 &tm, (long long)tv64.tv_sec);
 
 err_read:
 	rtc_class_close(rtc);
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 7e253be19ba7..ea4afe3893f2 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -297,12 +297,8 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
 	err = rtc_valid_tm(&alarm->time);
 
 done:
-	if (err) {
-		dev_warn(&rtc->dev, "invalid alarm value: %d-%d-%d %d:%d:%d\n",
-			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);
-	}
+	if (err)
+		dev_warn(&rtc->dev, "invalid alarm value: %ptR\n", &alarm->time);
 
 	return err;
 }
diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c
index 31e7e23cc5be..2aed9a0042d8 100644
--- a/drivers/rtc/rtc-proc.c
+++ b/drivers/rtc/rtc-proc.c
@@ -50,41 +50,15 @@ static int rtc_proc_show(struct seq_file *seq, void *offset)
 	err = rtc_read_time(rtc, &tm);
 	if (err == 0) {
 		seq_printf(seq,
-			"rtc_time\t: %02d:%02d:%02d\n"
-			"rtc_date\t: %04d-%02d-%02d\n",
-			tm.tm_hour, tm.tm_min, tm.tm_sec,
-			tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
+				"rtc_time\t: %ptRt\n"
+				"rtc_date\t: %ptRd\n",
+				&tm, &tm);
 	}
 
 	err = rtc_read_alarm(rtc, &alrm);
 	if (err == 0) {
-		seq_printf(seq, "alrm_time\t: ");
-		if ((unsigned int)alrm.time.tm_hour <= 24)
-			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, "alrm_time\t: %ptRtv\n", &alrm.time);
+		seq_printf(seq, "alrm_date\t: %ptRdv\n", &alrm.time);
 		seq_printf(seq, "alarm_IRQ\t: %s\n",
 				alrm.enabled ? "yes" : "no");
 		seq_printf(seq, "alrm_pending\t: %s\n",
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index 92ff2edb86a6..0b96926a98e4 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -39,10 +39,8 @@ date_show(struct device *dev, struct device_attribute *attr, char *buf)
 	struct rtc_time tm;
 
 	retval = rtc_read_time(to_rtc_device(dev), &tm);
-	if (retval == 0) {
-		retval = sprintf(buf, "%04d-%02d-%02d\n",
-			tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
-	}
+	if (retval == 0)
+		retval = sprintf(buf, "%ptRd\n", &tm);
 
 	return retval;
 }
@@ -55,10 +53,8 @@ time_show(struct device *dev, struct device_attribute *attr, char *buf)
 	struct rtc_time tm;
 
 	retval = rtc_read_time(to_rtc_device(dev), &tm);
-	if (retval == 0) {
-		retval = sprintf(buf, "%02d:%02d:%02d\n",
-			tm.tm_hour, tm.tm_min, tm.tm_sec);
-	}
+	if (retval == 0)
+		retval = sprintf(buf, "%ptRt\n", &tm);
 
 	return retval;
 }
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 03/21] rtc: at91rm9200: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 02/21] rtc: Switch to use %ptR Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 04/21] rtc: at91sam9: " Andy Shevchenko
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/rtc/rtc-at91rm9200.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
index de81ecedd571..debffb9f7574 100644
--- a/drivers/rtc/rtc-at91rm9200.c
+++ b/drivers/rtc/rtc-at91rm9200.c
@@ -147,9 +147,7 @@ static int at91_rtc_readtime(struct device *dev, struct rtc_time *tm)
 	tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year);
 	tm->tm_year = tm->tm_year - 1900;
 
-	dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
-		1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
-		tm->tm_hour, tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "%s(): %ptR\n", __func__, tm);
 
 	return 0;
 }
@@ -161,9 +159,7 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm)
 {
 	unsigned long cr;
 
-	dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
-		1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
-		tm->tm_hour, tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "%s(): %ptR\n", __func__, tm);
 
 	wait_for_completion(&at91_rtc_upd_rdy);
 
@@ -209,8 +205,7 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
 	alrm->enabled = (at91_rtc_read_imr() & AT91_RTC_ALARM)
 			? 1 : 0;
 
-	dev_dbg(dev, "%s(): %02d-%02d %02d:%02d:%02d %sabled\n", __func__,
-		tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec,
+	dev_dbg(dev, "%s(): %ptR %sabled\n", __func__, tm,
 		alrm->enabled ? "en" : "dis");
 
 	return 0;
@@ -247,9 +242,7 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
 		at91_rtc_write_ier(AT91_RTC_ALARM);
 	}
 
-	dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
-		tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour,
-		tm.tm_min, tm.tm_sec);
+	dev_dbg(dev, "%s(): %ptR\n", __func__, &tm);
 
 	return 0;
 }
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 04/21] rtc: at91sam9: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (2 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 03/21] rtc: at91rm9200: " Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 05/21] rtc: m41t80: " Andy Shevchenko
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/rtc/rtc-at91sam9.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
index 7418a763ce52..8d8994f79619 100644
--- a/drivers/rtc/rtc-at91sam9.c
+++ b/drivers/rtc/rtc-at91sam9.c
@@ -124,9 +124,7 @@ static int at91_rtc_readtime(struct device *dev, struct rtc_time *tm)
 
 	rtc_time_to_tm(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,
-		tm->tm_hour, tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "%s: %ptR\n", __func__, tm);
 
 	return 0;
 }
@@ -141,9 +139,7 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm)
 	u32 offset, alarm, mr;
 	unsigned long secs;
 
-	dev_dbg(dev, "%s: %4d-%02d-%02d %02d:%02d:%02d\n", "settime",
-		1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
-		tm->tm_hour, tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "%s: %ptR\n", __func__, tm);
 
 	err = rtc_tm_to_time(tm, &secs);
 	if (err != 0)
@@ -199,9 +195,7 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
 	if (alarm != ALARM_DISABLED && offset != 0) {
 		rtc_time_to_tm(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,
-			tm->tm_hour, tm->tm_min, tm->tm_sec);
+		dev_dbg(dev, "%s: %ptR\n", __func__, tm);
 
 		if (rtt_readl(rtc, MR) & AT91_RTT_ALMIEN)
 			alrm->enabled = 1;
@@ -242,9 +236,7 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
 	if (alrm->enabled)
 		rtt_writel(rtc, MR, mr | AT91_RTT_ALMIEN);
 
-	dev_dbg(dev, "%s: %4d-%02d-%02d %02d:%02d:%02d\n", "setalarm",
-		tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour,
-		tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "%s: %ptR\n", __func__, tm);
 
 	return 0;
 }
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 05/21] rtc: m41t80: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (3 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 04/21] rtc: at91sam9: " Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 06/21] rtc: m48t59: " Andy Shevchenko
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/rtc/rtc-m41t80.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index c90fba3ed861..0ffc03826efb 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -950,11 +950,7 @@ static int m41t80_probe(struct i2c_client *client,
 		if (m41t80_data->features & M41T80_FEATURE_HT) {
 			m41t80_get_datetime(client, &tm);
 			dev_info(&client->dev, "HT bit was set!\n");
-			dev_info(&client->dev,
-				 "Power Down at %04i-%02i-%02i %02i:%02i:%02i\n",
-				 tm.tm_year + 1900,
-				 tm.tm_mon + 1, tm.tm_mday, tm.tm_hour,
-				 tm.tm_min, tm.tm_sec);
+			dev_info(&client->dev, "Power Down at %ptR\n", &tm);
 		}
 		rc = i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_HOUR,
 					       rc & ~M41T80_ALHOUR_HT);
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 06/21] rtc: m48t59: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (4 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 05/21] rtc: m41t80: " Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 07/21] rtc: mcp795: " Andy Shevchenko
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/rtc/rtc-m48t59.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
index 399fc4255d54..67ba7cb2bbe4 100644
--- a/drivers/rtc/rtc-m48t59.c
+++ b/drivers/rtc/rtc-m48t59.c
@@ -102,9 +102,7 @@ static int m48t59_rtc_read_time(struct device *dev, struct rtc_time *tm)
 	M48T59_CLEAR_BITS(M48T59_CNTL_READ, M48T59_CNTL);
 	spin_unlock_irqrestore(&m48t59->lock, flags);
 
-	dev_dbg(dev, "RTC read time %04d-%02d-%02d %02d/%02d/%02d\n",
-		tm->tm_year + 1900, tm->tm_mon, tm->tm_mday,
-		tm->tm_hour, tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "RTC read time %ptR\n", tm);
 	return rtc_valid_tm(tm);
 }
 
@@ -193,9 +191,7 @@ static int m48t59_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
 	M48T59_CLEAR_BITS(M48T59_CNTL_READ, M48T59_CNTL);
 	spin_unlock_irqrestore(&m48t59->lock, flags);
 
-	dev_dbg(dev, "RTC read alarm time %04d-%02d-%02d %02d/%02d/%02d\n",
-		tm->tm_year + 1900, tm->tm_mon, tm->tm_mday,
-		tm->tm_hour, tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "RTC read alarm time %ptR\n", tm);
 	return rtc_valid_tm(tm);
 }
 
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 07/21] rtc: mcp795: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (5 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 06/21] rtc: m48t59: " Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 08/21] rtc: pcf50633: " Andy Shevchenko
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/rtc/rtc-mcp795.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/rtc/rtc-mcp795.c b/drivers/rtc/rtc-mcp795.c
index 77f21331ae21..fad71527e417 100644
--- a/drivers/rtc/rtc-mcp795.c
+++ b/drivers/rtc/rtc-mcp795.c
@@ -233,9 +233,7 @@ static int mcp795_set_time(struct device *dev, struct rtc_time *tim)
 	if (ret)
 		return ret;
 
-	dev_dbg(dev, "Set mcp795: %04d-%02d-%02d(%d) %02d:%02d:%02d\n",
-			tim->tm_year + 1900, tim->tm_mon, tim->tm_mday,
-			tim->tm_wday, tim->tm_hour, tim->tm_min, tim->tm_sec);
+	dev_dbg(dev, "Set mcp795: %ptR\n", tim);
 
 	return 0;
 }
@@ -258,9 +256,7 @@ static int mcp795_read_time(struct device *dev, struct rtc_time *tim)
 	tim->tm_mon	= bcd2bin(data[5] & 0x1F) - 1;
 	tim->tm_year	= bcd2bin(data[6]) + 100; /* Assume we are in 20xx */
 
-	dev_dbg(dev, "Read from mcp795: %04d-%02d-%02d(%d) %02d:%02d:%02d\n",
-			tim->tm_year + 1900, tim->tm_mon, tim->tm_mday,
-			tim->tm_wday, tim->tm_hour, tim->tm_min, tim->tm_sec);
+	dev_dbg(dev, "Read from mcp795: %ptR\n", tim);
 
 	return rtc_valid_tm(tim);
 }
@@ -319,9 +315,8 @@ static int mcp795_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
 			return ret;
 		dev_dbg(dev, "Alarm IRQ armed\n");
 	}
-	dev_dbg(dev, "Set alarm: %02d-%02d(%d) %02d:%02d:%02d\n",
-			alm->time.tm_mon, alm->time.tm_mday, alm->time.tm_wday,
-			alm->time.tm_hour, alm->time.tm_min, alm->time.tm_sec);
+	dev_dbg(dev, "Set alarm: %ptRdr(%d) %ptRt\n",
+		&alm->time, alm->time.tm_wday, &alm->time);
 	return 0;
 }
 
@@ -345,9 +340,8 @@ static int mcp795_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
 	alm->time.tm_isdst	= -1;
 	alm->time.tm_yday	= -1;
 
-	dev_dbg(dev, "Read alarm: %02d-%02d(%d) %02d:%02d:%02d\n",
-			alm->time.tm_mon, alm->time.tm_mday, alm->time.tm_wday,
-			alm->time.tm_hour, alm->time.tm_min, alm->time.tm_sec);
+	dev_dbg(dev, "Read alarm: %ptRdr(%d) %ptRt\n",
+		&alm->time, alm->time.tm_wday, &alm->time);
 	return 0;
 }
 
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 08/21] rtc: pcf50633: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (6 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 07/21] rtc: mcp795: " Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 09/21] rtc: pic32: " Andy Shevchenko
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/rtc/rtc-pcf50633.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/rtc/rtc-pcf50633.c b/drivers/rtc/rtc-pcf50633.c
index 00c31c91b245..ace2080daf10 100644
--- a/drivers/rtc/rtc-pcf50633.c
+++ b/drivers/rtc/rtc-pcf50633.c
@@ -131,9 +131,7 @@ static int pcf50633_rtc_read_time(struct device *dev, struct rtc_time *tm)
 
 	pcf2rtc_time(tm, &pcf_tm);
 
-	dev_dbg(dev, "RTC_TIME: %u.%u.%u %u:%u:%u\n",
-		tm->tm_mday, tm->tm_mon, tm->tm_year,
-		tm->tm_hour, tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "RTC_TIME: %ptRr\n", tm);
 
 	return rtc_valid_tm(tm);
 }
@@ -146,9 +144,7 @@ static int pcf50633_rtc_set_time(struct device *dev, struct rtc_time *tm)
 
 	rtc = dev_get_drvdata(dev);
 
-	dev_dbg(dev, "RTC_TIME: %u.%u.%u %u:%u:%u\n",
-		tm->tm_mday, tm->tm_mon, tm->tm_year,
-		tm->tm_hour, tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "RTC_TIME: %ptRr\n", tm);
 
 	rtc2pcf_time(&pcf_tm, tm);
 
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 09/21] rtc: pic32: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (7 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 08/21] rtc: pcf50633: " Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 10/21] rtc: pm8xxx: " Andy Shevchenko
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/rtc/rtc-pic32.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/rtc/rtc-pic32.c b/drivers/rtc/rtc-pic32.c
index 5cfb6df5c430..c35b62564d3d 100644
--- a/drivers/rtc/rtc-pic32.c
+++ b/drivers/rtc/rtc-pic32.c
@@ -170,9 +170,7 @@ static int pic32_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm)
 
 	rtc_tm->tm_year += 100;
 
-	dev_dbg(dev, "read time %04d.%02d.%02d %02d:%02d:%02d\n",
-		1900 + rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday,
-		rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec);
+	dev_dbg(dev, "read time %ptR\n", rtc_tm);
 
 	clk_disable(pdata->clk);
 	return rtc_valid_tm(rtc_tm);
@@ -184,9 +182,7 @@ static int pic32_rtc_settime(struct device *dev, struct rtc_time *tm)
 	void __iomem *base = pdata->reg_base;
 	int year = tm->tm_year - 100;
 
-	dev_dbg(dev, "set time %04d.%02d.%02d %02d:%02d:%02d\n",
-		1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
-		tm->tm_hour, tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "set time %ptR\n", tm);
 
 	if (year < 0 || year >= 100) {
 		dev_err(dev, "rtc only supports 100 years\n");
@@ -224,10 +220,7 @@ static int pic32_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm)
 
 	alrm->enabled = (alm_en & PIC32_RTCALRM_ALRMEN) ? 1 : 0;
 
-	dev_dbg(dev, "getalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n",
-		alm_en,
-		1900 + alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday,
-		alm_tm->tm_hour, alm_tm->tm_min, alm_tm->tm_sec);
+	dev_dbg(dev, "getalarm: %d, %ptR\n", alm_en, alm_tm);
 
 	alm_tm->tm_sec = bcd2bin(alm_tm->tm_sec);
 	alm_tm->tm_min = bcd2bin(alm_tm->tm_min);
@@ -247,10 +240,7 @@ static int pic32_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
 	void __iomem *base = pdata->reg_base;
 
 	clk_enable(pdata->clk);
-	dev_dbg(dev, "setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n",
-		alrm->enabled,
-		1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday,
-		tm->tm_hour, tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "setalarm: %d, %ptR\n", alrm->enabled, tm);
 
 	writel(0x00, base + PIC32_ALRMTIME);
 	writel(0x00, base + PIC32_ALRMDATE);
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 10/21] rtc: pm8xxx: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (8 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 09/21] rtc: pic32: " Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 11/21] rtc: puv3: " Andy Shevchenko
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/rtc/rtc-pm8xxx.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index fac835530671..deb0f14f9e37 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -196,9 +196,7 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
 		return rc;
 	}
 
-	dev_dbg(dev, "secs = %lu, h:m:s == %d:%d:%d, d/m/y = %d/%d/%d\n",
-		secs, tm->tm_hour, tm->tm_min, tm->tm_sec,
-		tm->tm_mday, tm->tm_mon, tm->tm_year);
+	dev_dbg(dev, "secs = %lu, h:m:s == %ptRt, y-m-d = %ptRdr\n", secs, tm, tm);
 
 	return 0;
 }
@@ -243,10 +241,8 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 		goto rtc_rw_fail;
 	}
 
-	dev_dbg(dev, "Alarm Set for h:r:s=%d:%d:%d, d/m/y=%d/%d/%d\n",
-		alarm->time.tm_hour, alarm->time.tm_min,
-		alarm->time.tm_sec, alarm->time.tm_mday,
-		alarm->time.tm_mon, alarm->time.tm_year);
+	dev_dbg(dev, "Alarm Set for h:m:s=%ptRt, y-m-d=%ptRdr\n",
+		&alarm->time, &alarm->time);
 rtc_rw_fail:
 	spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags);
 	return rc;
@@ -277,10 +273,8 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 		return rc;
 	}
 
-	dev_dbg(dev, "Alarm set for - h:r:s=%d:%d:%d, d/m/y=%d/%d/%d\n",
-		alarm->time.tm_hour, alarm->time.tm_min,
-		alarm->time.tm_sec, alarm->time.tm_mday,
-		alarm->time.tm_mon, alarm->time.tm_year);
+	dev_dbg(dev, "Alarm set for - h:m:s=%ptRt, y-m-d=%ptRdr\n",
+		&alarm->time, &alarm->time);
 
 	return 0;
 }
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 11/21] rtc: puv3: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (9 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 10/21] rtc: pm8xxx: " Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 12/21] rtc: rk808: " Andy Shevchenko
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko, Guan Xuetao

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

Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/rtc/rtc-puv3.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/rtc/rtc-puv3.c b/drivers/rtc/rtc-puv3.c
index 9e83be32ff43..f77ef282f013 100644
--- a/drivers/rtc/rtc-puv3.c
+++ b/drivers/rtc/rtc-puv3.c
@@ -90,9 +90,7 @@ static int puv3_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm)
 {
 	rtc_time_to_tm(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,
-		 rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec);
+	dev_dbg(dev, "read time %ptRr\n", rtc_tm);
 
 	return 0;
 }
@@ -101,9 +99,7 @@ static int puv3_rtc_settime(struct device *dev, struct rtc_time *tm)
 {
 	unsigned long rtc_count = 0;
 
-	dev_dbg(dev, "set time %02d.%02d.%02d %02d/%02d/%02d\n",
-		 tm->tm_year, tm->tm_mon, tm->tm_mday,
-		 tm->tm_hour, tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "set time %ptRr\n", tm);
 
 	rtc_tm_to_time(tm, &rtc_count);
 	writel(rtc_count, RTC_RCNR);
@@ -119,10 +115,7 @@ static int puv3_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm)
 
 	alrm->enabled = readl(RTC_RTSR) & RTC_RTSR_ALE;
 
-	dev_dbg(dev, "read alarm %02x %02x.%02x.%02x %02x/%02x/%02x\n",
-		 alrm->enabled,
-		 alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday,
-		 alm_tm->tm_hour, alm_tm->tm_min, alm_tm->tm_sec);
+	dev_dbg(dev, "read alarm: %d, %ptRr\n", alrm->enabled, alm_tm);
 
 	return 0;
 }
@@ -132,10 +125,7 @@ static int puv3_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
 	struct rtc_time *tm = &alrm->time;
 	unsigned long rtcalarm_count = 0;
 
-	dev_dbg(dev, "puv3_rtc_setalarm: %d, %02x/%02x/%02x %02x.%02x.%02x\n",
-		 alrm->enabled,
-		 tm->tm_mday & 0xff, tm->tm_mon & 0xff, tm->tm_year & 0xff,
-		 tm->tm_hour & 0xff, tm->tm_min & 0xff, tm->tm_sec);
+	dev_dbg(dev, "set alarm: %d, %ptRr\n", alrm->enabled, tm);
 
 	rtc_tm_to_time(tm, &rtcalarm_count);
 	writel(rtcalarm_count, RTC_RTAR);
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 12/21] rtc: rk808: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (10 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 11/21] rtc: puv3: " Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 13/21] rtc: rx6110: " Andy Shevchenko
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/rtc/rtc-rk808.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/rtc/rtc-rk808.c b/drivers/rtc/rtc-rk808.c
index 35c9aada07c8..09d6653bc0de 100644
--- a/drivers/rtc/rtc-rk808.c
+++ b/drivers/rtc/rtc-rk808.c
@@ -138,9 +138,7 @@ static int rk808_rtc_readtime(struct device *dev, struct rtc_time *tm)
 	tm->tm_year = (bcd2bin(rtc_data[5] & YEARS_REG_MSK)) + 100;
 	tm->tm_wday = bcd2bin(rtc_data[6] & WEEKS_REG_MSK);
 	rockchip_to_gregorian(tm);
-	dev_dbg(dev, "RTC date/time %4d-%02d-%02d(%d) %02d:%02d:%02d\n",
-		1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday,
-		tm->tm_wday, tm->tm_hour, tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "RTC date/time %ptRd(%d) %ptRt\n", tm, tm->tm_wday, tm);
 
 	return ret;
 }
@@ -153,9 +151,7 @@ static int rk808_rtc_set_time(struct device *dev, struct rtc_time *tm)
 	u8 rtc_data[NUM_TIME_REGS];
 	int ret;
 
-	dev_dbg(dev, "set RTC date/time %4d-%02d-%02d(%d) %02d:%02d:%02d\n",
-		1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday,
-		tm->tm_wday, tm->tm_hour, tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "set RTC date/time %ptRd(%d) %ptRt\n", tm, tm->tm_wday, tm);
 	gregorian_to_rockchip(tm);
 	rtc_data[0] = bin2bcd(tm->tm_sec);
 	rtc_data[1] = bin2bcd(tm->tm_min);
@@ -216,10 +212,8 @@ static int rk808_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
 		return ret;
 	}
 
-	dev_dbg(dev, "alrm read RTC date/time %4d-%02d-%02d(%d) %02d:%02d:%02d\n",
-		1900 + alrm->time.tm_year, alrm->time.tm_mon + 1,
-		alrm->time.tm_mday, alrm->time.tm_wday, alrm->time.tm_hour,
-		alrm->time.tm_min, alrm->time.tm_sec);
+	dev_dbg(dev, "alrm read RTC date/time %ptRd(%d) %ptRt\n",
+		&alrm->time, alrm->time.tm_wday, &alrm->time);
 
 	alrm->enabled = (int_reg & BIT_RTC_INTERRUPTS_REG_IT_ALARM_M) ? 1 : 0;
 
@@ -261,10 +255,8 @@ static int rk808_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
 		dev_err(dev, "Failed to stop alarm: %d\n", ret);
 		return ret;
 	}
-	dev_dbg(dev, "alrm set RTC date/time %4d-%02d-%02d(%d) %02d:%02d:%02d\n",
-		1900 + alrm->time.tm_year, alrm->time.tm_mon + 1,
-		alrm->time.tm_mday, alrm->time.tm_wday, alrm->time.tm_hour,
-		alrm->time.tm_min, alrm->time.tm_sec);
+	dev_dbg(dev, "alrm set RTC date/time %ptRd(%d) %ptRt\n",
+		&alrm->time, alrm->time.tm_wday, &alrm->time);
 
 	gregorian_to_rockchip(&alrm->time);
 	alrm_data[0] = bin2bcd(alrm->time.tm_sec);
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 13/21] rtc: rx6110: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (11 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 12/21] rtc: rk808: " Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 14/21] rtc: rx8025: " Andy Shevchenko
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/rtc/rtc-rx6110.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/rtc/rtc-rx6110.c b/drivers/rtc/rtc-rx6110.c
index 7c9c08eab5e5..1705358fc706 100644
--- a/drivers/rtc/rtc-rx6110.c
+++ b/drivers/rtc/rtc-rx6110.c
@@ -114,9 +114,7 @@ struct rx6110_data {
  */
 static int rx6110_rtc_tm_to_data(struct rtc_time *tm, u8 *data)
 {
-	pr_debug("%s: date %ds %dm %dh %dmd %dm %dy\n", __func__,
-		 tm->tm_sec, tm->tm_min, tm->tm_hour,
-		 tm->tm_mday, tm->tm_mon, tm->tm_year);
+	pr_debug("%s: date %ptRr\n", __func__, tm);
 
 	/*
 	 * The year in the RTC is a value between 0 and 99.
@@ -154,9 +152,7 @@ static int rx6110_data_to_rtc_tm(u8 *data, struct rtc_time *tm)
 	tm->tm_mon = bcd2bin(data[RTC_MONTH] & 0x1f) - 1;
 	tm->tm_year = bcd2bin(data[RTC_YEAR]) + 100;
 
-	pr_debug("%s: date %ds %dm %dh %dmd %dm %dy\n", __func__,
-		 tm->tm_sec, tm->tm_min, tm->tm_hour,
-		 tm->tm_mday, tm->tm_mon, tm->tm_year);
+	pr_debug("%s: date %ptRr\n", __func__, tm);
 
 	/*
 	 * The year in the RTC is a value between 0 and 99.
@@ -248,9 +244,7 @@ static int rx6110_get_time(struct device *dev, struct rtc_time *tm)
 	if (ret)
 		return ret;
 
-	dev_dbg(dev, "%s: date %ds %dm %dh %dmd %dm %dy\n", __func__,
-		tm->tm_sec, tm->tm_min, tm->tm_hour,
-		tm->tm_mday, tm->tm_mon, tm->tm_year);
+	dev_dbg(dev, "%s: date %ptRr\n", __func__, tm);
 
 	return rtc_valid_tm(tm);
 }
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 14/21] rtc: rx8025: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (12 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 13/21] rtc: rx6110: " Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 15/21] rtc: s3c: " Andy Shevchenko
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/rtc/rtc-rx8025.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/rtc/rtc-rx8025.c b/drivers/rtc/rtc-rx8025.c
index 91857d8d2df8..a44125eba15c 100644
--- a/drivers/rtc/rtc-rx8025.c
+++ b/drivers/rtc/rtc-rx8025.c
@@ -193,10 +193,7 @@ static int rx8025_get_time(struct device *dev, struct rtc_time *dt)
 	if (err)
 		return err;
 
-	dev_dbg(dev, "%s: read 0x%02x 0x%02x "
-		"0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", __func__,
-		date[0], date[1], date[2], date[3], date[4],
-		date[5], date[6]);
+	dev_dbg(dev, "%s: read %7ph\n", __func__, date);
 
 	dt->tm_sec = bcd2bin(date[RX8025_REG_SEC] & 0x7f);
 	dt->tm_min = bcd2bin(date[RX8025_REG_MIN] & 0x7f);
@@ -210,9 +207,7 @@ static int rx8025_get_time(struct device *dev, struct rtc_time *dt)
 	dt->tm_mon = bcd2bin(date[RX8025_REG_MONTH] & 0x1f) - 1;
 	dt->tm_year = bcd2bin(date[RX8025_REG_YEAR]) + 100;
 
-	dev_dbg(dev, "%s: date %ds %dm %dh %dmd %dm %dy\n", __func__,
-		dt->tm_sec, dt->tm_min, dt->tm_hour,
-		dt->tm_mday, dt->tm_mon, dt->tm_year);
+	dev_dbg(dev, "%s: date %ptRr\n", __func__, dt);
 
 	return rtc_valid_tm(dt);
 }
@@ -243,10 +238,7 @@ static int rx8025_set_time(struct device *dev, struct rtc_time *dt)
 	date[RX8025_REG_MONTH] = bin2bcd(dt->tm_mon + 1);
 	date[RX8025_REG_YEAR] = bin2bcd(dt->tm_year - 100);
 
-	dev_dbg(dev,
-		"%s: write 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
-		__func__,
-		date[0], date[1], date[2], date[3], date[4], date[5], date[6]);
+	dev_dbg(dev, "%s: write %7ph\n", __func__, date);
 
 	ret = rx8025_write_regs(rx8025->client, RX8025_REG_SEC, 7, date);
 	if (ret < 0)
@@ -319,10 +311,7 @@ static int rx8025_read_alarm(struct device *dev, struct rtc_wkalrm *t)
 		t->time.tm_hour = bcd2bin(ald[1] & 0x1f) % 12
 			+ (ald[1] & 0x20 ? 12 : 0);
 
-	dev_dbg(dev, "%s: date: %ds %dm %dh %dmd %dm %dy\n",
-		__func__,
-		t->time.tm_sec, t->time.tm_min, t->time.tm_hour,
-		t->time.tm_mday, t->time.tm_mon, t->time.tm_year);
+	dev_dbg(dev, "%s: date: %ptRr\n", __func__, t);
 	t->enabled = !!(rx8025->ctrl1 & RX8025_BIT_CTRL1_DALE);
 	t->pending = (ctrl2 & RX8025_BIT_CTRL2_DAFG) && t->enabled;
 
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 15/21] rtc: s3c: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (13 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 14/21] rtc: rx8025: " Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 16/21] rtc: s5m: " Andy Shevchenko
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/rtc/rtc-s3c.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index a8992c227f61..4a18824a39b1 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -225,13 +225,10 @@ static int s3c_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm)
 	s3c_rtc_disable_clk(info);
 
 	rtc_tm->tm_year += 100;
-
-	dev_dbg(dev, "read time %04d.%02d.%02d %02d:%02d:%02d\n",
-		1900 + rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday,
-		rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec);
-
 	rtc_tm->tm_mon -= 1;
 
+	dev_dbg(dev, "read time %ptR\n", rtc_tm);
+
 	return rtc_valid_tm(rtc_tm);
 }
 
@@ -241,9 +238,7 @@ static int s3c_rtc_settime(struct device *dev, struct rtc_time *tm)
 	int year = tm->tm_year - 100;
 	int ret;
 
-	dev_dbg(dev, "set time %04d.%02d.%02d %02d:%02d:%02d\n",
-		1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
-		tm->tm_hour, tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "set time %ptR\n", tm);
 
 	/* we get around y2k by simply not supporting it */
 
@@ -292,10 +287,7 @@ static int s3c_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm)
 
 	alrm->enabled = (alm_en & S3C2410_RTCALM_ALMEN) ? 1 : 0;
 
-	dev_dbg(dev, "read alarm %d, %04d.%02d.%02d %02d:%02d:%02d\n",
-		alm_en,
-		1900 + alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday,
-		alm_tm->tm_hour, alm_tm->tm_min, alm_tm->tm_sec);
+	dev_dbg(dev, "read alarm %d, %ptR\n", alm_en, alm_tm);
 
 	/* decode the alarm enable field */
 	if (alm_en & S3C2410_RTCALM_SECEN)
@@ -329,10 +321,7 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
 	int ret;
 	int year = tm->tm_year - 100;
 
-	dev_dbg(dev, "s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n",
-		alrm->enabled,
-		1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday,
-		tm->tm_hour, tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "s3c_rtc_setalarm: %d, %ptR\n", alrm->enabled, tm);
 
 	ret = s3c_rtc_enable_clk(info);
 	if (ret)
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 16/21] rtc: s5m: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (14 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 15/21] rtc: s3c: " Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 17/21] rtc: tegra: " Andy Shevchenko
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko, Bartlomiej Zolnierkiewicz

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

Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/rtc/rtc-s5m.c | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c
index 0477678d968f..5c6916ee335c 100644
--- a/drivers/rtc/rtc-s5m.c
+++ b/drivers/rtc/rtc-s5m.c
@@ -403,9 +403,7 @@ static int s5m_rtc_read_time(struct device *dev, struct rtc_time *tm)
 		return -EINVAL;
 	}
 
-	dev_dbg(dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__,
-		1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday,
-		tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_wday);
+	dev_dbg(dev, "%s: %ptR(%d)\n", __func__, tm, tm->tm_wday);
 
 	return rtc_valid_tm(tm);
 }
@@ -433,9 +431,7 @@ static int s5m_rtc_set_time(struct device *dev, struct rtc_time *tm)
 	if (ret < 0)
 		return ret;
 
-	dev_dbg(dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__,
-		1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday,
-		tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_wday);
+	dev_dbg(dev, "%s: %ptR(%d)\n", __func__, tm, tm->tm_wday);
 
 	ret = regmap_raw_write(info->regmap, info->regs->time, data,
 			info->regs->regs_count);
@@ -487,11 +483,7 @@ static int s5m_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 		return -EINVAL;
 	}
 
-	dev_dbg(dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__,
-		1900 + alrm->time.tm_year, 1 + alrm->time.tm_mon,
-		alrm->time.tm_mday, alrm->time.tm_hour,
-		alrm->time.tm_min, alrm->time.tm_sec,
-		alrm->time.tm_wday);
+	dev_dbg(dev, "%s: %ptR(%d)\n", __func__, &alrm->time, alrm->time.tm_wday);
 
 	ret = s5m_check_peding_alarm_interrupt(info, alrm);
 
@@ -510,9 +502,7 @@ static int s5m_rtc_stop_alarm(struct s5m_rtc_info *info)
 		return ret;
 
 	s5m8767_data_to_tm(data, &tm, info->rtc_24hr_mode);
-	dev_dbg(info->dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__,
-		1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday,
-		tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_wday);
+	dev_dbg(info->dev, "%s: %ptR(%d)\n", __func__, &tm, tm.tm_wday);
 
 	switch (info->device_type) {
 	case S5M8763X:
@@ -555,9 +545,7 @@ static int s5m_rtc_start_alarm(struct s5m_rtc_info *info)
 		return ret;
 
 	s5m8767_data_to_tm(data, &tm, info->rtc_24hr_mode);
-	dev_dbg(info->dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__,
-		1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday,
-		tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_wday);
+	dev_dbg(info->dev, "%s: %ptR(%d)\n", __func__, &tm, tm.tm_wday);
 
 	switch (info->device_type) {
 	case S5M8763X:
@@ -617,10 +605,7 @@ static int s5m_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 		return -EINVAL;
 	}
 
-	dev_dbg(dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__,
-		1900 + alrm->time.tm_year, 1 + alrm->time.tm_mon,
-		alrm->time.tm_mday, alrm->time.tm_hour, alrm->time.tm_min,
-		alrm->time.tm_sec, alrm->time.tm_wday);
+	dev_dbg(dev, "%s: %ptR(%d)\n", __func__, &alrm->time, alrm->time.tm_wday);
 
 	ret = s5m_rtc_stop_alarm(info);
 	if (ret < 0)
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 17/21] rtc: tegra: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (15 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 16/21] rtc: s5m: " Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 18/21] ds1302: " Andy Shevchenko
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko, Thierry Reding, Jonathan Hunter

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

Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/rtc/rtc-tegra.c | 30 +++---------------------------
 1 file changed, 3 insertions(+), 27 deletions(-)

diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c
index d30d57b048d3..e9adfaa851f5 100644
--- a/drivers/rtc/rtc-tegra.c
+++ b/drivers/rtc/rtc-tegra.c
@@ -124,15 +124,7 @@ static int tegra_rtc_read_time(struct device *dev, struct rtc_time *tm)
 
 	rtc_time_to_tm(sec, tm);
 
-	dev_vdbg(dev, "time read as %lu. %d/%d/%d %d:%02u:%02u\n",
-		sec,
-		tm->tm_mon + 1,
-		tm->tm_mday,
-		tm->tm_year + 1900,
-		tm->tm_hour,
-		tm->tm_min,
-		tm->tm_sec
-	);
+	dev_vdbg(dev, "time read as %lu. %ptR\n", sec, tm);
 
 	return 0;
 }
@@ -150,15 +142,7 @@ static int tegra_rtc_set_time(struct device *dev, struct rtc_time *tm)
 
 	rtc_tm_to_time(tm, &sec);
 
-	dev_vdbg(dev, "time set to %lu. %d/%d/%d %d:%02u:%02u\n",
-		sec,
-		tm->tm_mon+1,
-		tm->tm_mday,
-		tm->tm_year+1900,
-		tm->tm_hour,
-		tm->tm_min,
-		tm->tm_sec
-	);
+	dev_vdbg(dev, "time set to %lu. %ptR\n", sec, tm);
 
 	/* seconds only written if wait succeeded. */
 	ret = tegra_rtc_wait_while_busy(dev);
@@ -235,15 +219,7 @@ static int tegra_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 	/* if successfully written and alarm is enabled ... */
 	if (sec) {
 		tegra_rtc_alarm_irq_enable(dev, 1);
-
-		dev_vdbg(dev, "alarm set as %lu. %d/%d/%d %d:%02u:%02u\n",
-			sec,
-			alarm->time.tm_mon+1,
-			alarm->time.tm_mday,
-			alarm->time.tm_year+1900,
-			alarm->time.tm_hour,
-			alarm->time.tm_min,
-			alarm->time.tm_sec);
+		dev_vdbg(dev, "alarm set as %lu. %ptR\n", sec, &alarm->time);
 	} else {
 		/* disable alarm if 0 or write error. */
 		dev_vdbg(dev, "alarm disabled\n");
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 18/21] ds1302: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (16 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 17/21] rtc: tegra: " Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 19/21] Input: hp_sdc_rtc - " Andy Shevchenko
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko

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

Cc: Arnd Bergmann <arnd@arndb.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/char/Kconfig  |  1 +
 drivers/char/ds1302.c | 39 ++++++++++-----------------------------
 2 files changed, 11 insertions(+), 29 deletions(-)

diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index c96e00ebeae9..2bd83d3951c1 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -350,6 +350,7 @@ config EFI_RTC
 config DS1302
 	tristate "DS1302 RTC support"
 	depends on M32R && (PLAT_M32700UT || PLAT_OPSPUT)
+	select PRINTK_PEXT_TIMEDATE
 	help
 	  If you say Y here and create a character special file /dev/rtc with
 	  major number 121 and minor number 0 using mknod ("man mknod"), you
diff --git a/drivers/char/ds1302.c b/drivers/char/ds1302.c
index 8e16ad5d6d89..1e8bd9bf4bc9 100644
--- a/drivers/char/ds1302.c
+++ b/drivers/char/ds1302.c
@@ -5,7 +5,7 @@
 *!
 *! DESCRIPTION: Implements an interface for the DS1302 RTC
 *!
-*! Functions exported: ds1302_readreg, ds1302_writereg, ds1302_init, get_rtc_status
+*! Functions exported: ds1302_readreg, ds1302_writereg, ds1302_init
 *!
 *! ---------------------------------------------------------------------------
 *!
@@ -258,31 +258,6 @@ static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	}
 }
 
-int
-get_rtc_status(char *buf)
-{
-	char *p;
-	struct rtc_time tm;
-
-	p = buf;
-
-	get_rtc_time(&tm);
-
-	/*
-	 * There is no way to tell if the luser has the RTC set for local
-	 * time or for Universal Standard Time (GMT). Probably local though.
-	 */
-
-	p += sprintf(p,
-		"rtc_time\t: %02d:%02d:%02d\n"
-		"rtc_date\t: %04d-%02d-%02d\n",
-		tm.tm_hour, tm.tm_min, tm.tm_sec,
-		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
-
-	return  p - buf;
-}
-
-
 /* The various file operations we support. */
 
 static const struct file_operations rtc_fops = {
@@ -299,6 +274,7 @@ static int __init
 ds1302_probe(void)
 {
 	int retval, res, baur;
+	struct rtc_time tm;
 
 	baur=(boot_cpu_data.bus_clock/(2*1000*1000));
 
@@ -317,11 +293,16 @@ ds1302_probe(void)
 
 	/* read RAM byte 0 */
 	if((res = in_byte_rtc(0xc1)) == MAGIC_PATTERN) {
-		char buf[100];
 		ds1302_wdisable();
 		printk("%s: RTC found.\n", ds1302_name);
-		get_rtc_status(buf);
-		printk(buf);
+		/*
+		 * There is no way to tell if the luser has the RTC set
+		 * for local time or for Universal Standard Time (GMT).
+		 * Probably local though.
+		 */
+		get_rtc_time(&tm);
+		printk("rtc_time\t: %ptRt\n", &tm);
+		printk("rtc_date\t: %ptRd\n", &tm);
 		retval = 1;
 	} else {
 		printk("%s: RTC not found.\n", ds1302_name);
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 19/21] Input: hp_sdc_rtc - Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (17 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 18/21] ds1302: " Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-20 21:43 ` [PATCH v2 20/21] mk68/mac: " Andy Shevchenko
  2018-02-20 21:44 ` [PATCH v2 21/21] PM: " Andy Shevchenko
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko, Dmitry Torokhov

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

Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/input/misc/Kconfig      | 1 +
 drivers/input/misc/hp_sdc_rtc.c | 8 +++-----
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 62a1312a7387..f0f09ef79081 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -525,6 +525,7 @@ config HP_SDC_RTC
 	tristate "HP SDC Real Time Clock"
 	depends on (GSC || HP300) && SERIO
 	select HP_SDC
+	select PRINTK_PEXT_TIMEDATE
 	help
 	  Say Y here if you want to support the built-in real time clock
 	  of the HP SDC controller.
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
index 49b34de0aed4..503ff518dfa2 100644
--- a/drivers/input/misc/hp_sdc_rtc.c
+++ b/drivers/input/misc/hp_sdc_rtc.c
@@ -441,12 +441,10 @@ static int hp_sdc_rtc_proc_show(struct seq_file *m, void *v)
 		seq_puts(m, "BBRTC\t\t: READ FAILED!\n");
 	} else {
 		seq_printf(m,
-			     "rtc_time\t: %02d:%02d:%02d\n"
-			     "rtc_date\t: %04d-%02d-%02d\n"
+			     "rtc_time\t: %ptRt\n"
+			     "rtc_date\t: %ptRd\n"
 			     "rtc_epoch\t: %04lu\n",
-			     tm.tm_hour, tm.tm_min, tm.tm_sec,
-			     tm.tm_year + 1900, tm.tm_mon + 1, 
-			     tm.tm_mday, epoch);
+			     &tm, &tm, epoch);
 	}
 
 	if (hp_sdc_rtc_read_rt(&tv)) {
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 20/21] mk68/mac: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (18 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 19/21] Input: hp_sdc_rtc - " Andy Shevchenko
@ 2018-02-20 21:43 ` Andy Shevchenko
  2018-02-21  9:38   ` Geert Uytterhoeven
  2018-02-20 21:44 ` [PATCH v2 21/21] PM: " Andy Shevchenko
  20 siblings, 1 reply; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:43 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko, Geert Uytterhoeven

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

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/m68k/Kconfig.machine | 1 +
 arch/m68k/mac/misc.c      | 8 ++------
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/m68k/Kconfig.machine b/arch/m68k/Kconfig.machine
index 64a641467736..620a55da648e 100644
--- a/arch/m68k/Kconfig.machine
+++ b/arch/m68k/Kconfig.machine
@@ -26,6 +26,7 @@ config MAC
 	bool "Macintosh support"
 	depends on MMU
 	select MMU_MOTOROLA if MMU
+	select PRINTK_PEXT_TIMEDATE
 	help
 	  This option enables support for the Apple Macintosh series of
 	  computers (yes, there is experimental support now, at least for part
diff --git a/arch/m68k/mac/misc.c b/arch/m68k/mac/misc.c
index 4956edaac926..0002bb0ebbfc 100644
--- a/arch/m68k/mac/misc.c
+++ b/arch/m68k/mac/misc.c
@@ -673,13 +673,9 @@ int mac_hwclk(int op, struct rtc_time *t)
 		unmktime(now, 0,
 			 &t->tm_year, &t->tm_mon, &t->tm_mday,
 			 &t->tm_hour, &t->tm_min, &t->tm_sec);
-		pr_debug("%s: read %04d-%02d-%-2d %02d:%02d:%02d\n",
-		         __func__, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
-		         t->tm_hour, t->tm_min, t->tm_sec);
+		pr_debug("%s: read %ptR\n", __func__, t);
 	} else { /* write */
-		pr_debug("%s: tried to write %04d-%02d-%-2d %02d:%02d:%02d\n",
-		         __func__, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
-		         t->tm_hour, t->tm_min, t->tm_sec);
+		pr_debug("%s: tried to write %ptR\n", __func__, t);
 
 		now = mktime(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
 			     t->tm_hour, t->tm_min, t->tm_sec);
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 21/21] PM: Switch to use %ptR
  2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
                   ` (19 preceding siblings ...)
  2018-02-20 21:43 ` [PATCH v2 20/21] mk68/mac: " Andy Shevchenko
@ 2018-02-20 21:44 ` Andy Shevchenko
  20 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-20 21:44 UTC (permalink / raw)
  To: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Joe Perches, Mark Salyzyn
  Cc: Andy Shevchenko, linux-pm

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

Cc: linux-pm@vger.kernel.org
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/power/trace.c | 4 +---
 kernel/power/Kconfig       | 1 +
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/base/power/trace.c b/drivers/base/power/trace.c
index 1cda505d6a85..b11f47a1e819 100644
--- a/drivers/base/power/trace.c
+++ b/drivers/base/power/trace.c
@@ -118,9 +118,7 @@ static unsigned int read_magic_time(void)
 	unsigned int val;
 
 	mc146818_get_time(&time);
-	pr_info("RTC time: %2d:%02d:%02d, date: %02d/%02d/%02d\n",
-		time.tm_hour, time.tm_min, time.tm_sec,
-		time.tm_mon + 1, time.tm_mday, time.tm_year % 100);
+	pr_info("RTC time: %ptRt, date: %ptRd\n", &time, &time);
 	val = time.tm_year;				/* 100 years */
 	if (val > 100)
 		val -= 100;
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index e880ca22c5a5..f73cecd3b75f 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -220,6 +220,7 @@ config PM_TRACE_RTC
 	depends on PM_SLEEP_DEBUG
 	depends on X86
 	select PM_TRACE
+	select PRINTK_PEXT_TIMEDATE
 	---help---
 	This enables some cheesy code to save the last PM event point in the
 	RTC across reboots, so that you can debug a machine that just hangs
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
  2018-02-20 21:43 ` [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt Andy Shevchenko
@ 2018-02-20 23:55     ` Joe Perches
  2018-02-21  9:33   ` Geert Uytterhoeven
  1 sibling, 0 replies; 41+ messages in thread
From: Joe Perches @ 2018-02-20 23:55 UTC (permalink / raw)
  To: Andy Shevchenko, Rasmus Villemoes, Greg Kroah-Hartman,
	Andrew Morton, linux-kernel, Alessandro Zummo, Alexandre Belloni,
	linux-rtc, Arnd Bergmann, Mark Salyzyn
  Cc: Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Geert Uytterhoeven,
	Guan Xuetao, Ingo Molnar, Jason Wessel, Jonathan Corbet,
	Jonathan Hunter, Krzysztof Kozlowski, Rafael J. Wysocki,
	Thierry Reding

On Tue, 2018-02-20 at 23:43 +0200, Andy Shevchenko wrote:
> There are users which print time and date represented by content of
> struct rtc_time in human readable format.
> 
> Instead of open coding that each time introduce %ptR[dt][rv] specifier.
> 
> Note, users have to select PRINTK_PEXT_TIMEDATE option in a Kconfig.

Not sure this is a great option.
Not just the name, the need to select it.

> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
[]
> +static noinline_for_stack
> +char *date_str(char *buf, char *end, const struct rtc_time *tm, bool v, bool r)
> +{
> +	int year = tm->tm_year + (r ? 0 : 1900);
> +	int mon = tm->tm_mon + (r ? 0 : 1);

What happens with negative values?
Perhaps these temporaries should be unsigned int.

> +
> +	if (unlikely(v && (unsigned int)tm->tm_year > 200))
> +		buf = string(buf, end, "****", default_str_spec);
> +	else
> +		buf = number(buf, end, year, default_dec04_spec);
> +
> +	if (buf < end)
> +		*buf = '-';
> +	buf++;
> +
> +	if (unlikely(v && (unsigned int)tm->tm_mon > 11))
> +		buf = string(buf, end, "**", default_str_spec);
> +	else
> +		buf = number(buf, end, mon, default_dec02_spec);
> +
> +	if (buf < end)
> +		*buf = '-';
> +	buf++;
> +
> +	if (unlikely(v && (unsigned int)tm->tm_mday > 31))
> +		buf = string(buf, end, "**", default_str_spec);
> +	else
> +		buf = number(buf, end, tm->tm_mday, default_dec02_spec);
> +
> +	return buf;
> +}
> +
> +static noinline_for_stack
> +char *time_str(char *buf, char *end, const struct rtc_time *tm, bool v, bool r)
> +{

Maybe use unsigned int temporaries here too for hour, min, sec

> +	if (unlikely(v && (unsigned int)tm->tm_hour > 24))
> +		buf = string(buf, end, "**", default_str_spec);
> +	else
> +		buf = number(buf, end, tm->tm_hour, default_dec02_spec);
> +
> +	if (buf < end)
> +		*buf = ':';
> +	buf++;
> +
> +	if (unlikely(v && (unsigned int)tm->tm_min > 59))

leap seconds are allowed in the struct

> +		buf = string(buf, end, "**", default_str_spec);
> +	else
> +		buf = number(buf, end, tm->tm_min, default_dec02_spec);
> +
> +	if (buf < end)
> +		*buf = ':';
> +	buf++;
> +
> +	if (unlikely(v && (unsigned int)tm->tm_sec > 59))
> +		buf = string(buf, end, "**", default_str_spec);
> +	else
> +		buf = number(buf, end, tm->tm_sec, default_dec02_spec);
> +
> +	return buf;
> +}
> 

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
@ 2018-02-20 23:55     ` Joe Perches
  0 siblings, 0 replies; 41+ messages in thread
From: Joe Perches @ 2018-02-20 23:55 UTC (permalink / raw)
  To: Andy Shevchenko, Rasmus Villemoes, Greg Kroah-Hartman,
	Andrew Morton, linux-kernel, Alessandro Zummo, Alexandre Belloni,
	linux-rtc, Arnd Bergmann, Mark Salyzyn
  Cc: Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Geert Uytterhoeven,
	Guan Xuetao, Ingo Molnar, Jason Wessel, Jonathan Corbet,
	Jonathan Hunter, Krzysztof Kozlowski, Rafael J. Wysocki,
	Thierry Reding

On Tue, 2018-02-20 at 23:43 +0200, Andy Shevchenko wrote:
> There are users which print time and date represented by content of
> struct rtc_time in human readable format.
> 
> Instead of open coding that each time introduce %ptR[dt][rv] specifier.
> 
> Note, users have to select PRINTK_PEXT_TIMEDATE option in a Kconfig.

Not sure this is a great option.
Not just the name, the need to select it.

> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
[]
> +static noinline_for_stack
> +char *date_str(char *buf, char *end, const struct rtc_time *tm, bool v, bool r)
> +{
> +	int year = tm->tm_year + (r ? 0 : 1900);
> +	int mon = tm->tm_mon + (r ? 0 : 1);

What happens with negative values?
Perhaps these temporaries should be unsigned int.

> +
> +	if (unlikely(v && (unsigned int)tm->tm_year > 200))
> +		buf = string(buf, end, "****", default_str_spec);
> +	else
> +		buf = number(buf, end, year, default_dec04_spec);
> +
> +	if (buf < end)
> +		*buf = '-';
> +	buf++;
> +
> +	if (unlikely(v && (unsigned int)tm->tm_mon > 11))
> +		buf = string(buf, end, "**", default_str_spec);
> +	else
> +		buf = number(buf, end, mon, default_dec02_spec);
> +
> +	if (buf < end)
> +		*buf = '-';
> +	buf++;
> +
> +	if (unlikely(v && (unsigned int)tm->tm_mday > 31))
> +		buf = string(buf, end, "**", default_str_spec);
> +	else
> +		buf = number(buf, end, tm->tm_mday, default_dec02_spec);
> +
> +	return buf;
> +}
> +
> +static noinline_for_stack
> +char *time_str(char *buf, char *end, const struct rtc_time *tm, bool v, bool r)
> +{

Maybe use unsigned int temporaries here too for hour, min, sec

> +	if (unlikely(v && (unsigned int)tm->tm_hour > 24))
> +		buf = string(buf, end, "**", default_str_spec);
> +	else
> +		buf = number(buf, end, tm->tm_hour, default_dec02_spec);
> +
> +	if (buf < end)
> +		*buf = ':';
> +	buf++;
> +
> +	if (unlikely(v && (unsigned int)tm->tm_min > 59))

leap seconds are allowed in the struct

> +		buf = string(buf, end, "**", default_str_spec);
> +	else
> +		buf = number(buf, end, tm->tm_min, default_dec02_spec);
> +
> +	if (buf < end)
> +		*buf = ':';
> +	buf++;
> +
> +	if (unlikely(v && (unsigned int)tm->tm_sec > 59))
> +		buf = string(buf, end, "**", default_str_spec);
> +	else
> +		buf = number(buf, end, tm->tm_sec, default_dec02_spec);
> +
> +	return buf;
> +}
> 

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
  2018-02-20 23:55     ` Joe Perches
  (?)
@ 2018-02-21  7:38     ` Rasmus Villemoes
  2018-02-21 13:23         ` Andy Shevchenko
  -1 siblings, 1 reply; 41+ messages in thread
From: Rasmus Villemoes @ 2018-02-21  7:38 UTC (permalink / raw)
  To: Joe Perches, Andy Shevchenko, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Mark Salyzyn
  Cc: Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Geert Uytterhoeven,
	Guan Xuetao, Ingo Molnar, Jason Wessel, Jonathan Corbet,
	Jonathan Hunter, Krzysztof Kozlowski, Rafael J. Wysocki,
	Thierry Reding

On 2018-02-21 00:55, Joe Perches wrote:
> On Tue, 2018-02-20 at 23:43 +0200, Andy Shevchenko wrote:
>> There are users which print time and date represented by content of
>> struct rtc_time in human readable format.
>>
>> Instead of open coding that each time introduce %ptR[dt][rv] specifier.
>>
>> Note, users have to select PRINTK_PEXT_TIMEDATE option in a Kconfig.
> 
> Not sure this is a great option.
> Not just the name, the need to select it.

Bikeshedding first: If you do keep the config option, please use PRINTF,
not PRINTK - vsprintf can be and is used by lots of code other than printk.

Well, on the one hand, I like to reduce the size of the kernel when
possible and ideally make all new functionality guarded by config
options, but OTOH, how much does compiling out the datetime formatters
really save? Also, I agree with Joe's concern about the need to select
it. Maybe if we had a gcc plugin that did %pFOO validation it could also
warn about %pBAR being used without a corresponding config option being
set. But we don't have that currently...

Rasmus

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
  2018-02-20 23:55     ` Joe Perches
  (?)
  (?)
@ 2018-02-21  9:16     ` Alexandre Belloni
  -1 siblings, 0 replies; 41+ messages in thread
From: Alexandre Belloni @ 2018-02-21  9:16 UTC (permalink / raw)
  To: Joe Perches
  Cc: Andy Shevchenko, Rasmus Villemoes, Greg Kroah-Hartman,
	Andrew Morton, linux-kernel, Alessandro Zummo, linux-rtc,
	Arnd Bergmann, Mark Salyzyn, Bartlomiej Zolnierkiewicz,
	Dmitry Torokhov, Geert Uytterhoeven, Guan Xuetao, Ingo Molnar,
	Jason Wessel, Jonathan Corbet, Jonathan Hunter,
	Krzysztof Kozlowski, Rafael J. Wysocki, Thierry Reding

On 20/02/2018 at 15:55:07 -0800, Joe Perches wrote:
> On Tue, 2018-02-20 at 23:43 +0200, Andy Shevchenko wrote:
> > +static noinline_for_stack
> > +char *time_str(char *buf, char *end, const struct rtc_time *tm, bool v, bool r)
> > +{
> 
> Maybe use unsigned int temporaries here too for hour, min, sec
> 
> > +	if (unlikely(v && (unsigned int)tm->tm_hour > 24))
> > +		buf = string(buf, end, "**", default_str_spec);
> > +	else
> > +		buf = number(buf, end, tm->tm_hour, default_dec02_spec);
> > +
> > +	if (buf < end)
> > +		*buf = ':';
> > +	buf++;
> > +
> > +	if (unlikely(v && (unsigned int)tm->tm_min > 59))
> 
> leap seconds are allowed in the struct
> 

No, they are not:
https://elixir.bootlin.com/linux/v4.15.4/source/drivers/rtc/rtc-lib.c#L108


-- 
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
  2018-02-20 21:43 ` [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt Andy Shevchenko
  2018-02-20 23:55     ` Joe Perches
@ 2018-02-21  9:33   ` Geert Uytterhoeven
  2018-02-21 14:02       ` Andy Shevchenko
  1 sibling, 1 reply; 41+ messages in thread
From: Geert Uytterhoeven @ 2018-02-21  9:33 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	Linux Kernel Mailing List, Alessandro Zummo, Alexandre Belloni,
	linux-rtc, Arnd Bergmann, Joe Perches, Mark Salyzyn,
	Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Guan Xuetao,
	Ingo Molnar, Jason Wessel, Jonathan Corbet, Jonathan Hunter,
	Krzysztof Kozlowski, Rafael J. Wysocki, Thierry Reding

Hi Andy,

On Tue, Feb 20, 2018 at 10:43 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> There are users which print time and date represented by content of
> struct rtc_time in human readable format.
>
> Instead of open coding that each time introduce %ptR[dt][rv] specifier.

Thanks for your patch!

> Note, users have to select PRINTK_PEXT_TIMEDATE option in a Kconfig.

Is it worthwhile making this an option?

> --- a/Documentation/core-api/printk-formats.rst
> +++ b/Documentation/core-api/printk-formats.rst
> @@ -412,6 +412,37 @@ Examples::
>
>  Passed by reference.
>
> +Time and date
> +-------------
> +
> +::
> +
> +       %pt[R]          YYYY-mm-dd HH:MM:SS
> +       %pt[R]d         YYYY-mm-dd
> +       %pt[R]t         HH:MM:SS

[R] suggests the "R" is optional?
But if it's missing, it prints the hex pointer value?

> +       %pt[R][dt]

What's the purpose of this?

> +
> +  R for struct rtc_time
> +
> +Note, users have to select PRINTK_PEXT_TIMEDATE option in a Kconfig.
> +
> +struct rtc_time
> +~~~~~~~~~~~~~~~
> +
> +::
> +
> +       %ptR[dt][rv]

What's the purpose of this paragraph, compared to the previous one?

> +
> +For printing date and time as represented by struct rtc_time structure in
> +human readable format.

> @@ -1443,6 +1458,132 @@ char *address_val(char *buf, char *end, const void *addr, const char *fmt)
>         return special_hex_number(buf, end, num, size);
>  }
>
> +static noinline_for_stack
> +char *date_str(char *buf, char *end, const struct rtc_time *tm, bool v, bool r)
> +{
> +       int year = tm->tm_year + (r ? 0 : 1900);
> +       int mon = tm->tm_mon + (r ? 0 : 1);
> +
> +       if (unlikely(v && (unsigned int)tm->tm_year > 200))
> +               buf = string(buf, end, "****", default_str_spec);
> +       else
> +               buf = number(buf, end, year, default_dec04_spec);
> +
> +       if (buf < end)
> +               *buf = '-';

Instead of all these checks to avoid overflowing the passed buffer, it
may be simpler to format everything in a fixed-size buffer on the stack,
and copy whatever will fit in the target buffer at the end.

> +       buf++;
> +
> +       if (unlikely(v && (unsigned int)tm->tm_mon > 11))
> +               buf = string(buf, end, "**", default_str_spec);
> +       else
> +               buf = number(buf, end, mon, default_dec02_spec);
> +
> +       if (buf < end)
> +               *buf = '-';
> +       buf++;
> +
> +       if (unlikely(v && (unsigned int)tm->tm_mday > 31))
> +               buf = string(buf, end, "**", default_str_spec);
> +       else
> +               buf = number(buf, end, tm->tm_mday, default_dec02_spec);
> +
> +       return buf;
> +}
> +
> +static noinline_for_stack
> +char *time_str(char *buf, char *end, const struct rtc_time *tm, bool v, bool r)
> +{
> +       if (unlikely(v && (unsigned int)tm->tm_hour > 24))
> +               buf = string(buf, end, "**", default_str_spec);
> +       else
> +               buf = number(buf, end, tm->tm_hour, default_dec02_spec);
> +
> +       if (buf < end)
> +               *buf = ':';

Likewise.

> +       buf++;
> +
> +       if (unlikely(v && (unsigned int)tm->tm_min > 59))
> +               buf = string(buf, end, "**", default_str_spec);
> +       else
> +               buf = number(buf, end, tm->tm_min, default_dec02_spec);
> +
> +       if (buf < end)
> +               *buf = ':';
> +       buf++;
> +
> +       if (unlikely(v && (unsigned int)tm->tm_sec > 59))
> +               buf = string(buf, end, "**", default_str_spec);
> +       else
> +               buf = number(buf, end, tm->tm_sec, default_dec02_spec);
> +
> +       return buf;
> +}
> +
> +static noinline_for_stack
> +char *rtc_str(char *buf, char *end, const struct rtc_time *tm, const char *fmt)
> +{
> +       bool have_t = true, have_d = true;
> +       bool validate = false;
> +       bool raw = false;
> +       int count = 1;
> +       bool found;
> +
> +       switch (fmt[++count]) {
> +       case 'd':
> +               have_t = false;
> +               break;
> +       case 't':
> +               have_d = false;
> +               break;
> +       }
> +
> +       /* No %pt[dt] supplied */
> +       if (have_d && have_t)
> +               --count;

First increment count, then rollback.
What about:

    switch (fmt[count]) {
    case 'd':
            have_t = false;
            count++;
            break;
    case 't':
            have_d = false;
            count++;
            break;
    }

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 20/21] mk68/mac: Switch to use %ptR
  2018-02-20 21:43 ` [PATCH v2 20/21] mk68/mac: " Andy Shevchenko
@ 2018-02-21  9:38   ` Geert Uytterhoeven
  2018-02-21 14:04     ` Andy Shevchenko
  0 siblings, 1 reply; 41+ messages in thread
From: Geert Uytterhoeven @ 2018-02-21  9:38 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	Linux Kernel Mailing List, Alessandro Zummo, Alexandre Belloni,
	linux-rtc, Arnd Bergmann, Joe Perches, Mark Salyzyn

Hi Andy,

On Tue, Feb 20, 2018 at 10:43 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> Use %ptR instead of open coded variant to print content of
> struct rtc_time in human readable format.
>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  arch/m68k/Kconfig.machine | 1 +
>  arch/m68k/mac/misc.c      | 8 ++------
>  2 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/arch/m68k/Kconfig.machine b/arch/m68k/Kconfig.machine
> index 64a641467736..620a55da648e 100644
> --- a/arch/m68k/Kconfig.machine
> +++ b/arch/m68k/Kconfig.machine
> @@ -26,6 +26,7 @@ config MAC
>         bool "Macintosh support"
>         depends on MMU
>         select MMU_MOTOROLA if MMU
> +       select PRINTK_PEXT_TIMEDATE

Yeah, now you have to track whatever code uses the new %p extension...

Note that the user below uses pr_debug(), so technically it depends on
DYNAMIC_DEBUG, or (more likely) someone manually inserting "#define DEBUG"
at the top of the file for a short debug session ;-)

> --- a/arch/m68k/mac/misc.c
> +++ b/arch/m68k/mac/misc.c
> @@ -673,13 +673,9 @@ int mac_hwclk(int op, struct rtc_time *t)
>                 unmktime(now, 0,
>                          &t->tm_year, &t->tm_mon, &t->tm_mday,
>                          &t->tm_hour, &t->tm_min, &t->tm_sec);
> -               pr_debug("%s: read %04d-%02d-%-2d %02d:%02d:%02d\n",
> -                        __func__, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
> -                        t->tm_hour, t->tm_min, t->tm_sec);
> +               pr_debug("%s: read %ptR\n", __func__, t);
>         } else { /* write */
> -               pr_debug("%s: tried to write %04d-%02d-%-2d %02d:%02d:%02d\n",
> -                        __func__, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
> -                        t->tm_hour, t->tm_min, t->tm_sec);
> +               pr_debug("%s: tried to write %ptR\n", __func__, t);
>
>                 now = mktime(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
>                              t->tm_hour, t->tm_min, t->tm_sec);

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
  2018-02-20 23:55     ` Joe Perches
@ 2018-02-21 13:19       ` Andy Shevchenko
  -1 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-21 13:19 UTC (permalink / raw)
  To: Joe Perches, Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Mark Salyzyn
  Cc: Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Geert Uytterhoeven,
	Guan Xuetao, Ingo Molnar, Jason Wessel, Jonathan Corbet,
	Jonathan Hunter, Krzysztof Kozlowski, Rafael J. Wysocki,
	Thierry Reding

On Tue, 2018-02-20 at 15:55 -0800, Joe Perches wrote:
> On Tue, 2018-02-20 at 23:43 +0200, Andy Shevchenko wrote:
> > There are users which print time and date represented by content of
> > struct rtc_time in human readable format.
> > 
> > Instead of open coding that each time introduce %ptR[dt][rv]
> > specifier.
> > 
> > Note, users have to select PRINTK_PEXT_TIMEDATE option in a Kconfig.
> 
> Not sure this is a great option.
> Not just the name, the need to select it.

kbuildbot and some people complained about + text size.
https://lists.01.org/pipermail/kbuild-all/2017-June/034950.html

I would really like to compile it always.

> > +	int year = tm->tm_year + (r ? 0 : 1900);
> > +	int mon = tm->tm_mon + (r ? 0 : 1);
> 
> What happens with negative values?

Same as before.

> Perhaps these temporaries should be unsigned int.

No, the type of them is int, so, I'll keep it int.

> > +	if (unlikely(v && (unsigned int)tm->tm_min > 59))
> 
> leap seconds are allowed in the struct

Alexandre answered already, but I would add that this is part of
existing ABI, so, I wouldn't go to change this.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
@ 2018-02-21 13:19       ` Andy Shevchenko
  0 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-21 13:19 UTC (permalink / raw)
  To: Joe Perches, Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Mark Salyzyn
  Cc: Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Geert Uytterhoeven,
	Guan Xuetao, Ingo Molnar, Jason Wessel, Jonathan Corbet,
	Jonathan Hunter, Krzysztof Kozlowski, Rafael J. Wysocki,
	Thierry Reding

On Tue, 2018-02-20 at 15:55 -0800, Joe Perches wrote:
> On Tue, 2018-02-20 at 23:43 +0200, Andy Shevchenko wrote:
> > There are users which print time and date represented by content of
> > struct rtc_time in human readable format.
> > 
> > Instead of open coding that each time introduce %ptR[dt][rv]
> > specifier.
> > 
> > Note, users have to select PRINTK_PEXT_TIMEDATE option in a Kconfig.
> 
> Not sure this is a great option.
> Not just the name, the need to select it.

kbuildbot and some people complained about + text size.
https://lists.01.org/pipermail/kbuild-all/2017-June/034950.html

I would really like to compile it always.

> > +	int year = tm->tm_year + (r ? 0 : 1900);
> > +	int mon = tm->tm_mon + (r ? 0 : 1);
> 
> What happens with negative values?

Same as before.

> Perhaps these temporaries should be unsigned int.

No, the type of them is int, so, I'll keep it int.

> > +	if (unlikely(v && (unsigned int)tm->tm_min > 59))
> 
> leap seconds are allowed in the struct

Alexandre answered already, but I would add that this is part of
existing ABI, so, I wouldn't go to change this.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
  2018-02-21  7:38     ` Rasmus Villemoes
@ 2018-02-21 13:23         ` Andy Shevchenko
  0 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-21 13:23 UTC (permalink / raw)
  To: Rasmus Villemoes, Joe Perches, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Mark Salyzyn
  Cc: Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Geert Uytterhoeven,
	Guan Xuetao, Ingo Molnar, Jason Wessel, Jonathan Corbet,
	Jonathan Hunter, Krzysztof Kozlowski, Rafael J. Wysocki,
	Thierry Reding

On Wed, 2018-02-21 at 08:38 +0100, Rasmus Villemoes wrote:
> On 2018-02-21 00:55, Joe Perches wrote:
> > On Tue, 2018-02-20 at 23:43 +0200, Andy Shevchenko wrote:
> > > There are users which print time and date represented by content
> > > of
> > > struct rtc_time in human readable format.
> > > 
> > > Instead of open coding that each time introduce %ptR[dt][rv]
> > > specifier.
> > > 
> > > Note, users have to select PRINTK_PEXT_TIMEDATE option in a
> > > Kconfig.
> > 
> > Not sure this is a great option.
> > Not just the name, the need to select it.
> 
> Bikeshedding first: If you do keep the config option, please use
> PRINTF,
> not PRINTK - vsprintf can be and is used by lots of code other than
> printk.

OK.

> Well, on the one hand, I like to reduce the size of the kernel when
> possible and ideally make all new functionality guarded by config
> options, but OTOH, how much does compiling out the datetime formatters
> really save?

https://lists.01.org/pipermail/kbuild-all/2017-June/034950.html

I understand that half a year time allows us to increase kernel text
size by 750+ bytes unconditionally.

I would really like to not use any option.

>  Also, I agree with Joe's concern about the need to select
> it.

So, what exactly you are proposing?

>  Maybe if we had a gcc plugin that did %pFOO validation it could also
> warn about %pBAR being used without a corresponding config option
> being
> set. But we don't have that currently...

We have not, so, it's out of scope. If it's a big impediment, then I'm
not the guy who will do the job.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
@ 2018-02-21 13:23         ` Andy Shevchenko
  0 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-21 13:23 UTC (permalink / raw)
  To: Rasmus Villemoes, Joe Perches, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Arnd Bergmann, Mark Salyzyn
  Cc: Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Geert Uytterhoeven,
	Guan Xuetao, Ingo Molnar, Jason Wessel, Jonathan Corbet,
	Jonathan Hunter, Krzysztof Kozlowski, Rafael J. Wysocki,
	Thierry Reding

On Wed, 2018-02-21 at 08:38 +0100, Rasmus Villemoes wrote:
> On 2018-02-21 00:55, Joe Perches wrote:
> > On Tue, 2018-02-20 at 23:43 +0200, Andy Shevchenko wrote:
> > > There are users which print time and date represented by content
> > > of
> > > struct rtc_time in human readable format.
> > > 
> > > Instead of open coding that each time introduce %ptR[dt][rv]
> > > specifier.
> > > 
> > > Note, users have to select PRINTK_PEXT_TIMEDATE option in a
> > > Kconfig.
> > 
> > Not sure this is a great option.
> > Not just the name, the need to select it.
> 
> Bikeshedding first: If you do keep the config option, please use
> PRINTF,
> not PRINTK - vsprintf can be and is used by lots of code other than
> printk.

OK.

> Well, on the one hand, I like to reduce the size of the kernel when
> possible and ideally make all new functionality guarded by config
> options, but OTOH, how much does compiling out the datetime formatters
> really save?

https://lists.01.org/pipermail/kbuild-all/2017-June/034950.html

I understand that half a year time allows us to increase kernel text
size by 750+ bytes unconditionally.

I would really like to not use any option.

>  Also, I agree with Joe's concern about the need to select
> it.

So, what exactly you are proposing?

>  Maybe if we had a gcc plugin that did %pFOO validation it could also
> warn about %pBAR being used without a corresponding config option
> being
> set. But we don't have that currently...

We have not, so, it's out of scope. If it's a big impediment, then I'm
not the guy who will do the job.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
  2018-02-21  9:33   ` Geert Uytterhoeven
@ 2018-02-21 14:02       ` Andy Shevchenko
  0 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-21 14:02 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	Linux Kernel Mailing List, Alessandro Zummo, Alexandre Belloni,
	linux-rtc, Arnd Bergmann, Joe Perches, Mark Salyzyn,
	Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Guan Xuetao,
	Ingo Molnar, Jason Wessel, Jonathan Corbet, Jonathan Hunter,
	Krzysztof Kozlowski, Rafael J. Wysocki, Thierry Reding

On Wed, 2018-02-21 at 10:33 +0100, Geert Uytterhoeven wrote:
> Hi Andy,
> 
> On Tue, Feb 20, 2018 at 10:43 PM, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > There are users which print time and date represented by content of
> > struct rtc_time in human readable format.
> > 
> > Instead of open coding that each time introduce %ptR[dt][rv]
> > specifier.
> 
> Thanks for your patch!
> 
> > Note, users have to select PRINTK_PEXT_TIMEDATE option in a Kconfig.
> 
> Is it worthwhile making this an option?

People were complaining before

https://lists.01.org/pipermail/kbuild-all/2017-June/034950.html

> > --- a/Documentation/core-api/printk-formats.rst
> > +++ b/Documentation/core-api/printk-formats.rst
> > @@ -412,6 +412,37 @@ Examples::
> > 
> >  Passed by reference.
> > 
> > +Time and date
> > +-------------
> > +
> > +::
> > +
> > +       %pt[R]          YYYY-mm-dd HH:MM:SS
> > +       %pt[R]d         YYYY-mm-dd
> > +       %pt[R]t         HH:MM:SS
> 
> [R] suggests the "R" is optional?
> But if it's missing, it prints the hex pointer value?

Yes.

> > +       %pt[R][dt]
> 
> What's the purpose of this?

A place holder to extend.

> > +
> > +  R for struct rtc_time
> > +
> > +Note, users have to select PRINTK_PEXT_TIMEDATE option in a
> > Kconfig.
> > +
> > +struct rtc_time
> > +~~~~~~~~~~~~~~~
> > +
> > +::
> > +
> > +       %ptR[dt][rv]
> 
> What's the purpose of this paragraph, compared to the previous one?

This is first batch to make it working for struct rtc_time. We have
several users (and I have some local patches WIP) to print time64_t /
timespec64 which would use different letters and paragraphs to explain.

I could remove it and return like it was in v1 (with the exception for
new R letter added).

TBH, I don't see much consensus among developers on this topic.
I wouldn't like to send a new version until it would be a consensus.

> > +static noinline_for_stack
> > +char *date_str(char *buf, char *end, const struct rtc_time *tm,
> > bool v, bool r)
> > +{
> > +       int year = tm->tm_year + (r ? 0 : 1900);
> > +       int mon = tm->tm_mon + (r ? 0 : 1);
> > +
> > +       if (unlikely(v && (unsigned int)tm->tm_year > 200))
> > +               buf = string(buf, end, "****", default_str_spec);
> > +       else
> > +               buf = number(buf, end, year, default_dec04_spec);
> > +
> > +       if (buf < end)
> > +               *buf = '-';
> 
> Instead of all these checks to avoid overflowing the passed buffer, it
> may be simpler to format everything in a fixed-size buffer on the
> stack,
> and copy whatever will fit in the target buffer at the end.

I dropped that idea since the most heavier call is number().
We still need to do several of them one way or the other.

So, I really don't see much benefit of doing your way.

> > +static noinline_for_stack
> > +char *rtc_str(char *buf, char *end, const struct rtc_time *tm,
> > const char *fmt)
> > +{
> > +       bool have_t = true, have_d = true;
> > +       bool validate = false;
> > +       bool raw = false;
> > +       int count = 1;
> > +       bool found;
> > +
> > +       switch (fmt[++count]) {
> > +       case 'd':
> > +               have_t = false;
> > +               break;
> > +       case 't':
> > +               have_d = false;
> > +               break;
> > +       }
> > +
> > +       /* No %pt[dt] supplied */
> > +       if (have_d && have_t)
> > +               --count;
> 
> First increment count, then rollback.
> What about:
> 
>     switch (fmt[count]) {
>     case 'd':
>             have_t = false;
>             count++;
>             break;
>     case 't':
>             have_d = false;
>             count++;
>             break;
>     }

Or simple:

 default:
  --count;
  break;

?

I really need to come up with the next pile for time64_t which I suppose
will require rethinking of format parsing and printing functions here.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
@ 2018-02-21 14:02       ` Andy Shevchenko
  0 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-21 14:02 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	Linux Kernel Mailing List, Alessandro Zummo, Alexandre Belloni,
	linux-rtc, Arnd Bergmann, Joe Perches, Mark Salyzyn,
	Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Guan Xuetao,
	Ingo Molnar, Jason Wessel, Jonathan Corbet, Jonathan Hunter,
	Krzysztof Kozlowski, Rafael J. Wysocki, Thierry Reding

On Wed, 2018-02-21 at 10:33 +0100, Geert Uytterhoeven wrote:
> Hi Andy,
> 
> On Tue, Feb 20, 2018 at 10:43 PM, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > There are users which print time and date represented by content of
> > struct rtc_time in human readable format.
> > 
> > Instead of open coding that each time introduce %ptR[dt][rv]
> > specifier.
> 
> Thanks for your patch!
> 
> > Note, users have to select PRINTK_PEXT_TIMEDATE option in a Kconfig.
> 
> Is it worthwhile making this an option?

People were complaining before

https://lists.01.org/pipermail/kbuild-all/2017-June/034950.html

> > --- a/Documentation/core-api/printk-formats.rst
> > +++ b/Documentation/core-api/printk-formats.rst
> > @@ -412,6 +412,37 @@ Examples::
> > 
> >  Passed by reference.
> > 
> > +Time and date
> > +-------------
> > +
> > +::
> > +
> > +       %pt[R]          YYYY-mm-dd HH:MM:SS
> > +       %pt[R]d         YYYY-mm-dd
> > +       %pt[R]t         HH:MM:SS
> 
> [R] suggests the "R" is optional?
> But if it's missing, it prints the hex pointer value?

Yes.

> > +       %pt[R][dt]
> 
> What's the purpose of this?

A place holder to extend.

> > +
> > +  R for struct rtc_time
> > +
> > +Note, users have to select PRINTK_PEXT_TIMEDATE option in a
> > Kconfig.
> > +
> > +struct rtc_time
> > +~~~~~~~~~~~~~~~
> > +
> > +::
> > +
> > +       %ptR[dt][rv]
> 
> What's the purpose of this paragraph, compared to the previous one?

This is first batch to make it working for struct rtc_time. We have
several users (and I have some local patches WIP) to print time64_t /
timespec64 which would use different letters and paragraphs to explain.

I could remove it and return like it was in v1 (with the exception for
new R letter added).

TBH, I don't see much consensus among developers on this topic.
I wouldn't like to send a new version until it would be a consensus.

> > +static noinline_for_stack
> > +char *date_str(char *buf, char *end, const struct rtc_time *tm,
> > bool v, bool r)
> > +{
> > +       int year = tm->tm_year + (r ? 0 : 1900);
> > +       int mon = tm->tm_mon + (r ? 0 : 1);
> > +
> > +       if (unlikely(v && (unsigned int)tm->tm_year > 200))
> > +               buf = string(buf, end, "****", default_str_spec);
> > +       else
> > +               buf = number(buf, end, year, default_dec04_spec);
> > +
> > +       if (buf < end)
> > +               *buf = '-';
> 
> Instead of all these checks to avoid overflowing the passed buffer, it
> may be simpler to format everything in a fixed-size buffer on the
> stack,
> and copy whatever will fit in the target buffer at the end.

I dropped that idea since the most heavier call is number().
We still need to do several of them one way or the other.

So, I really don't see much benefit of doing your way.

> > +static noinline_for_stack
> > +char *rtc_str(char *buf, char *end, const struct rtc_time *tm,
> > const char *fmt)
> > +{
> > +       bool have_t = true, have_d = true;
> > +       bool validate = false;
> > +       bool raw = false;
> > +       int count = 1;
> > +       bool found;
> > +
> > +       switch (fmt[++count]) {
> > +       case 'd':
> > +               have_t = false;
> > +               break;
> > +       case 't':
> > +               have_d = false;
> > +               break;
> > +       }
> > +
> > +       /* No %pt[dt] supplied */
> > +       if (have_d && have_t)
> > +               --count;
> 
> First increment count, then rollback.
> What about:
> 
>     switch (fmt[count]) {
>     case 'd':
>             have_t = false;
>             count++;
>             break;
>     case 't':
>             have_d = false;
>             count++;
>             break;
>     }

Or simple:

 default:
  --count;
  break;

?

I really need to come up with the next pile for time64_t which I suppose
will require rethinking of format parsing and printing functions here.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 20/21] mk68/mac: Switch to use %ptR
  2018-02-21  9:38   ` Geert Uytterhoeven
@ 2018-02-21 14:04     ` Andy Shevchenko
  0 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-21 14:04 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	Linux Kernel Mailing List, Alessandro Zummo, Alexandre Belloni,
	linux-rtc, Arnd Bergmann, Joe Perches, Mark Salyzyn

On Wed, 2018-02-21 at 10:38 +0100, Geert Uytterhoeven wrote:

> > +       select PRINTK_PEXT_TIMEDATE
> 
> Yeah, now you have to track whatever code uses the new %p extension...

I don't like this. People had an opinion that 750+ bytes is way too much
for tiny kernel configuration.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
  2018-02-21 14:02       ` Andy Shevchenko
@ 2018-02-21 14:05         ` Andy Shevchenko
  -1 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-21 14:05 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	Linux Kernel Mailing List, Alessandro Zummo, Alexandre Belloni,
	linux-rtc, Arnd Bergmann, Joe Perches, Mark Salyzyn,
	Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Guan Xuetao,
	Ingo Molnar, Jason Wessel, Jonathan Corbet, Jonathan Hunter,
	Krzysztof Kozlowski, Rafael J. Wysocki, Thierry Reding

> TBH, I don't see much consensus among developers on this topic.
> I wouldn't like to send a new version until it would be a consensus.

I would love to see the comments followed by an agreement from majority
of people who are in Cc list here.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
@ 2018-02-21 14:05         ` Andy Shevchenko
  0 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-21 14:05 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Rasmus Villemoes, Greg Kroah-Hartman, Andrew Morton,
	Linux Kernel Mailing List, Alessandro Zummo, Alexandre Belloni,
	linux-rtc, Arnd Bergmann, Joe Perches, Mark Salyzyn,
	Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Guan Xuetao,
	Ingo Molnar, Jason Wessel, Jonathan Corbet, Jonathan Hunter,
	Krzysztof Kozlowski, Rafael J. Wysocki, Thierry Reding

> TBH, I don't see much consensus among developers on this topic.
> I wouldn't like to send a new version until it would be a consensus.

I would love to see the comments followed by an agreement from majority
of people who are in Cc list here.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
  2018-02-21 13:23         ` Andy Shevchenko
  (?)
@ 2018-02-21 14:19         ` Geert Uytterhoeven
  2018-02-22 12:46             ` Andy Shevchenko
  -1 siblings, 1 reply; 41+ messages in thread
From: Geert Uytterhoeven @ 2018-02-21 14:19 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Rasmus Villemoes, Joe Perches, Greg Kroah-Hartman, Andrew Morton,
	Linux Kernel Mailing List, Alessandro Zummo, Alexandre Belloni,
	linux-rtc, Arnd Bergmann, Mark Salyzyn,
	Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Guan Xuetao,
	Ingo Molnar, Jason Wessel, Jonathan Corbet, Jonathan Hunter,
	Krzysztof Kozlowski, Rafael J. Wysocki, Thierry Reding

On Wed, Feb 21, 2018 at 2:23 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Wed, 2018-02-21 at 08:38 +0100, Rasmus Villemoes wrote:
>> On 2018-02-21 00:55, Joe Perches wrote:
>> > On Tue, 2018-02-20 at 23:43 +0200, Andy Shevchenko wrote:
>> > > There are users which print time and date represented by content
>> > > of
>> > > struct rtc_time in human readable format.
>> > >
>> > > Instead of open coding that each time introduce %ptR[dt][rv]
>> > > specifier.
>> > >
>> > > Note, users have to select PRINTK_PEXT_TIMEDATE option in a
>> > > Kconfig.
>> >
>> > Not sure this is a great option.
>> > Not just the name, the need to select it.
>>
>> Bikeshedding first: If you do keep the config option, please use
>> PRINTF,
>> not PRINTK - vsprintf can be and is used by lots of code other than
>> printk.
>
> OK.
>
>> Well, on the one hand, I like to reduce the size of the kernel when
>> possible and ideally make all new functionality guarded by config
>> options, but OTOH, how much does compiling out the datetime formatters
>> really save?
>
> https://lists.01.org/pipermail/kbuild-all/2017-June/034950.html
>
> I understand that half a year time allows us to increase kernel text
> size by 750+ bytes unconditionally.
>
> I would really like to not use any option.

Agreed.

FTR, growth of my atari_defconfig kernel between v4.7 and v4.15:

add/remove: 351/155 grow/shrink: 691/429 up/down: 63095/-38665 (24430)
add/remove: 394/156 grow/shrink: 595/709 up/down: 61173/-31092 (30081)
add/remove: 1315/711 grow/shrink: 1269/442 up/down: 172871/-92075 (80796)
add/remove: 525/266 grow/shrink: 914/510 up/down: 116115/-46240 (69875)
add/remove: 443/222 grow/shrink: 906/456 up/down: 77807/-40657 (37150)
add/remove: 536/296 grow/shrink: 1043/652 up/down: 97366/-65459 (31907)
add/remove: 413/176 grow/shrink: 711/479 up/down: 75678/-41356 (34322)
add/remove: 311/145 grow/shrink: 898/438 up/down: 51655/-26851 (24804)

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
  2018-02-21 14:19         ` Geert Uytterhoeven
@ 2018-02-22 12:46             ` Andy Shevchenko
  0 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-22 12:46 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Rasmus Villemoes, Joe Perches, Greg Kroah-Hartman, Andrew Morton,
	Linux Kernel Mailing List, Alessandro Zummo, Alexandre Belloni,
	linux-rtc, Arnd Bergmann, Mark Salyzyn,
	Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Guan Xuetao,
	Ingo Molnar, Jason Wessel, Jonathan Corbet, Jonathan Hunter,
	Krzysztof Kozlowski, Rafael J. Wysocki, Thierry Reding

On Wed, 2018-02-21 at 15:19 +0100, Geert Uytterhoeven wrote:
> On Wed, Feb 21, 2018 at 2:23 PM, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Wed, 2018-02-21 at 08:38 +0100, Rasmus Villemoes wrote:
> > > On 2018-02-21 00:55, Joe Perches wrote:

> > > Well, on the one hand, I like to reduce the size of the kernel
> > > when
> > > possible and ideally make all new functionality guarded by config
> > > options, but OTOH, how much does compiling out the datetime
> > > formatters
> > > really save?
> > 
> > https://lists.01.org/pipermail/kbuild-all/2017-June/034950.html
> > 
> > I understand that half a year time allows us to increase kernel text
> > size by 750+ bytes unconditionally.
> > 
> > I would really like to not use any option.
> 
> Agreed.
> 
> FTR, growth of my atari_defconfig kernel between v4.7 and v4.15:
> 
> add/remove: 351/155 grow/shrink: 691/429 up/down: 63095/-38665 (24430)
> add/remove: 394/156 grow/shrink: 595/709 up/down: 61173/-31092 (30081)
> add/remove: 1315/711 grow/shrink: 1269/442 up/down: 172871/-92075
> (80796)
> add/remove: 525/266 grow/shrink: 914/510 up/down: 116115/-46240
> (69875)
> add/remove: 443/222 grow/shrink: 906/456 up/down: 77807/-40657 (37150)
> add/remove: 536/296 grow/shrink: 1043/652 up/down: 97366/-65459
> (31907)
> add/remove: 413/176 grow/shrink: 711/479 up/down: 75678/-41356 (34322)
> add/remove: 311/145 grow/shrink: 898/438 up/down: 51655/-26851 (24804)

The concern was emitted from one who cares about tiny config, i.e.
i386_tiny_defconfig.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
@ 2018-02-22 12:46             ` Andy Shevchenko
  0 siblings, 0 replies; 41+ messages in thread
From: Andy Shevchenko @ 2018-02-22 12:46 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Rasmus Villemoes, Joe Perches, Greg Kroah-Hartman, Andrew Morton,
	Linux Kernel Mailing List, Alessandro Zummo, Alexandre Belloni,
	linux-rtc, Arnd Bergmann, Mark Salyzyn,
	Bartlomiej Zolnierkiewicz, Dmitry Torokhov, Guan Xuetao,
	Ingo Molnar, Jason Wessel, Jonathan Corbet, Jonathan Hunter,
	Krzysztof Kozlowski, Rafael J. Wysocki, Thierry Reding

On Wed, 2018-02-21 at 15:19 +0100, Geert Uytterhoeven wrote:
> On Wed, Feb 21, 2018 at 2:23 PM, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Wed, 2018-02-21 at 08:38 +0100, Rasmus Villemoes wrote:
> > > On 2018-02-21 00:55, Joe Perches wrote:

> > > Well, on the one hand, I like to reduce the size of the kernel
> > > when
> > > possible and ideally make all new functionality guarded by config
> > > options, but OTOH, how much does compiling out the datetime
> > > formatters
> > > really save?
> > 
> > https://lists.01.org/pipermail/kbuild-all/2017-June/034950.html
> > 
> > I understand that half a year time allows us to increase kernel text
> > size by 750+ bytes unconditionally.
> > 
> > I would really like to not use any option.
> 
> Agreed.
> 
> FTR, growth of my atari_defconfig kernel between v4.7 and v4.15:
> 
> add/remove: 351/155 grow/shrink: 691/429 up/down: 63095/-38665 (24430)
> add/remove: 394/156 grow/shrink: 595/709 up/down: 61173/-31092 (30081)
> add/remove: 1315/711 grow/shrink: 1269/442 up/down: 172871/-92075
> (80796)
> add/remove: 525/266 grow/shrink: 914/510 up/down: 116115/-46240
> (69875)
> add/remove: 443/222 grow/shrink: 906/456 up/down: 77807/-40657 (37150)
> add/remove: 536/296 grow/shrink: 1043/652 up/down: 97366/-65459
> (31907)
> add/remove: 413/176 grow/shrink: 711/479 up/down: 75678/-41356 (34322)
> add/remove: 311/145 grow/shrink: 898/438 up/down: 51655/-26851 (24804)

The concern was emitted from one who cares about tiny config, i.e.
i386_tiny_defconfig.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt
  2018-02-21 14:05         ` Andy Shevchenko
  (?)
@ 2018-03-14 16:54         ` Dmitry Torokhov
  -1 siblings, 0 replies; 41+ messages in thread
From: Dmitry Torokhov @ 2018-03-14 16:54 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Geert Uytterhoeven, Rasmus Villemoes, Greg Kroah-Hartman,
	Andrew Morton, Linux Kernel Mailing List, Alessandro Zummo,
	Alexandre Belloni, linux-rtc, Arnd Bergmann, Joe Perches,
	Mark Salyzyn, Bartlomiej Zolnierkiewicz, Guan Xuetao,
	Ingo Molnar, Jason Wessel, Jonathan Corbet, Jonathan Hunter,
	Krzysztof Kozlowski, Rafael J. Wysocki, Thierry Reding

On Wed, Feb 21, 2018 at 04:05:53PM +0200, Andy Shevchenko wrote:
> > TBH, I don't see much consensus among developers on this topic.
> > I wouldn't like to send a new version until it would be a consensus.
> 
> I would love to see the comments followed by an agreement from majority
> of people who are in Cc list here.

Not sure why I am on the CC list, but if we add it at all I do not think
this should be guarded by a config option. Otherwise let's add options
for %d and %s as well.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2018-03-14 16:54 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-20 21:43 [PATCH v2 00/21] lib, rtc: Print rtc_time via %ptR[dt][rv] Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 01/21] lib/vsprintf: Print time and date in human readable format via %pt Andy Shevchenko
2018-02-20 23:55   ` Joe Perches
2018-02-20 23:55     ` Joe Perches
2018-02-21  7:38     ` Rasmus Villemoes
2018-02-21 13:23       ` Andy Shevchenko
2018-02-21 13:23         ` Andy Shevchenko
2018-02-21 14:19         ` Geert Uytterhoeven
2018-02-22 12:46           ` Andy Shevchenko
2018-02-22 12:46             ` Andy Shevchenko
2018-02-21  9:16     ` Alexandre Belloni
2018-02-21 13:19     ` Andy Shevchenko
2018-02-21 13:19       ` Andy Shevchenko
2018-02-21  9:33   ` Geert Uytterhoeven
2018-02-21 14:02     ` Andy Shevchenko
2018-02-21 14:02       ` Andy Shevchenko
2018-02-21 14:05       ` Andy Shevchenko
2018-02-21 14:05         ` Andy Shevchenko
2018-03-14 16:54         ` Dmitry Torokhov
2018-02-20 21:43 ` [PATCH v2 02/21] rtc: Switch to use %ptR Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 03/21] rtc: at91rm9200: " Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 04/21] rtc: at91sam9: " Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 05/21] rtc: m41t80: " Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 06/21] rtc: m48t59: " Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 07/21] rtc: mcp795: " Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 08/21] rtc: pcf50633: " Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 09/21] rtc: pic32: " Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 10/21] rtc: pm8xxx: " Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 11/21] rtc: puv3: " Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 12/21] rtc: rk808: " Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 13/21] rtc: rx6110: " Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 14/21] rtc: rx8025: " Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 15/21] rtc: s3c: " Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 16/21] rtc: s5m: " Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 17/21] rtc: tegra: " Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 18/21] ds1302: " Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 19/21] Input: hp_sdc_rtc - " Andy Shevchenko
2018-02-20 21:43 ` [PATCH v2 20/21] mk68/mac: " Andy Shevchenko
2018-02-21  9:38   ` Geert Uytterhoeven
2018-02-21 14:04     ` Andy Shevchenko
2018-02-20 21:44 ` [PATCH v2 21/21] PM: " Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.