* [PATCH v2 1/4] lib/vsprintf: Allow to override ISO 8601 date and time separator
@ 2021-05-11 15:39 ` Andy Shevchenko
0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2021-05-11 15:39 UTC (permalink / raw)
To: Petr Mladek, JC Kuo, Joe Perches, Sumit Garg,
linux-doc-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA,
linux-nilfs-u79uwXL29TY76Z2rM5mHXA,
kgdb-bugreport-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Cc: Steven Rostedt, Sergey Senozhatsky, Andy Shevchenko,
Rasmus Villemoes, Jonathan Corbet, Mathias Nyman,
Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter,
Ryusuke Konishi, Jason Wessel, Daniel Thompson, Douglas Anderson
ISO 8601 defines 'T' as a separator between date and time. Though,
some ABIs use time and date with ' ' (space) separator instead.
Add a flavour to the %pt specifier to override default separator.
Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
v2: fixed the parameters set, renamed variable and dropped comment (Petr)
Documentation/core-api/printk-formats.rst | 7 ++++++-
lib/test_printf.c | 5 +++++
lib/vsprintf.c | 22 +++++++++++++++++-----
3 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
index f063a384c7c8..1dd4ebf0be79 100644
--- a/Documentation/core-api/printk-formats.rst
+++ b/Documentation/core-api/printk-formats.rst
@@ -514,9 +514,10 @@ Time and date
::
%pt[RT] YYYY-mm-ddTHH:MM:SS
+ %pt[RT]s YYYY-mm-dd HH:MM:SS
%pt[RT]d YYYY-mm-dd
%pt[RT]t HH:MM:SS
- %pt[RT][dt][r]
+ %pt[RT][dt][r][s]
For printing date and time as represented by::
@@ -528,6 +529,10 @@ in human readable format.
By default year will be incremented by 1900 and month by 1.
Use %pt[RT]r (raw) to suppress this behaviour.
+The %pt[RT]s (space) will override ISO 8601 separator by using ' ' (space)
+instead of 'T' (Capital T) between date and time. It won't have any effect
+when date or time is omitted.
+
Passed by reference.
struct clk
diff --git a/lib/test_printf.c b/lib/test_printf.c
index ec0d5976bb69..8ac71aee46af 100644
--- a/lib/test_printf.c
+++ b/lib/test_printf.c
@@ -528,6 +528,11 @@ time_and_date(void)
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);
+
+ test("2019-01-04 15:32:23", "%ptTs", &t);
+ test("0119-00-04 15:32:23", "%ptTsr", &t);
+ test("15:32:23|2019-01-04", "%ptTts|%ptTds", &t, &t);
+ test("15:32:23|0119-00-04", "%ptTtrs|%ptTdrs", &t, &t);
}
static void __init
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index f0c35d9b65bf..14a4e4e8a657 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1834,7 +1834,8 @@ char *rtc_str(char *buf, char *end, const struct rtc_time *tm,
struct printf_spec spec, const char *fmt)
{
bool have_t = true, have_d = true;
- bool raw = false;
+ bool raw = false, iso8601_separator = true;
+ bool found = true;
int count = 2;
if (check_pointer(&buf, end, tm, spec))
@@ -1851,14 +1852,25 @@ char *rtc_str(char *buf, char *end, const struct rtc_time *tm,
break;
}
- raw = fmt[count] == 'r';
+ do {
+ switch (fmt[count++]) {
+ case 'r':
+ raw = true;
+ break;
+ case 's':
+ iso8601_separator = false;
+ break;
+ default:
+ found = false;
+ break;
+ }
+ } while (found);
if (have_d)
buf = date_str(buf, end, tm, raw);
if (have_d && have_t) {
- /* Respect ISO 8601 */
if (buf < end)
- *buf = 'T';
+ *buf = iso8601_separator ? 'T' : ' ';
buf++;
}
if (have_t)
@@ -2298,7 +2310,7 @@ early_param("no_hash_pointers", no_hash_pointers_enable);
* - '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[RT][dt][r]' For time and date as represented by:
+ * - 't[RT][dt][r][s]' 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
--
2.30.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 2/4] kdb: Switch to use %ptTs
2021-05-11 15:39 ` Andy Shevchenko
(?)
@ 2021-05-11 15:39 ` Andy Shevchenko
2021-05-13 9:31 ` Daniel Thompson
-1 siblings, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2021-05-11 15:39 UTC (permalink / raw)
To: Petr Mladek, JC Kuo, Joe Perches, Sumit Garg, linux-doc,
linux-kernel, linux-usb, linux-tegra, linux-nilfs,
kgdb-bugreport
Cc: Steven Rostedt, Sergey Senozhatsky, Andy Shevchenko,
Rasmus Villemoes, Jonathan Corbet, Mathias Nyman,
Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter,
Ryusuke Konishi, Jason Wessel, Daniel Thompson, Douglas Anderson
Use %ptTs instead of open-coded variant to print contents
of time64_t type in human readable form.
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Cc: kgdb-bugreport@lists.sourceforge.net
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
---
v2: collected tags
kernel/debug/kdb/kdb_main.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 1baa96a2ecb8..622410c45da1 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -2488,7 +2488,6 @@ static void kdb_sysinfo(struct sysinfo *val)
static int kdb_summary(int argc, const char **argv)
{
time64_t now;
- struct tm tm;
struct sysinfo val;
if (argc)
@@ -2502,13 +2501,7 @@ static int kdb_summary(int argc, const char **argv)
kdb_printf("domainname %s\n", init_uts_ns.name.domainname);
now = __ktime_get_real_seconds();
- time64_to_tm(now, 0, &tm);
- kdb_printf("date %04ld-%02d-%02d %02d:%02d:%02d "
- "tz_minuteswest %d\n",
- 1900+tm.tm_year, tm.tm_mon+1, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec,
- sys_tz.tz_minuteswest);
-
+ kdb_printf("date %ptTs tz_minuteswest %d\n", &now, sys_tz.tz_minuteswest);
kdb_sysinfo(&val);
kdb_printf("uptime ");
if (val.uptime > (24*60*60)) {
--
2.30.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v2 2/4] kdb: Switch to use %ptTs
@ 2021-05-13 9:31 ` Daniel Thompson
0 siblings, 0 replies; 19+ messages in thread
From: Daniel Thompson @ 2021-05-13 9:31 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Petr Mladek, JC Kuo, Joe Perches, Sumit Garg, linux-doc,
linux-kernel, linux-usb, linux-tegra, linux-nilfs,
kgdb-bugreport, Steven Rostedt, Sergey Senozhatsky,
Rasmus Villemoes, Jonathan Corbet, Mathias Nyman,
Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter,
Ryusuke Konishi, Jason Wessel, Douglas Anderson
On Tue, May 11, 2021 at 06:39:56PM +0300, Andy Shevchenko wrote:
> Use %ptTs instead of open-coded variant to print contents
> of time64_t type in human readable form.
>
> Cc: Jason Wessel <jason.wessel@windriver.com>
> Cc: Daniel Thompson <daniel.thompson@linaro.org>
> Cc: kgdb-bugreport@lists.sourceforge.net
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Petr Mladek <pmladek@suse.com>
> Reviewed-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Any clue what route this will take into the kernel? I'm certainly happy
for someone else to take the kdb bits alongside the vsprintf stuff
(so here's an acked-by too in case they are fussy about that sort of
thing ;-) ):
Acked-by: Daniel Thompson <daniel.thompson@linaro.org>
Daniel.
> ---
> v2: collected tags
> kernel/debug/kdb/kdb_main.c | 9 +--------
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
> index 1baa96a2ecb8..622410c45da1 100644
> --- a/kernel/debug/kdb/kdb_main.c
> +++ b/kernel/debug/kdb/kdb_main.c
> @@ -2488,7 +2488,6 @@ static void kdb_sysinfo(struct sysinfo *val)
> static int kdb_summary(int argc, const char **argv)
> {
> time64_t now;
> - struct tm tm;
> struct sysinfo val;
>
> if (argc)
> @@ -2502,13 +2501,7 @@ static int kdb_summary(int argc, const char **argv)
> kdb_printf("domainname %s\n", init_uts_ns.name.domainname);
>
> now = __ktime_get_real_seconds();
> - time64_to_tm(now, 0, &tm);
> - kdb_printf("date %04ld-%02d-%02d %02d:%02d:%02d "
> - "tz_minuteswest %d\n",
> - 1900+tm.tm_year, tm.tm_mon+1, tm.tm_mday,
> - tm.tm_hour, tm.tm_min, tm.tm_sec,
> - sys_tz.tz_minuteswest);
> -
> + kdb_printf("date %ptTs tz_minuteswest %d\n", &now, sys_tz.tz_minuteswest);
> kdb_sysinfo(&val);
> kdb_printf("uptime ");
> if (val.uptime > (24*60*60)) {
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 2/4] kdb: Switch to use %ptTs
@ 2021-05-13 9:31 ` Daniel Thompson
0 siblings, 0 replies; 19+ messages in thread
From: Daniel Thompson @ 2021-05-13 9:31 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Petr Mladek, JC Kuo, Joe Perches, Sumit Garg,
linux-doc-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA,
linux-nilfs-u79uwXL29TY76Z2rM5mHXA,
kgdb-bugreport-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Steven Rostedt,
Sergey Senozhatsky, Rasmus Villemoes, Jonathan Corbet,
Mathias Nyman, Greg Kroah-Hartman, Thierry Reding,
Jonathan Hunter, Ryusuke Konishi, Jason Wessel, Douglas Anderson
On Tue, May 11, 2021 at 06:39:56PM +0300, Andy Shevchenko wrote:
> Use %ptTs instead of open-coded variant to print contents
> of time64_t type in human readable form.
>
> Cc: Jason Wessel <jason.wessel-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
> Cc: Daniel Thompson <daniel.thompson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> Cc: kgdb-bugreport-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> Reviewed-by: Petr Mladek <pmladek-IBi9RG/b67k@public.gmane.org>
> Reviewed-by: Douglas Anderson <dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Reviewed-by: Daniel Thompson <daniel.thompson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Any clue what route this will take into the kernel? I'm certainly happy
for someone else to take the kdb bits alongside the vsprintf stuff
(so here's an acked-by too in case they are fussy about that sort of
thing ;-) ):
Acked-by: Daniel Thompson <daniel.thompson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Daniel.
> ---
> v2: collected tags
> kernel/debug/kdb/kdb_main.c | 9 +--------
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
> index 1baa96a2ecb8..622410c45da1 100644
> --- a/kernel/debug/kdb/kdb_main.c
> +++ b/kernel/debug/kdb/kdb_main.c
> @@ -2488,7 +2488,6 @@ static void kdb_sysinfo(struct sysinfo *val)
> static int kdb_summary(int argc, const char **argv)
> {
> time64_t now;
> - struct tm tm;
> struct sysinfo val;
>
> if (argc)
> @@ -2502,13 +2501,7 @@ static int kdb_summary(int argc, const char **argv)
> kdb_printf("domainname %s\n", init_uts_ns.name.domainname);
>
> now = __ktime_get_real_seconds();
> - time64_to_tm(now, 0, &tm);
> - kdb_printf("date %04ld-%02d-%02d %02d:%02d:%02d "
> - "tz_minuteswest %d\n",
> - 1900+tm.tm_year, tm.tm_mon+1, tm.tm_mday,
> - tm.tm_hour, tm.tm_min, tm.tm_sec,
> - sys_tz.tz_minuteswest);
> -
> + kdb_printf("date %ptTs tz_minuteswest %d\n", &now, sys_tz.tz_minuteswest);
> kdb_sysinfo(&val);
> kdb_printf("uptime ");
> if (val.uptime > (24*60*60)) {
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 2/4] kdb: Switch to use %ptTs
@ 2021-05-17 6:21 ` Andy Shevchenko
0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2021-05-17 6:21 UTC (permalink / raw)
To: Daniel Thompson
Cc: Petr Mladek, JC Kuo, Joe Perches, Sumit Garg, linux-doc,
linux-kernel, linux-usb, linux-tegra, linux-nilfs,
kgdb-bugreport, Steven Rostedt, Sergey Senozhatsky,
Rasmus Villemoes, Jonathan Corbet, Mathias Nyman,
Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter,
Ryusuke Konishi, Jason Wessel, Douglas Anderson
On Thu, May 13, 2021 at 10:31:30AM +0100, Daniel Thompson wrote:
> On Tue, May 11, 2021 at 06:39:56PM +0300, Andy Shevchenko wrote:
> > Use %ptTs instead of open-coded variant to print contents
> > of time64_t type in human readable form.
> >
> > Cc: Jason Wessel <jason.wessel@windriver.com>
> > Cc: Daniel Thompson <daniel.thompson@linaro.org>
> > Cc: kgdb-bugreport@lists.sourceforge.net
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Reviewed-by: Petr Mladek <pmladek@suse.com>
> > Reviewed-by: Douglas Anderson <dianders@chromium.org>
>
> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
>
> Any clue what route this will take into the kernel? I'm certainly happy
> for someone else to take the kdb bits alongside the vsprintf stuff
> (so here's an acked-by too in case they are fussy about that sort of
> thing ;-) ):
I hope Petr will take it thru PRINTK tree.
> Acked-by: Daniel Thompson <daniel.thompson@linaro.org>
Thanks!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 2/4] kdb: Switch to use %ptTs
@ 2021-05-17 6:21 ` Andy Shevchenko
0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2021-05-17 6:21 UTC (permalink / raw)
To: Daniel Thompson
Cc: Petr Mladek, JC Kuo, Joe Perches, Sumit Garg,
linux-doc-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA,
linux-nilfs-u79uwXL29TY76Z2rM5mHXA,
kgdb-bugreport-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Steven Rostedt,
Sergey Senozhatsky, Rasmus Villemoes, Jonathan Corbet,
Mathias Nyman, Greg Kroah-Hartman, Thierry Reding,
Jonathan Hunter, Ryusuke Konishi, Jason Wessel, Douglas Anderson
On Thu, May 13, 2021 at 10:31:30AM +0100, Daniel Thompson wrote:
> On Tue, May 11, 2021 at 06:39:56PM +0300, Andy Shevchenko wrote:
> > Use %ptTs instead of open-coded variant to print contents
> > of time64_t type in human readable form.
> >
> > Cc: Jason Wessel <jason.wessel-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
> > Cc: Daniel Thompson <daniel.thompson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> > Cc: kgdb-bugreport-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> > Reviewed-by: Petr Mladek <pmladek-IBi9RG/b67k@public.gmane.org>
> > Reviewed-by: Douglas Anderson <dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
>
> Reviewed-by: Daniel Thompson <daniel.thompson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>
> Any clue what route this will take into the kernel? I'm certainly happy
> for someone else to take the kdb bits alongside the vsprintf stuff
> (so here's an acked-by too in case they are fussy about that sort of
> thing ;-) ):
I hope Petr will take it thru PRINTK tree.
> Acked-by: Daniel Thompson <daniel.thompson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Thanks!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v2 3/4] nilfs2: Switch to use %ptTs
@ 2021-05-11 15:39 ` Andy Shevchenko
0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2021-05-11 15:39 UTC (permalink / raw)
To: Petr Mladek, JC Kuo, Joe Perches, Sumit Garg, linux-doc,
linux-kernel, linux-usb, linux-tegra, linux-nilfs,
kgdb-bugreport
Cc: Steven Rostedt, Sergey Senozhatsky, Andy Shevchenko,
Rasmus Villemoes, Jonathan Corbet, Mathias Nyman,
Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter,
Ryusuke Konishi, Jason Wessel, Daniel Thompson, Douglas Anderson
Use %ptTs instead of open coded variant to print contents
of time64_t type in human readable form.
Use sysfs_emit() at the same time in the changed functions.
Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: linux-nilfs@vger.kernel.org
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
---
v2: collected tags
fs/nilfs2/sysfs.c | 19 +++----------------
1 file changed, 3 insertions(+), 16 deletions(-)
diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c
index 303d71430bdd..4e10423f0448 100644
--- a/fs/nilfs2/sysfs.c
+++ b/fs/nilfs2/sysfs.c
@@ -19,19 +19,6 @@
/* /sys/fs/<nilfs>/ */
static struct kset *nilfs_kset;
-#define NILFS_SHOW_TIME(time_t_val, buf) ({ \
- struct tm res; \
- int count = 0; \
- time64_to_tm(time_t_val, 0, &res); \
- res.tm_year += 1900; \
- res.tm_mon += 1; \
- count = scnprintf(buf, PAGE_SIZE, \
- "%ld-%.2d-%.2d %.2d:%.2d:%.2d\n", \
- res.tm_year, res.tm_mon, res.tm_mday, \
- res.tm_hour, res.tm_min, res.tm_sec);\
- count; \
-})
-
#define NILFS_DEV_INT_GROUP_OPS(name, parent_name) \
static ssize_t nilfs_##name##_attr_show(struct kobject *kobj, \
struct attribute *attr, char *buf) \
@@ -576,7 +563,7 @@ nilfs_segctor_last_seg_write_time_show(struct nilfs_segctor_attr *attr,
ctime = nilfs->ns_ctime;
up_read(&nilfs->ns_segctor_sem);
- return NILFS_SHOW_TIME(ctime, buf);
+ return sysfs_emit(buf, "%ptTs\n", &ctime);
}
static ssize_t
@@ -604,7 +591,7 @@ nilfs_segctor_last_nongc_write_time_show(struct nilfs_segctor_attr *attr,
nongc_ctime = nilfs->ns_nongc_ctime;
up_read(&nilfs->ns_segctor_sem);
- return NILFS_SHOW_TIME(nongc_ctime, buf);
+ return sysfs_emit(buf, "%ptTs\n", &nongc_ctime);
}
static ssize_t
@@ -724,7 +711,7 @@ nilfs_superblock_sb_write_time_show(struct nilfs_superblock_attr *attr,
sbwtime = nilfs->ns_sbwtime;
up_read(&nilfs->ns_sem);
- return NILFS_SHOW_TIME(sbwtime, buf);
+ return sysfs_emit(buf, "%ptTs\n", &sbwtime);
}
static ssize_t
--
2.30.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 3/4] nilfs2: Switch to use %ptTs
@ 2021-05-11 15:39 ` Andy Shevchenko
0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2021-05-11 15:39 UTC (permalink / raw)
To: Petr Mladek, JC Kuo, Joe Perches, Sumit Garg,
linux-doc-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA,
linux-nilfs-u79uwXL29TY76Z2rM5mHXA,
kgdb-bugreport-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Cc: Steven Rostedt, Sergey Senozhatsky, Andy Shevchenko,
Rasmus Villemoes, Jonathan Corbet, Mathias Nyman,
Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter,
Ryusuke Konishi, Jason Wessel, Daniel Thompson, Douglas Anderson
Use %ptTs instead of open coded variant to print contents
of time64_t type in human readable form.
Use sysfs_emit() at the same time in the changed functions.
Cc: Ryusuke Konishi <konishi.ryusuke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Reviewed-by: Petr Mladek <pmladek-IBi9RG/b67k@public.gmane.org>
---
v2: collected tags
fs/nilfs2/sysfs.c | 19 +++----------------
1 file changed, 3 insertions(+), 16 deletions(-)
diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c
index 303d71430bdd..4e10423f0448 100644
--- a/fs/nilfs2/sysfs.c
+++ b/fs/nilfs2/sysfs.c
@@ -19,19 +19,6 @@
/* /sys/fs/<nilfs>/ */
static struct kset *nilfs_kset;
-#define NILFS_SHOW_TIME(time_t_val, buf) ({ \
- struct tm res; \
- int count = 0; \
- time64_to_tm(time_t_val, 0, &res); \
- res.tm_year += 1900; \
- res.tm_mon += 1; \
- count = scnprintf(buf, PAGE_SIZE, \
- "%ld-%.2d-%.2d %.2d:%.2d:%.2d\n", \
- res.tm_year, res.tm_mon, res.tm_mday, \
- res.tm_hour, res.tm_min, res.tm_sec);\
- count; \
-})
-
#define NILFS_DEV_INT_GROUP_OPS(name, parent_name) \
static ssize_t nilfs_##name##_attr_show(struct kobject *kobj, \
struct attribute *attr, char *buf) \
@@ -576,7 +563,7 @@ nilfs_segctor_last_seg_write_time_show(struct nilfs_segctor_attr *attr,
ctime = nilfs->ns_ctime;
up_read(&nilfs->ns_segctor_sem);
- return NILFS_SHOW_TIME(ctime, buf);
+ return sysfs_emit(buf, "%ptTs\n", &ctime);
}
static ssize_t
@@ -604,7 +591,7 @@ nilfs_segctor_last_nongc_write_time_show(struct nilfs_segctor_attr *attr,
nongc_ctime = nilfs->ns_nongc_ctime;
up_read(&nilfs->ns_segctor_sem);
- return NILFS_SHOW_TIME(nongc_ctime, buf);
+ return sysfs_emit(buf, "%ptTs\n", &nongc_ctime);
}
static ssize_t
@@ -724,7 +711,7 @@ nilfs_superblock_sb_write_time_show(struct nilfs_superblock_attr *attr,
sbwtime = nilfs->ns_sbwtime;
up_read(&nilfs->ns_sem);
- return NILFS_SHOW_TIME(sbwtime, buf);
+ return sysfs_emit(buf, "%ptTs\n", &sbwtime);
}
static ssize_t
--
2.30.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 4/4] usb: host: xhci-tegra: Switch to use %ptTs
@ 2021-05-11 15:39 ` Andy Shevchenko
0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2021-05-11 15:39 UTC (permalink / raw)
To: Petr Mladek, JC Kuo, Joe Perches, Sumit Garg, linux-doc,
linux-kernel, linux-usb, linux-tegra, linux-nilfs,
kgdb-bugreport
Cc: Steven Rostedt, Sergey Senozhatsky, Andy Shevchenko,
Rasmus Villemoes, Jonathan Corbet, Mathias Nyman,
Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter,
Ryusuke Konishi, Jason Wessel, Daniel Thompson, Douglas Anderson
Use %ptTs instead of open coded variant to print contents
of time64_t type in human readable form.
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: Petr Mladek <pmladek@suse.com>
---
v2: collected tags
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 ce97ff054c68..937b78cba89b 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -890,7 +890,6 @@ static int tegra_xusb_load_firmware(struct tegra_xusb *tegra)
struct xhci_op_regs __iomem *op;
unsigned long timeout;
time64_t timestamp;
- struct tm time;
u64 address;
u32 value;
int err;
@@ -987,11 +986,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: %ptTs UTC\n", ×tamp);
return 0;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 4/4] usb: host: xhci-tegra: Switch to use %ptTs
@ 2021-05-11 15:39 ` Andy Shevchenko
0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2021-05-11 15:39 UTC (permalink / raw)
To: Petr Mladek, JC Kuo, Joe Perches, Sumit Garg,
linux-doc-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA,
linux-nilfs-u79uwXL29TY76Z2rM5mHXA,
kgdb-bugreport-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Cc: Steven Rostedt, Sergey Senozhatsky, Andy Shevchenko,
Rasmus Villemoes, Jonathan Corbet, Mathias Nyman,
Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter,
Ryusuke Konishi, Jason Wessel, Daniel Thompson, Douglas Anderson
Use %ptTs instead of open coded variant to print contents
of time64_t type in human readable form.
Cc: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Jonathan Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Reviewed-by: Petr Mladek <pmladek-IBi9RG/b67k@public.gmane.org>
---
v2: collected tags
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 ce97ff054c68..937b78cba89b 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -890,7 +890,6 @@ static int tegra_xusb_load_firmware(struct tegra_xusb *tegra)
struct xhci_op_regs __iomem *op;
unsigned long timeout;
time64_t timestamp;
- struct tm time;
u64 address;
u32 value;
int err;
@@ -987,11 +986,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: %ptTs UTC\n", ×tamp);
return 0;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v2 4/4] usb: host: xhci-tegra: Switch to use %ptTs
@ 2021-05-13 12:49 ` Greg Kroah-Hartman
0 siblings, 0 replies; 19+ messages in thread
From: Greg Kroah-Hartman @ 2021-05-13 12:49 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Petr Mladek, JC Kuo, Joe Perches, Sumit Garg, linux-doc,
linux-kernel, linux-usb, linux-tegra, linux-nilfs,
kgdb-bugreport, Steven Rostedt, Sergey Senozhatsky,
Rasmus Villemoes, Jonathan Corbet, Mathias Nyman, Thierry Reding,
Jonathan Hunter, Ryusuke Konishi, Jason Wessel, Daniel Thompson,
Douglas Anderson
On Tue, May 11, 2021 at 06:39:58PM +0300, Andy Shevchenko wrote:
> Use %ptTs instead of open coded variant to print contents
> of time64_t type in human readable form.
>
> 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: Petr Mladek <pmladek@suse.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 4/4] usb: host: xhci-tegra: Switch to use %ptTs
@ 2021-05-13 12:49 ` Greg Kroah-Hartman
0 siblings, 0 replies; 19+ messages in thread
From: Greg Kroah-Hartman @ 2021-05-13 12:49 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Petr Mladek, JC Kuo, Joe Perches, Sumit Garg,
linux-doc-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA,
linux-nilfs-u79uwXL29TY76Z2rM5mHXA,
kgdb-bugreport-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Steven Rostedt,
Sergey Senozhatsky, Rasmus Villemoes, Jonathan Corbet,
Mathias Nyman, Thierry Reding, Jonathan Hunter, Ryusuke Konishi,
Jason Wessel, Daniel Thompson, Douglas Anderson
On Tue, May 11, 2021 at 06:39:58PM +0300, Andy Shevchenko wrote:
> Use %ptTs instead of open coded variant to print contents
> of time64_t type in human readable form.
>
> Cc: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Cc: Jonathan Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> Reviewed-by: Petr Mladek <pmladek-IBi9RG/b67k@public.gmane.org>
Acked-by: Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 1/4] lib/vsprintf: Allow to override ISO 8601 date and time separator
2021-05-11 15:39 ` Andy Shevchenko
@ 2021-05-13 9:34 ` Petr Mladek
-1 siblings, 0 replies; 19+ messages in thread
From: Petr Mladek @ 2021-05-13 9:34 UTC (permalink / raw)
To: Andy Shevchenko
Cc: JC Kuo, Joe Perches, Sumit Garg, linux-doc, linux-kernel,
linux-usb, linux-tegra, linux-nilfs, kgdb-bugreport,
Steven Rostedt, Sergey Senozhatsky, Rasmus Villemoes,
Jonathan Corbet, Mathias Nyman, Greg Kroah-Hartman,
Thierry Reding, Jonathan Hunter, Ryusuke Konishi, Jason Wessel,
Daniel Thompson, Douglas Anderson
On Tue 2021-05-11 18:39:55, Andy Shevchenko wrote:
> ISO 8601 defines 'T' as a separator between date and time. Though,
> some ABIs use time and date with ' ' (space) separator instead.
>
> Add a flavour to the %pt specifier to override default separator.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
I am going to queue the entire patchset for 5.14 via the printk tree
the following week unless anyone complains in the meantime.
Best Regards,
Petr
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 1/4] lib/vsprintf: Allow to override ISO 8601 date and time separator
@ 2021-05-13 9:34 ` Petr Mladek
0 siblings, 0 replies; 19+ messages in thread
From: Petr Mladek @ 2021-05-13 9:34 UTC (permalink / raw)
To: Andy Shevchenko
Cc: JC Kuo, Joe Perches, Sumit Garg, linux-doc, linux-kernel,
linux-usb, linux-tegra, linux-nilfs, kgdb-bugreport,
Steven Rostedt, Sergey Senozhatsky, Rasmus Villemoes,
Jonathan Corbet, Mathias Nyman, Greg Kroah-Hartman,
Thierry Reding, Jonathan Hunter, Ryusuke Konishi, Jason Wessel,
Daniel Thompson, Douglas Anderson
On Tue 2021-05-11 18:39:55, Andy Shevchenko wrote:
> ISO 8601 defines 'T' as a separator between date and time. Though,
> some ABIs use time and date with ' ' (space) separator instead.
>
> Add a flavour to the %pt specifier to override default separator.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
I am going to queue the entire patchset for 5.14 via the printk tree
the following week unless anyone complains in the meantime.
Best Regards,
Petr
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 1/4] lib/vsprintf: Allow to override ISO 8601 date and time separator
2021-05-13 9:34 ` Petr Mladek
@ 2021-05-13 12:06 ` Sergey Senozhatsky
-1 siblings, 0 replies; 19+ messages in thread
From: Sergey Senozhatsky @ 2021-05-13 12:06 UTC (permalink / raw)
To: Petr Mladek
Cc: Andy Shevchenko, JC Kuo, Joe Perches, Sumit Garg, linux-doc,
linux-kernel, linux-usb, linux-tegra, linux-nilfs,
kgdb-bugreport, Steven Rostedt, Sergey Senozhatsky,
Rasmus Villemoes, Jonathan Corbet, Mathias Nyman,
Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter,
Ryusuke Konishi, Jason Wessel, Daniel Thompson, Douglas Anderson
On (21/05/13 11:34), Petr Mladek wrote:
> On Tue 2021-05-11 18:39:55, Andy Shevchenko wrote:
> > ISO 8601 defines 'T' as a separator between date and time. Though,
> > some ABIs use time and date with ' ' (space) separator instead.
> >
> > Add a flavour to the %pt specifier to override default separator.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Reviewed-by: Petr Mladek <pmladek@suse.com>
>
> I am going to queue the entire patchset for 5.14 via the printk tree
> the following week unless anyone complains in the meantime.
Looks good to me
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 1/4] lib/vsprintf: Allow to override ISO 8601 date and time separator
@ 2021-05-13 12:06 ` Sergey Senozhatsky
0 siblings, 0 replies; 19+ messages in thread
From: Sergey Senozhatsky @ 2021-05-13 12:06 UTC (permalink / raw)
To: Petr Mladek
Cc: Andy Shevchenko, JC Kuo, Joe Perches, Sumit Garg,
linux-doc-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA,
linux-nilfs-u79uwXL29TY76Z2rM5mHXA,
kgdb-bugreport-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Steven Rostedt,
Sergey Senozhatsky, Rasmus Villemoes, Jonathan Corbet,
Mathias Nyman, Greg Kroah-Hartman, Thierry Reding,
Jonathan Hunter, Ryusuke Konishi, Jason Wessel, Daniel
On (21/05/13 11:34), Petr Mladek wrote:
> On Tue 2021-05-11 18:39:55, Andy Shevchenko wrote:
> > ISO 8601 defines 'T' as a separator between date and time. Though,
> > some ABIs use time and date with ' ' (space) separator instead.
> >
> > Add a flavour to the %pt specifier to override default separator.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
>
> Reviewed-by: Petr Mladek <pmladek-IBi9RG/b67k@public.gmane.org>
>
> I am going to queue the entire patchset for 5.14 via the printk tree
> the following week unless anyone complains in the meantime.
Looks good to me
Reviewed-by: Sergey Senozhatsky <senozhatsky-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 1/4] lib/vsprintf: Allow to override ISO 8601 date and time separator
2021-05-13 9:34 ` Petr Mladek
@ 2021-05-17 12:42 ` Petr Mladek
-1 siblings, 0 replies; 19+ messages in thread
From: Petr Mladek @ 2021-05-17 12:42 UTC (permalink / raw)
To: Andy Shevchenko
Cc: JC Kuo, Joe Perches, Sumit Garg, linux-doc, linux-kernel,
linux-usb, linux-tegra, linux-nilfs, kgdb-bugreport,
Steven Rostedt, Sergey Senozhatsky, Rasmus Villemoes,
Jonathan Corbet, Mathias Nyman, Greg Kroah-Hartman,
Thierry Reding, Jonathan Hunter, Ryusuke Konishi, Jason Wessel,
Daniel Thompson, Douglas Anderson
On Thu 2021-05-13 11:34:18, Petr Mladek wrote:
> On Tue 2021-05-11 18:39:55, Andy Shevchenko wrote:
> > ISO 8601 defines 'T' as a separator between date and time. Though,
> > some ABIs use time and date with ' ' (space) separator instead.
> >
> > Add a flavour to the %pt specifier to override default separator.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Reviewed-by: Petr Mladek <pmladek@suse.com>
>
> I am going to queue the entire patchset for 5.14 via the printk tree
> the following week unless anyone complains in the meantime.
The patchset has been committed into print/linux.git, branch
for-5.14-vsprintf-pts.
Best Regards,
Petr
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 1/4] lib/vsprintf: Allow to override ISO 8601 date and time separator
@ 2021-05-17 12:42 ` Petr Mladek
0 siblings, 0 replies; 19+ messages in thread
From: Petr Mladek @ 2021-05-17 12:42 UTC (permalink / raw)
To: Andy Shevchenko
Cc: JC Kuo, Joe Perches, Sumit Garg,
linux-doc-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA,
linux-nilfs-u79uwXL29TY76Z2rM5mHXA,
kgdb-bugreport-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Steven Rostedt,
Sergey Senozhatsky, Rasmus Villemoes, Jonathan Corbet,
Mathias Nyman, Greg Kroah-Hartman, Thierry Reding,
Jonathan Hunter, Ryusuke Konishi, Jason Wessel, Daniel Thompson,
Douglas Anderson
On Thu 2021-05-13 11:34:18, Petr Mladek wrote:
> On Tue 2021-05-11 18:39:55, Andy Shevchenko wrote:
> > ISO 8601 defines 'T' as a separator between date and time. Though,
> > some ABIs use time and date with ' ' (space) separator instead.
> >
> > Add a flavour to the %pt specifier to override default separator.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
>
> Reviewed-by: Petr Mladek <pmladek-IBi9RG/b67k@public.gmane.org>
>
> I am going to queue the entire patchset for 5.14 via the printk tree
> the following week unless anyone complains in the meantime.
The patchset has been committed into print/linux.git, branch
for-5.14-vsprintf-pts.
Best Regards,
Petr
^ permalink raw reply [flat|nested] 19+ messages in thread