linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] lib/vsprintf: Introduce %ptT for time64_t
@ 2019-10-01 13:47 Andy Shevchenko
  2019-10-01 13:47 ` [PATCH v2 1/4] lib/vsprintf: Print time64_t in human readable format Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Andy Shevchenko @ 2019-10-01 13:47 UTC (permalink / raw)
  To: linux-kernel, Greg Kroah-Hartman, Hans Verkuil, Jonathan Corbet,
	Thierry Reding, Jonathan Hunter, Alexandre Belloni, John Stultz
  Cc: Andy Shevchenko

It is a logical continuation of previously applied %ptR for struct rtc_time.
We have few users of time64_t that would like to print it.

In v2:
- drop #ifdef CONFIG_RTC_LIB with time64_to_rtc_time() altogether
  (Petr, Alexandre)
- update default error path message along with test case for it
- add Hans' Ack for patch 3

Andy Shevchenko (4):
  lib/vsprintf: Print time64_t in human readable format
  ARM: bcm2835: Switch to use %ptT
  [media] usb: pulse8-cec: Switch to use %ptT
  usb: host: xhci-tegra: Switch to use %ptT

 Documentation/core-api/printk-formats.rst | 22 ++++++++--------
 drivers/firmware/raspberrypi.c            | 12 +++------
 drivers/media/usb/pulse8-cec/pulse8-cec.c |  6 +----
 drivers/usb/host/xhci-tegra.c             |  6 +----
 lib/test_printf.c                         | 13 +++++++---
 lib/vsprintf.c                            | 31 +++++++++++++++++++++--
 6 files changed, 56 insertions(+), 34 deletions(-)

-- 
2.23.0


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

* [PATCH v2 1/4] lib/vsprintf: Print time64_t in human readable format
  2019-10-01 13:47 [PATCH v2 0/4] lib/vsprintf: Introduce %ptT for time64_t Andy Shevchenko
@ 2019-10-01 13:47 ` Andy Shevchenko
  2019-10-01 19:31   ` Alexandre Belloni
  2019-10-01 13:47 ` [PATCH v2 2/4] ARM: bcm2835: Switch to use %ptT Andy Shevchenko
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2019-10-01 13:47 UTC (permalink / raw)
  To: linux-kernel, Greg Kroah-Hartman, Hans Verkuil, Jonathan Corbet,
	Thierry Reding, Jonathan Hunter, Alexandre Belloni, John Stultz
  Cc: Andy Shevchenko, Mathias Nyman

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

Instead of open coding that each time introduce %ptT[dt][r] specifier.

Few test cases for %ptT specifier has been added as well.

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Mathias Nyman <mathias.nyman@intel.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 Documentation/core-api/printk-formats.rst | 22 ++++++++--------
 lib/test_printf.c                         | 13 +++++++---
 lib/vsprintf.c                            | 31 +++++++++++++++++++++--
 3 files changed, 51 insertions(+), 15 deletions(-)

diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
index ecbebf4ca8e7..83f452e45f3f 100644
--- a/Documentation/core-api/printk-formats.rst
+++ b/Documentation/core-api/printk-formats.rst
@@ -428,21 +428,23 @@ Examples::
 
 Passed by reference.
 
-Time and date (struct rtc_time)
--------------------------------
+Time and date
+-------------
 
 ::
 
-	%ptR		YYYY-mm-ddTHH:MM:SS
-	%ptRd		YYYY-mm-dd
-	%ptRt		HH:MM:SS
-	%ptR[dt][r]
+	%pt[RT]			YYYY-mm-ddTHH:MM:SS
+	%pt[RT]d		YYYY-mm-dd
+	%pt[RT]t		HH:MM:SS
+	%pt[RT][dt][r]
 
-For printing date and time as represented by struct rtc_time structure in
-human readable format.
+For printing date and time as represented by
+	R  struct rtc_time structure
+	T  time64_t type
+in human readable format.
 
-By default year will be incremented by 1900 and month by 1. Use %ptRr (raw)
-to suppress this behaviour.
+By default year will be incremented by 1900 and month by 1.
+Use %pt[RT]r (raw) to suppress this behaviour.
 
 Passed by reference.
 
diff --git a/lib/test_printf.c b/lib/test_printf.c
index 5d94cbff2120..16fb668685dd 100644
--- a/lib/test_printf.c
+++ b/lib/test_printf.c
@@ -476,7 +476,7 @@ struct_va_format(void)
 }
 
 static void __init
-struct_rtc_time(void)
+time_and_date(void)
 {
 	/* 1543210543 */
 	const struct rtc_time tm = {
@@ -487,14 +487,21 @@ struct_rtc_time(void)
 		.tm_mon = 10,
 		.tm_year = 118,
 	};
+	/* 2019-01-04T15:32:23 */
+	time64_t t = 1546615943;
 
-	test("(%ptR?)", "%pt", &tm);
+	test("(%pt?)", "%pt", &tm);
 	test("2018-11-26T05:35:43", "%ptR", &tm);
 	test("0118-10-26T05:35:43", "%ptRr", &tm);
 	test("05:35:43|2018-11-26", "%ptRt|%ptRd", &tm, &tm);
 	test("05:35:43|0118-10-26", "%ptRtr|%ptRdr", &tm, &tm);
 	test("05:35:43|2018-11-26", "%ptRttr|%ptRdtr", &tm, &tm);
 	test("05:35:43 tr|2018-11-26 tr", "%ptRt tr|%ptRd tr", &tm, &tm);
+
+	test("2019-01-04T15:32:23", "%ptT", &t);
+	test("0119-00-04T15:32:23", "%ptTr", &t);
+	test("15:32:23|2019-01-04", "%ptTt|%ptTd", &t, &t);
+	test("15:32:23|0119-00-04", "%ptTtr|%ptTdr", &t, &t);
 }
 
 static void __init
@@ -610,7 +617,7 @@ test_pointer(void)
 	uuid();
 	dentry();
 	struct_va_format();
-	struct_rtc_time();
+	time_and_date();
 	struct_clk();
 	bitmap();
 	netdev_features();
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index e78017a3e1bd..e4bc380deb62 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -33,6 +33,7 @@
 #include <linux/dcache.h>
 #include <linux/cred.h>
 #include <linux/rtc.h>
+#include <linux/time.h>
 #include <linux/uuid.h>
 #include <linux/of.h>
 #include <net/addrconf.h>
@@ -1780,6 +1781,29 @@ char *rtc_str(char *buf, char *end, const struct rtc_time *tm,
 	return buf;
 }
 
+static noinline_for_stack
+char *time64_str(char *buf, char *end, const time64_t time,
+		 struct printf_spec spec, const char *fmt)
+{
+	struct rtc_time rtc_time;
+	struct tm tm;
+
+	time64_to_tm(time, 0, &tm);
+
+	rtc_time.tm_sec = tm.tm_sec;
+	rtc_time.tm_min = tm.tm_min;
+	rtc_time.tm_hour = tm.tm_hour;
+	rtc_time.tm_mday = tm.tm_mday;
+	rtc_time.tm_mon = tm.tm_mon;
+	rtc_time.tm_year = tm.tm_year;
+	rtc_time.tm_wday = tm.tm_wday;
+	rtc_time.tm_yday = tm.tm_yday;
+
+	rtc_time.tm_isdst = 0;
+
+	return rtc_str(buf, end, &rtc_time, spec, fmt);
+}
+
 static noinline_for_stack
 char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec,
 		    const char *fmt)
@@ -1787,8 +1811,10 @@ char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec,
 	switch (fmt[1]) {
 	case 'R':
 		return rtc_str(buf, end, (const struct rtc_time *)ptr, spec, fmt);
+	case 'T':
+		return time64_str(buf, end, *(const time64_t *)ptr, spec, fmt);
 	default:
-		return error_string(buf, end, "(%ptR?)", spec);
+		return error_string(buf, end, "(%pt?)", spec);
 	}
 }
 
@@ -2088,8 +2114,9 @@ static char *kobject_string(char *buf, char *end, void *ptr,
  * - '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][r]' For time and date as represented:
+ * - 't[RT][dt][r]' For time and date as represented by:
  *      R    struct rtc_time
+ *      T    time64_t
  * - '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
-- 
2.23.0


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

* [PATCH v2 2/4] ARM: bcm2835: Switch to use %ptT
  2019-10-01 13:47 [PATCH v2 0/4] lib/vsprintf: Introduce %ptT for time64_t Andy Shevchenko
  2019-10-01 13:47 ` [PATCH v2 1/4] lib/vsprintf: Print time64_t in human readable format Andy Shevchenko
@ 2019-10-01 13:47 ` Andy Shevchenko
  2019-10-01 13:47 ` [PATCH v2 3/4] [media] usb: pulse8-cec: " Andy Shevchenko
  2019-10-01 13:47 ` [PATCH v2 4/4] usb: host: xhci-tegra: " Andy Shevchenko
  3 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2019-10-01 13:47 UTC (permalink / raw)
  To: linux-kernel, Greg Kroah-Hartman, Hans Verkuil, Jonathan Corbet,
	Thierry Reding, Jonathan Hunter, Alexandre Belloni, John Stultz
  Cc: Andy Shevchenko

Use %ptT instead of open coded variant to print content of
time64_t type in human readable format.

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

diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
index da26a584dca0..a3e85186f8e6 100644
--- a/drivers/firmware/raspberrypi.c
+++ b/drivers/firmware/raspberrypi.c
@@ -182,16 +182,10 @@ rpi_firmware_print_firmware_revision(struct rpi_firmware *fw)
 					RPI_FIRMWARE_GET_FIRMWARE_REVISION,
 					&packet, sizeof(packet));
 
-	if (ret == 0) {
-		struct tm tm;
-
-		time64_to_tm(packet, 0, &tm);
+	if (ret)
+		return;
 
-		dev_info(fw->cl.dev,
-			 "Attached to firmware from %04ld-%02d-%02d %02d:%02d\n",
-			 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
-			 tm.tm_hour, tm.tm_min);
-	}
+	dev_info(fw->cl.dev, "Attached to firmware from %ptT\n", &packet);
 }
 
 static void
-- 
2.23.0


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

* [PATCH v2 3/4] [media] usb: pulse8-cec: Switch to use %ptT
  2019-10-01 13:47 [PATCH v2 0/4] lib/vsprintf: Introduce %ptT for time64_t Andy Shevchenko
  2019-10-01 13:47 ` [PATCH v2 1/4] lib/vsprintf: Print time64_t in human readable format Andy Shevchenko
  2019-10-01 13:47 ` [PATCH v2 2/4] ARM: bcm2835: Switch to use %ptT Andy Shevchenko
@ 2019-10-01 13:47 ` Andy Shevchenko
  2019-10-01 13:47 ` [PATCH v2 4/4] usb: host: xhci-tegra: " Andy Shevchenko
  3 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2019-10-01 13:47 UTC (permalink / raw)
  To: linux-kernel, Greg Kroah-Hartman, Hans Verkuil, Jonathan Corbet,
	Thierry Reding, Jonathan Hunter, Alexandre Belloni, John Stultz
  Cc: Andy Shevchenko, Hans Verkuil

Use %ptT instead of open coded variant to print content of
time64_t type in human readable format.

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/media/usb/pulse8-cec/pulse8-cec.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/media/usb/pulse8-cec/pulse8-cec.c b/drivers/media/usb/pulse8-cec/pulse8-cec.c
index ac88ade94cda..4299cf924f21 100644
--- a/drivers/media/usb/pulse8-cec/pulse8-cec.c
+++ b/drivers/media/usb/pulse8-cec/pulse8-cec.c
@@ -323,7 +323,6 @@ static int pulse8_setup(struct pulse8 *pulse8, struct serio *serio,
 	u8 *data = pulse8->data + 1;
 	u8 cmd[2];
 	int err;
-	struct tm tm;
 	time64_t date;
 
 	pulse8->vers = 0;
@@ -344,10 +343,7 @@ static int pulse8_setup(struct pulse8 *pulse8, struct serio *serio,
 	if (err)
 		return err;
 	date = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
-	time64_to_tm(date, 0, &tm);
-	dev_info(pulse8->dev, "Firmware build date %04ld.%02d.%02d %02d:%02d:%02d\n",
-		 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
-		 tm.tm_hour, tm.tm_min, tm.tm_sec);
+	dev_info(pulse8->dev, "Firmware build date %ptT\n", &date);
 
 	dev_dbg(pulse8->dev, "Persistent config:\n");
 	cmd[0] = MSGCODE_GET_AUTO_ENABLED;
-- 
2.23.0


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

* [PATCH v2 4/4] usb: host: xhci-tegra: Switch to use %ptT
  2019-10-01 13:47 [PATCH v2 0/4] lib/vsprintf: Introduce %ptT for time64_t Andy Shevchenko
                   ` (2 preceding siblings ...)
  2019-10-01 13:47 ` [PATCH v2 3/4] [media] usb: pulse8-cec: " Andy Shevchenko
@ 2019-10-01 13:47 ` Andy Shevchenko
  2019-10-02 11:39   ` Thierry Reding
  3 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2019-10-01 13:47 UTC (permalink / raw)
  To: linux-kernel, Greg Kroah-Hartman, Hans Verkuil, Jonathan Corbet,
	Thierry Reding, Jonathan Hunter, Alexandre Belloni, John Stultz
  Cc: Andy Shevchenko

Use %ptT instead of open coded variant to print content of
time64_t type 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/usb/host/xhci-tegra.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
index 2ff7c911fbd0..c1bf2ad1474d 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -802,7 +802,6 @@ static int tegra_xusb_load_firmware(struct tegra_xusb *tegra)
 	const struct firmware *fw;
 	unsigned long timeout;
 	time64_t timestamp;
-	struct tm time;
 	u64 address;
 	u32 value;
 	int err;
@@ -907,11 +906,8 @@ static int tegra_xusb_load_firmware(struct tegra_xusb *tegra)
 	}
 
 	timestamp = le32_to_cpu(header->fwimg_created_time);
-	time64_to_tm(timestamp, 0, &time);
 
-	dev_info(dev, "Firmware timestamp: %ld-%02d-%02d %02d:%02d:%02d UTC\n",
-		 time.tm_year + 1900, time.tm_mon + 1, time.tm_mday,
-		 time.tm_hour, time.tm_min, time.tm_sec);
+	dev_info(dev, "Firmware timestamp: %ptT UTC\n", &timestamp);
 
 	return 0;
 }
-- 
2.23.0


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

* Re: [PATCH v2 1/4] lib/vsprintf: Print time64_t in human readable format
  2019-10-01 13:47 ` [PATCH v2 1/4] lib/vsprintf: Print time64_t in human readable format Andy Shevchenko
@ 2019-10-01 19:31   ` Alexandre Belloni
  0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Belloni @ 2019-10-01 19:31 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-kernel, Greg Kroah-Hartman, Hans Verkuil, Jonathan Corbet,
	Thierry Reding, Jonathan Hunter, John Stultz, Mathias Nyman

On 01/10/2019 16:47:14+0300, Andy Shevchenko wrote:
> There are users which print time and date represented by content of
> time64_t type in human readable format.
> 
> Instead of open coding that each time introduce %ptT[dt][r] specifier.
> 
> Few test cases for %ptT specifier has been added as well.
> 
> Cc: Hans Verkuil <hverkuil@xs4all.nl>
> Cc: Mathias Nyman <mathias.nyman@intel.com>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Jonathan Hunter <jonathanh@nvidia.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
>  Documentation/core-api/printk-formats.rst | 22 ++++++++--------
>  lib/test_printf.c                         | 13 +++++++---
>  lib/vsprintf.c                            | 31 +++++++++++++++++++++--
>  3 files changed, 51 insertions(+), 15 deletions(-)
> 
> diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
> index ecbebf4ca8e7..83f452e45f3f 100644
> --- a/Documentation/core-api/printk-formats.rst
> +++ b/Documentation/core-api/printk-formats.rst
> @@ -428,21 +428,23 @@ Examples::
>  
>  Passed by reference.
>  
> -Time and date (struct rtc_time)
> --------------------------------
> +Time and date
> +-------------
>  
>  ::
>  
> -	%ptR		YYYY-mm-ddTHH:MM:SS
> -	%ptRd		YYYY-mm-dd
> -	%ptRt		HH:MM:SS
> -	%ptR[dt][r]
> +	%pt[RT]			YYYY-mm-ddTHH:MM:SS
> +	%pt[RT]d		YYYY-mm-dd
> +	%pt[RT]t		HH:MM:SS
> +	%pt[RT][dt][r]
>  
> -For printing date and time as represented by struct rtc_time structure in
> -human readable format.
> +For printing date and time as represented by
> +	R  struct rtc_time structure
> +	T  time64_t type
> +in human readable format.
>  
> -By default year will be incremented by 1900 and month by 1. Use %ptRr (raw)
> -to suppress this behaviour.
> +By default year will be incremented by 1900 and month by 1.
> +Use %pt[RT]r (raw) to suppress this behaviour.
>  
>  Passed by reference.
>  
> diff --git a/lib/test_printf.c b/lib/test_printf.c
> index 5d94cbff2120..16fb668685dd 100644
> --- a/lib/test_printf.c
> +++ b/lib/test_printf.c
> @@ -476,7 +476,7 @@ struct_va_format(void)
>  }
>  
>  static void __init
> -struct_rtc_time(void)
> +time_and_date(void)
>  {
>  	/* 1543210543 */
>  	const struct rtc_time tm = {
> @@ -487,14 +487,21 @@ struct_rtc_time(void)
>  		.tm_mon = 10,
>  		.tm_year = 118,
>  	};
> +	/* 2019-01-04T15:32:23 */
> +	time64_t t = 1546615943;
>  
> -	test("(%ptR?)", "%pt", &tm);
> +	test("(%pt?)", "%pt", &tm);
>  	test("2018-11-26T05:35:43", "%ptR", &tm);
>  	test("0118-10-26T05:35:43", "%ptRr", &tm);
>  	test("05:35:43|2018-11-26", "%ptRt|%ptRd", &tm, &tm);
>  	test("05:35:43|0118-10-26", "%ptRtr|%ptRdr", &tm, &tm);
>  	test("05:35:43|2018-11-26", "%ptRttr|%ptRdtr", &tm, &tm);
>  	test("05:35:43 tr|2018-11-26 tr", "%ptRt tr|%ptRd tr", &tm, &tm);
> +
> +	test("2019-01-04T15:32:23", "%ptT", &t);
> +	test("0119-00-04T15:32:23", "%ptTr", &t);
> +	test("15:32:23|2019-01-04", "%ptTt|%ptTd", &t, &t);
> +	test("15:32:23|0119-00-04", "%ptTtr|%ptTdr", &t, &t);
>  }
>  
>  static void __init
> @@ -610,7 +617,7 @@ test_pointer(void)
>  	uuid();
>  	dentry();
>  	struct_va_format();
> -	struct_rtc_time();
> +	time_and_date();
>  	struct_clk();
>  	bitmap();
>  	netdev_features();
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index e78017a3e1bd..e4bc380deb62 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -33,6 +33,7 @@
>  #include <linux/dcache.h>
>  #include <linux/cred.h>
>  #include <linux/rtc.h>
> +#include <linux/time.h>
>  #include <linux/uuid.h>
>  #include <linux/of.h>
>  #include <net/addrconf.h>
> @@ -1780,6 +1781,29 @@ char *rtc_str(char *buf, char *end, const struct rtc_time *tm,
>  	return buf;
>  }
>  
> +static noinline_for_stack
> +char *time64_str(char *buf, char *end, const time64_t time,
> +		 struct printf_spec spec, const char *fmt)
> +{
> +	struct rtc_time rtc_time;
> +	struct tm tm;
> +
> +	time64_to_tm(time, 0, &tm);
> +
> +	rtc_time.tm_sec = tm.tm_sec;
> +	rtc_time.tm_min = tm.tm_min;
> +	rtc_time.tm_hour = tm.tm_hour;
> +	rtc_time.tm_mday = tm.tm_mday;
> +	rtc_time.tm_mon = tm.tm_mon;
> +	rtc_time.tm_year = tm.tm_year;
> +	rtc_time.tm_wday = tm.tm_wday;
> +	rtc_time.tm_yday = tm.tm_yday;
> +
> +	rtc_time.tm_isdst = 0;
> +
> +	return rtc_str(buf, end, &rtc_time, spec, fmt);
> +}
> +
>  static noinline_for_stack
>  char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec,
>  		    const char *fmt)
> @@ -1787,8 +1811,10 @@ char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec,
>  	switch (fmt[1]) {
>  	case 'R':
>  		return rtc_str(buf, end, (const struct rtc_time *)ptr, spec, fmt);
> +	case 'T':
> +		return time64_str(buf, end, *(const time64_t *)ptr, spec, fmt);
>  	default:
> -		return error_string(buf, end, "(%ptR?)", spec);
> +		return error_string(buf, end, "(%pt?)", spec);
>  	}
>  }
>  
> @@ -2088,8 +2114,9 @@ static char *kobject_string(char *buf, char *end, void *ptr,
>   * - '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][r]' For time and date as represented:
> + * - 't[RT][dt][r]' For time and date as represented by:
>   *      R    struct rtc_time
> + *      T    time64_t
>   * - '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
> -- 
> 2.23.0
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH v2 4/4] usb: host: xhci-tegra: Switch to use %ptT
  2019-10-01 13:47 ` [PATCH v2 4/4] usb: host: xhci-tegra: " Andy Shevchenko
@ 2019-10-02 11:39   ` Thierry Reding
  2019-12-09 16:40     ` Andy Shevchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Thierry Reding @ 2019-10-02 11:39 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-kernel, Greg Kroah-Hartman, Hans Verkuil, Jonathan Corbet,
	Jonathan Hunter, Alexandre Belloni, John Stultz

[-- Attachment #1: Type: text/plain, Size: 1750 bytes --]

On Tue, Oct 01, 2019 at 04:47:17PM +0300, Andy Shevchenko wrote:
> Use %ptT instead of open coded variant to print content of
> time64_t type 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/usb/host/xhci-tegra.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
> index 2ff7c911fbd0..c1bf2ad1474d 100644
> --- a/drivers/usb/host/xhci-tegra.c
> +++ b/drivers/usb/host/xhci-tegra.c
> @@ -802,7 +802,6 @@ static int tegra_xusb_load_firmware(struct tegra_xusb *tegra)
>  	const struct firmware *fw;
>  	unsigned long timeout;
>  	time64_t timestamp;
> -	struct tm time;
>  	u64 address;
>  	u32 value;
>  	int err;
> @@ -907,11 +906,8 @@ static int tegra_xusb_load_firmware(struct tegra_xusb *tegra)
>  	}
>  
>  	timestamp = le32_to_cpu(header->fwimg_created_time);
> -	time64_to_tm(timestamp, 0, &time);
>  
> -	dev_info(dev, "Firmware timestamp: %ld-%02d-%02d %02d:%02d:%02d UTC\n",
> -		 time.tm_year + 1900, time.tm_mon + 1, time.tm_mday,
> -		 time.tm_hour, time.tm_min, time.tm_sec);
> +	dev_info(dev, "Firmware timestamp: %ptT UTC\n", &timestamp);

Can you please switch this to "Firmware timestamp: %ptTd %ptTt UTC\n" so
that the string stays the same? As discussed earlier there may be issues
if this string is changed. It may be unwise for someone to rely on the
exact format of this kernel log string, but why risk potentially causing
annoying changes in behaviour if we can easily avoid it?

Thierry

>  
>  	return 0;
>  }
> -- 
> 2.23.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v2 4/4] usb: host: xhci-tegra: Switch to use %ptT
  2019-10-02 11:39   ` Thierry Reding
@ 2019-12-09 16:40     ` Andy Shevchenko
  0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2019-12-09 16:40 UTC (permalink / raw)
  To: Thierry Reding
  Cc: linux-kernel, Greg Kroah-Hartman, Hans Verkuil, Jonathan Corbet,
	Jonathan Hunter, Alexandre Belloni, John Stultz

On Wed, Oct 02, 2019 at 01:39:23PM +0200, Thierry Reding wrote:
> On Tue, Oct 01, 2019 at 04:47:17PM +0300, Andy Shevchenko wrote:
> > Use %ptT instead of open coded variant to print content of
> > time64_t type in human readable format.

> >  	timestamp = le32_to_cpu(header->fwimg_created_time);
> > -	time64_to_tm(timestamp, 0, &time);
> >  
> > -	dev_info(dev, "Firmware timestamp: %ld-%02d-%02d %02d:%02d:%02d UTC\n",
> > -		 time.tm_year + 1900, time.tm_mon + 1, time.tm_mday,
> > -		 time.tm_hour, time.tm_min, time.tm_sec);
> > +	dev_info(dev, "Firmware timestamp: %ptT UTC\n", &timestamp);
> 
> Can you please switch this to "Firmware timestamp: %ptTd %ptTt UTC\n" so
> that the string stays the same? As discussed earlier there may be issues
> if this string is changed. It may be unwise for someone to rely on the
> exact format of this kernel log string, but why risk potentially causing
> annoying changes in behaviour if we can easily avoid it?

I don't think it's worth to do, though if you are insisting...

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2019-12-09 16:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-01 13:47 [PATCH v2 0/4] lib/vsprintf: Introduce %ptT for time64_t Andy Shevchenko
2019-10-01 13:47 ` [PATCH v2 1/4] lib/vsprintf: Print time64_t in human readable format Andy Shevchenko
2019-10-01 19:31   ` Alexandre Belloni
2019-10-01 13:47 ` [PATCH v2 2/4] ARM: bcm2835: Switch to use %ptT Andy Shevchenko
2019-10-01 13:47 ` [PATCH v2 3/4] [media] usb: pulse8-cec: " Andy Shevchenko
2019-10-01 13:47 ` [PATCH v2 4/4] usb: host: xhci-tegra: " Andy Shevchenko
2019-10-02 11:39   ` Thierry Reding
2019-12-09 16:40     ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).