lib, rtc: Print rtc_time via %pt[dt][rv]
Subsystems (18)
Andy Shevchenko
reviewercover lib, rtc: Print rtc_time via %pt[dt][rv]
Recently I have noticed too many users of struct rtc_time that printing its content field by field.
In this series I introduce %pt[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.
Andy Shevchenko (25):
lib/vsprintf: Remove useless NULL checks
lib/vsprintf: Make decspec global
lib/vsprintf: Make strspec global
lib/vsprintf: Print time and date in human readable format via %pt
ds1302: Switch to use %pt
rtc: Switch to use %pt
rtc: at91rm9200: Switch to use %pt
rtc: at91sam9: Switch to use %pt
rtc: m41t80: Switch to use %pt
rtc: m48t59: Switch to use %pt
rtc: mcp795: Switch to use %pt
rtc: pcf50633: Switch to use %pt
rtc: pic32: Switch to use %pt
rtc: pm8xxx: Switch to use %pt
rtc: puv3: Switch to use %pt
rtc: rk808: Switch to use %pt
rtc: rx6110: Switch to use %pt
rtc: rx8025: Switch to use %pt
rtc: s3c: Switch to use %pt
rtc: s5m: Switch to use %pt
rtc: tegra: Switch to use %pt
mk68/mac: Switch to use %pt
Input: hp_sdc_rtc - Switch to use %pt
kdb: Switch to use %pt
PM: Switch to use %pt
Documentation/printk-formats.txt | 17 ++++ arch/m68k/mac/misc.c | 8 +- drivers/base/power/trace.c | 4 +- drivers/char/ds1302.c | 38 +++------ drivers/char/rtc.c | 7 +- drivers/input/misc/hp_sdc_rtc.c | 8 +- drivers/rtc/hctosys.c | 8 +- drivers/rtc/interface.c | 8 +- drivers/rtc/rtc-at91rm9200.c | 16 +--- 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/debug/kdb/kdb_main.c | 7 +- lib/vsprintf.c | 167 ++++++++++++++++++++++++++++++++------- 27 files changed, 248 insertions(+), 325 deletions(-)
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 1/25 lib/vsprintf: Remove useless NULL checks
The pointer can't be NULL since it's first what has been done in the pointer().
Remove useless checks.
Note when we print clock name or rate it is safe in case !CONFIG_HAVE_CLK.
--- lib/vsprintf.c | 11 ----------- 1 file changed, 11 deletions(-)
lib/vsprintf.c +0 -11
@@ -811,10 +811,6 @@ char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec,/* nothing to print */ return buf; -if (ZERO_OR_NULL_PTR (addr)) -/* NULL pointer */ -return string (buf, end,NULL , spec); -switch (fmt[1 ]) {case 'C' : separator =':' ;
@@ -1253,10 +1249,6 @@ char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec,if (spec.field_width ==0 )return buf;/* nothing to print */ -if (ZERO_OR_NULL_PTR (addr)) -return string (buf, end,NULL , spec);/* NULL pointer */ - - do { switch (fmt[count++]) { case 'a':
@@ -1391,9 +1383,6 @@ static noinline_for_stackchar *clock (char *buf,char *end,struct clk *clk,struct printf_spec spec,const char *fmt) { -if (!IS_ENABLED (CONFIG_HAVE_CLK ) || !clk) -return string (buf, end,NULL , spec); -switch (fmt[1 ]) {case 'r' :return number (buf, end,clk_get_rate (clk), spec);
Signature · 1 line
2.11.0
Rasmus Villemoes
reviewerRe: [PATCH v1 01/25] lib/vsprintf: Remove useless NULL checks
Quoted 28 lines · Andy Shevchenko
The pointer can't be NULL since it's first what has been done in the
pointer().Remove useless checks.
Note when we print clock name or rate it is safe in case !CONFIG_HAVE_CLK.
Signed-off-by Andy Shevchenko <[email protected]>--- lib/vsprintf.c | 11 ----------- 1 file changed, 11 deletions(-)lib/vsprintf.c +0
-4@@ -811,10 +811,6 @@ char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec,/* nothing to print */ return buf; -if (ZERO_OR_NULL_PTR (addr)) -/* NULL pointer */ -return string (buf, end,NULL , spec); -switch (fmt[1 ]) {case 'C' : separator =':' ;
lib/vsprintf.c char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, · line 1259
Quoted 7 lines
lib/vsprintf.c +0
-4@@ -1253,10 +1249,6 @@ char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec,if (spec.field_width ==0 )return buf;/* nothing to print */ -if (ZERO_OR_NULL_PTR (addr)) -return string (buf, end,NULL , spec);/* NULL pointer */ - -
Well, ZERO_OR_NULL_PTR checks for a little more than !addr, but I suppose that if anyone passes the result from kmalloc(0) to %ph, they'd better also pass 0 as the size, so the .field_width tests should be sufficient.
lib/vsprintf.c static noinline_for_stack · line 1396
Quoted 10 lines
lib/vsprintf.c +0
-3do { switch (fmt[count++]) { case 'a':@@ -1391,9 +1383,6 @@ static noinline_for_stackchar *clock (char *buf,char *end,struct clk *clk,struct printf_spec spec,const char *fmt) { -if (!IS_ENABLED (CONFIG_HAVE_CLK ) || !clk) -return string (buf, end,NULL , spec); -
Well, it may be safe, but removing the IS_ENABLED(CONFIG_HAVE_CLK) check means that clock() becomes a much bigger function when !IS_ENABLED(CONFIG_HAVE_CLK). You're right that the !clk check is pointless.
Andy Shevchenko
reviewerRe: [PATCH v1 01/25] lib/vsprintf: Remove useless NULL checks
Quoted 4 lines · Rasmus Villemoes
Quoted 2 lines · Andy Shevchenko
The pointer can't be NULL since it's first what has been done in the
pointer().
Quoted 11 lines
lib/vsprintf.c char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, · line 1259
Quoted 5 lines
(quoted diff) +0
-2- if (ZERO_OR_NULL_PTR(addr)) - return string(buf, end, NULL, spec); /* NULLpointer */
lib/vsprintf.c +0
-2- -Well,
ZERO_OR_NULL_PTRchecks for a little more than !addr, but I suppose that if anyone passes the result from kmalloc(0) to %ph, they'd
better also pass 0 as the size, so the .field_width tests should be sufficient.
If we care about kmalloc(0) check we better to do this in pointer()?
Quoted 8 lines
lib/vsprintf.c static noinline_for_stack · line 1396
Quoted 3 lines
lib/vsprintf.c +0
-3-if (!IS_ENABLED (CONFIG_HAVE_CLK ) || !clk) -return string (buf, end,NULL , spec); -Well, it may be safe, but removing the
IS_ENABLED(CONFIG_HAVE_CLK)check
means thatclock()becomes a much bigger function when !IS_ENABLED(CONFIG_HAVE_CLK).
I return back this in v2.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Andy Shevchenko
reviewerPATCH 2/25 lib/vsprintf: Make decspec global
In reply to Andy ShevchenkoThere are places where default specification to print decimal numbers is in use.
Make it global and convert existing users.
--- lib/vsprintf.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
lib/vsprintf.c +9 -12
@@ -691,6 +691,11 @@ char *symbol_string(char *buf, char *end, void *ptr,#endif } +static const struct printf_spec default_dec_spec = { + .base =10 , + .precision =-1 , +}; +static noinline_for_stack char *resource_string(char *buf, char *end, struct resource *res,struct printf_spec spec,const char *fmt)
@@ -720,11 +725,6 @@ char *resource_string(char *buf, char *end, struct resource *res, .precision = -1, .flags = SMALL | ZEROPAD, }; -static const struct printf_spec dec_spec = { - .base =10 , - .precision =-1 , - .flags =0 , - };static const struct printf_spec str_spec = { .field_width =-1 , .precision =10 ,
@@ -758,10 +758,10 @@ char *resource_string(char *buf, char *end, struct resource *res, specp = &mem_spec; }else if (res->flags &IORESOURCE_IRQ ) { p =string (p, pend,"irq " , str_spec); - specp = &dec_spec; + specp = &default_dec_spec; }else if (res->flags &IORESOURCE_DMA ) { p =string (p, pend,"dma " , str_spec); - specp = &dec_spec; + specp = &default_dec_spec; }else if (res->flags &IORESOURCE_BUS ) { p =string (p, pend,"bus " , str_spec); specp = &bus_spec;
@@ -897,9 +897,6 @@ char *bitmap_list_string(char *buf, char *end, unsigned long *bitmap,int cur, rbot, rtop;bool first = true; -/* reused to print numbers */ - spec = (struct printf_spec ){ .base =10 }; - rbot = cur =find_first_bit (bitmap, nr_bits);while (cur < nr_bits) { rtop = cur;
@@ -914,13 +911,13 @@ char *bitmap_list_string(char *buf, char *end, unsigned long *bitmap, } first = false; - buf =number (buf, end, rbot, spec); + buf =number (buf, end, rbot, default_dec_spec);if (rbot < rtop) {if (buf < end) *buf ='-' ; buf++; - buf =number (buf, end, rtop, spec); + buf =number (buf, end, rtop, default_dec_spec); } rbot = cur;
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 3/25 lib/vsprintf: Make strspec global
In reply to Andy ShevchenkoThere is at least one new user is coming where default specification to print strings is in use.
Make it global.
--- lib/vsprintf.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
lib/vsprintf.c +6 -5
@@ -691,6 +691,11 @@ char *symbol_string(char *buf, char *end, void *ptr,#endif } +static const struct printf_spec default_str_spec = { + .field_width =-1 , + .precision =-1 , +}; +static const struct printf_spec default_dec_spec = { .base =10 , .precision =-1 ,
@@ -1399,10 +1404,6 @@ char *format_flags(char *buf, char *end, unsigned long flags, const struct trace_print_flags *names) {unsigned long mask; -const struct printf_spec strspec = { - .field_width =-1 , - .precision =-1 , - };const struct printf_spec numspec = { .flags =SPECIAL |SMALL , .field_width =-1 ,
@@ -1415,7 +1416,7 @@ char *format_flags(char *buf, char *end, unsigned long flags,if ((flags & mask) != mask)continue ; - buf =string (buf, end, names->name, strspec); + buf =string (buf, end, names->name, default_str_spec); flags &= ~mask;if (flags) {
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 4/25 lib/vsprintf: Print time and date in human readable format via %pt
In reply to Andy ShevchenkoThere 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 %pt[dt][rv] specifier.
--- Documentation/printk-formats.txt | 17 ++++++ lib/vsprintf.c | 124 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+)
Documentation/printk-formats.txt +17 -0
@@ -282,6 +282,23 @@ struct va_format: Passed by reference. +struct rtc_time: + + %pt YYYY-mm-dd HH:MM:SS + %ptd YYYY-mm-dd + %ptt HH:MM:SS + %pt[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 + 'r' (raw) to suppress this behaviour. On the other hand when + 'v' is applied validation mechanism will be in use, i.e. numbers + out of range will be replaced by '**' or '****'. + + Passed by reference. + struct clk: %pC pll1
lib/vsprintf.c +124 -0
154 lines not on this page · raw message
Signature · 1 line
2.11.0
Arnd Bergmann
maintainerRe: [PATCH v1 04/25] lib/vsprintf: Print time and date in human readable format via %pt
Quoted 4 lines · Andy Shevchenko
There are users which print time and date represented by content of struct
rtc_timein human readable format.Instead of open coding that each time introduce %pt[dt][rv] specifier.
I really like the idea, and the implementation seems fine for this use case, but before we reserve %pt for rtc_time, could we discuss whether we want that for printing struct tm, struct timespec64, time64_t or ktime_t instead?
I can see good reasons for pretty-printing any of them, but the namespace for format strings is rather limited.
struct rtc_time is almost the same as struct tm (the former has one extra member), so maybe we can actually define them to be the same and use one format string for both?
Arnd
Re: [PATCH v1 04/25] lib/vsprintf: Print time and date in human readable format via %pt
Quoted 10 lines · Arnd Bergmann
Quoted 4 lines · Andy Shevchenko
There are users which print time and date represented by content of struct
rtc_timein human readable format.Instead of open coding that each time introduce %pt[dt][rv] specifier.
I really like the idea, and the implementation seems fine for this use case, but before we reserve %pt for
rtc_time, could we discuss whether we want that for printing struct tm, struct timespec64,time64_torktime_tinstead?
How many users? For struct tm it's somelike 4 (which want to print its content).
Quoted 6 lines
I can see good reasons for pretty-printing any of them, but the namespace for format strings is rather limited.
struct
rtc_timeis almost the same as struct tm (the former has one extra member), so maybe we can actually define them to be the same and use one format string for both?
The reason I decide to drop struct tm for now due to they are not compatible and I have got an interesting bugs.
Verify tm_year member carefully.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v1 04/25] lib/vsprintf: Print time and date in human readable format via %pt
Quoted 17 lines · Andy Shevchenko
Quoted 10 lines · Arnd Bergmann
Quoted 4 lines · Andy Shevchenko
There are users which print time and date represented by content of struct
rtc_timein human readable format.Instead of open coding that each time introduce %pt[dt][rv] specifier.
I really like the idea, and the implementation seems fine for this use case, but before we reserve %pt for
rtc_time, could we discuss whether we want that for printing struct tm, struct timespec64,time64_torktime_tinstead?How many users? For struct tm it's somelike 4 (which want to print its content).
Quoted 3 lines
I can see good reasons for pretty-printing any of them, but the namespace for format strings is rather limited.
Quoted 8 lines
Quoted 3 lines
struct
rtc_timeis almost the same as struct tm (the former has one extra member), so maybe we can actually define them to be the same and use one format string for both?The reason I decide to drop struct tm for now due to they are not compatible and I have got an interesting bugs.
Verifytm_yearmember carefully.
I understand this may not fit your debugging needs but what about pretty printing time64_t and using rtc_tm_to_time64?
Signature · 3 lines
Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Re: [PATCH v1 04/25] lib/vsprintf: Print time and date in human readable format via %pt
Quoted 22 lines · Alexandre Belloni
Quoted 21 lines · Andy Shevchenko
Quoted 10 lines · Arnd Bergmann
Quoted 4 lines · Andy Shevchenko
There are users which print time and date represented by content of struct
rtc_timein human readable format.Instead of open coding that each time introduce %pt[dt][rv] specifier.
I really like the idea, and the implementation seems fine for this use case, but before we reserve %pt for
rtc_time, could we discuss whether we want that for printing struct tm, struct timespec64,time64_torktime_tinstead?How many users? For struct tm it's somelike 4 (which want to print its content).
Quoted 6 lines
I can see good reasons for pretty-printing any of them, but the namespace for format strings is rather limited.
struct
rtc_timeis almost the same as struct tm (the former has one extra member), so maybe we can actually define them to be the same and use one format string for both?
Quoted 7 lines
Quoted 4 lines
The reason I decide to drop struct tm for now due to they are not compatible and I have got an interesting bugs.
Verifytm_yearmember carefully.I understand this may not fit your debugging needs but what about pretty printing
time64_tand usingrtc_tm_to_time64?
There are two downsides as I can see:
1) conversion to and from just for that;
2) if you look closer to the patches rtc-* you may find cases where wday is also printed so, struct rtc_time still will be in use.
So, I would go not to convert if there is no strong reason to do.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v1 04/25] lib/vsprintf: Print time and date in human readable format via %pt
Quoted 29 lines · Andy Shevchenko
Quoted 27 lines · Alexandre Belloni
Quoted 25 lines · Andy Shevchenko
Quoted 10 lines · Arnd Bergmann
Quoted 4 lines · Andy Shevchenko
There are users which print time and date represented by content of struct
rtc_timein human readable format.Instead of open coding that each time introduce %pt[dt][rv] specifier.
I really like the idea, and the implementation seems fine for this use case, but before we reserve %pt for
rtc_time, could we discuss whether we want that for printing struct tm, struct timespec64,time64_torktime_tinstead?How many users? For struct tm it's somelike 4 (which want to print its content).
Quoted 6 lines
I can see good reasons for pretty-printing any of them, but the namespace for format strings is rather limited.
struct
rtc_timeis almost the same as struct tm (the former has one extra member), so maybe we can actually define them to be the same and use one format string for both?The reason I decide to drop struct tm for now due to they are not compatible and I have got an interesting bugs.
Verifytm_yearmember carefully.
Quoted 5 lines
Quoted 2 lines
I understand this may not fit your debugging needs but what about pretty printing
time64_tand usingrtc_tm_to_time64?There are two downsides as I can see:
1) conversion to and from just for that;
Those are almost all debug messages, I would be fine with that.
Quoted 3 lines
2) if you look closer to the patches rtc-* you may find cases where wday is also printed so, struct
rtc_timestill will be in use.
(And you missed two in rtc-mcp795.c). Honestly, nobody cares about wday, you may as well leave it out.
Signature · 3 lines
Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Re: [PATCH v1 04/25] lib/vsprintf: Print time and date in human readable format via %pt
Quoted 11 lines · Alexandre Belloni
Quoted 8 lines · Andy Shevchenko
Quoted 2 lines · Alexandre Belloni
I understand this may not fit your debugging needs but what about pretty printing
time64_tand usingrtc_tm_to_time64?There are two downsides as I can see:
1) conversion to and from just for that;Those are almost all debug messages, I would be fine with that.
Yeah, but the problem is to pass the reference. All dances around will uglify the code.
(Obviously we can't pass timespec64/time64_t or anything longer than 32 bits as is in %p extension)
Quoted 5 lines
Quoted 2 lines
2) if you look closer to the patches rtc-* you may find cases where wday is also printed so, struct
rtc_timestill will be in use.(And you missed two in
rtc-mcp795.c). Honestly, nobody cares about wday, you may as well leave it out.
Oops, thanks, indeed. Okay, I will leave it for now with dropped wday until someone comes with strong opinion why it should be there.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Rasmus Villemoes
reviewerRe: [PATCH v1 04/25] lib/vsprintf: Print time and date in human readable format via %pt
Quoted 12 lines · Andy Shevchenko
Quoted 10 lines · Alexandre Belloni
Quoted 8 lines · Andy Shevchenko
Quoted 2 lines · Alexandre Belloni
I understand this may not fit your debugging needs but what about pretty printing
time64_tand usingrtc_tm_to_time64?There are two downsides as I can see:
1) conversion to and from just for that;
Quoted 7 lines
Quoted 1 line
Those are almost all debug messages, I would be fine with that.
Yeah, but the problem is to pass the reference. All dances around will uglify the code.
(Obviously we can't pass timespec64/time64_t or anything longer than 32 bits as is in %p extension)
I like that this gets rid of some mm/dd/yy and other more or less random format and ends up standardizing yyyy-mm-dd HH:MM:SS. However, I do think %pt should take either ktime_t or timespec64 (obviously by reference), with fx these options
[ir] ISO (yyyy-mm-dd HH:MM:SS) or raw (seconds since epoch)
[n] append nanoseconds (.%09ld).
Please don't give people the option of eliding either the time or the date; I've spent too much time dealing with syslog files that don't include the year in the timestamps.
Getting a timespec64* or ktime_t* from <something else> is not that bad. There's the compound literal option
#define rtc_tm2timespec64p(tm) \
(&(struct timespec64){ .tv_sec = rtc_tm_to_time64(tm), .tv_nsec = 0 })
printk("%pt", rtc_tm2timespec64p(tm))
or the two-extra-lines per call-site
struct timespec64 ts;rtc_tm2time64(tm, &ts)printk("%pt", &ts)
Rasmus
Re: [PATCH v1 04/25] lib/vsprintf: Print time and date in human readable format via %pt
Quoted 12 lines · Rasmus Villemoes
Quoted 10 lines · Andy Shevchenko
Quoted 3 lines · Alexandre Belloni
Quoted 2 lines · Andy Shevchenko
On Thu, Jun 8, 2017 at 6:05 PM, Alexandre Belloni
<[email protected]> wrote:Yeah, but the problem is to pass the reference. All dances around will uglify the code.
(Obviously we can't pass timespec64/time64_t or anything longer than 32 bits as is in %p extension)
Quoted 4 lines
I like that this gets rid of some
mm/dd/yyand other more or less random format and ends up standardizing yyyy-mm-dd HH:MM:SS. However, I do think %pt should take eitherktime_tor timespec64 (obviously by reference),
I will try to look in this direction.
Quoted 4 lines
with fx these options
[ir] ISO (yyyy-mm-dd HH:MM:SS) or raw (seconds since epoch)
[n] append nanoseconds (.%09ld).
We still need to be able to print time *and/or* year groups separately. There are users which provide that via procfs or sysfs (ABI).
Quoted 3 lines
Please don't give people the option of eliding either the time or the date; I've spent too much time dealing with syslog files that don't include the year in the timestamps.
I understand that, but see above.
Quoted 2 lines
Getting a timespec64* or ktime_t* from <something else> is not that bad. There's the compound literal option
Will look at it later, thanks for it.
Quoted 11 lines
#define
rtc_tm2timespec64p(tm)\
(&(struct timespec64){ .tv_sec =rtc_tm_to_time64(tm), .tv_nsec = 0 })
printk("%pt", rtc_tm2timespec64p(tm))or the two-extra-lines per call-site
struct timespec64 ts;
rtc_tm2time64(tm, &ts)printk("%pt", &ts)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Arnd Bergmann
maintainerRe: [PATCH v1 04/25] lib/vsprintf: Print time and date in human readable format via %pt
Quoted 14 lines · Andy Shevchenko
Quoted 11 lines · Rasmus Villemoes
Quoted 10 lines · Andy Shevchenko
Quoted 3 lines · Alexandre Belloni
Quoted 2 lines · Andy Shevchenko
On Thu, Jun 8, 2017 at 6:05 PM, Alexandre Belloni
<[email protected]> wrote:Yeah, but the problem is to pass the reference. All dances around will uglify the code.
(Obviously we can't pass timespec64/time64_t or anything longer than 32 bits as is in %p extension)
Quoted 6 lines
Quoted 4 lines
I like that this gets rid of some
mm/dd/yyand other more or less random format and ends up standardizing yyyy-mm-dd HH:MM:SS. However, I do think %pt should take eitherktime_tor timespec64 (obviously by reference),I will try to look in this direction.
sounds good.
Quoted 5 lines
Quoted 3 lines
Please don't give people the option of eliding either the time or the date; I've spent too much time dealing with syslog files that don't include the year in the timestamps.
I understand that, but see above.
When we pretty-print a ktime_t, we probably want to leave out the high fields as well, as this often refers to a time interval, e.g. a few seconds. Even for absolute values, the start of ktime_t is usually not the 1970 epoch but system boot, so we may not necessarily want the higher fields. I hoped to find some inspiration in the 'date' man page, which contains a lot of formatting options, but it's hard to translate that into a useful format string within the constraints of %p flags in printk.
Arnd
Andy Shevchenko
reviewerRe: [PATCH v1 04/25] lib/vsprintf: Print time and date in human readable format via %pt
Quoted 36 lines · Arnd Bergmann
Quoted 15 lines · Andy Shevchenko
Quoted 13 lines · Rasmus Villemoes
Quoted 11 lines · Andy Shevchenko
Quoted 3 lines · Alexandre Belloni
Quoted 2 lines · Andy Shevchenko
On Thu, Jun 8, 2017 at 6:05 PM, Alexandre Belloni
<[email protected]> wrote:Yeah, but the problem is to pass the reference. All dances around will
uglify the code.
(Obviously we can't pass timespec64/time64_t or anything longer than
32 bits as is in %p extension)Quoted 8 lines
Quoted 6 lines
I like that this gets rid of some
mm/dd/yyand other more or less random
format and ends up standardizing yyyy-mm-dd HH:MM:SS. However, I do
think %pt should take eitherktime_tor timespec64 (obviously by reference),I will try to look in this direction.
sounds good.
Quoted 7 lines
Quoted 5 lines
Please don't give people the option of eliding either the time or the
date; I've spent too much time dealing with syslog files that don't
include the year in the timestamps.I understand that, but see above.
Quoted 9 lines
When we pretty-print a
ktime_t, we probably want to leave out the high fields as well, as this often refers to a time interval, e.g. a few seconds.
Even for absolute values, the start ofktime_tis usually not the 1970 epoch but system boot, so we may not necessarily want the higher fields. I hoped to find some inspiration in the 'date' man page, which contains a lot of formatting options, but it's hard to translate that into
a useful format string within the constraints of %p flags in printk.
Rasmus et al.,
Summarizing this discussion I would go forward with the following
- add one more letter in the format to provide argument type (timespec, ktime, ...)
- make a config option to enable / disable this facility and select it by users (and/or make it visible for configuration?)
- still leave possibility to print either date or time or both
- add suffix to print nanoseconds in cases where input has them (and output is not just plain date)
- address other (technical) comments
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Arnd Bergmann
maintainerRe: [PATCH v1 04/25] lib/vsprintf: Print time and date in human readable format via %pt
In reply to Andy ShevchenkoQuoted 6 lines · Andy Shevchenko
Quoted 5 lines · Arnd Bergmann
Quoted 3 lines · Andy Shevchenko
There are users which print time and date represented by content of struct
rtc_timein human readable format.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Instead of open coding that each time introduce %pt[dt][rv] specifier.
I really like the idea, and the implementation seems fine for this use case, but before we reserve %pt for
rtc_time, could we discuss whether we want that for printing struct tm, struct timespec64,time64_torktime_tinstead?How many users?
It's hard to predict, I would assume we get more users once there is an easy way to print the time.
Quoted 1 line
For struct tm it's somelike 4 (which want to print its content).
Good point. I notice that they all convert from time64_t or time_t into struct tm immediately before printing it, so we can scratch that one as long as there is a way to pretty-print a time64_t. We also don't need to print a time_t as we want to kill that one off anyway.
If we only care about printing time64_t and rtc_time, we can easily use %pT for one and %pt for the other, but there may still be good reasons to print a timespec64 or ktime_t.
Quoted 9 lines
Quoted 6 lines
I can see good reasons for pretty-printing any of them, but the namespace for format strings is rather limited.
struct
rtc_timeis almost the same as struct tm (the former has one extra member), so maybe we can actually define them to be the same and use one format string for both?The reason I decide to drop struct tm for now due to they are not compatible and I have got an interesting bugs.
Ok.
Arnd
Re: [PATCH v1 04/25] lib/vsprintf: Print time and date in human readable format via %pt
Quoted 21 lines · Arnd Bergmann
Quoted 6 lines · Andy Shevchenko
Quoted 5 lines · Arnd Bergmann
Quoted 3 lines · Andy Shevchenko
There are users which print time and date represented by content of struct
rtc_timein human readable format.Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Instead of open coding that each time introduce %pt[dt][rv] specifier.
I really like the idea, and the implementation seems fine for this use case, but before we reserve %pt for
rtc_time, could we discuss whether we want that for printing struct tm, struct timespec64,time64_torktime_tinstead?How many users?
It's hard to predict, I would assume we get more users once there is an easy way to print the time.
Quoted 1 line
For struct tm it's somelike 4 (which want to print its content).
Quoted 11 lines
Good point. I notice that they all convert from
time64_tortime_tinto struct tm immediately before printing it, so we can scratch that one as long as there is a way to pretty-print atime64_t. We also don't need to print atime_tas we want to kill that one off anyway.If we only care about printing
time64_tandrtc_time, we can easily use %pT for one and %pt for the other, but there may still be good reasons to print a timespec64 orktime_t.Quoted 2 lines
Quoted 2 lines
I can see good reasons for pretty-printing any of them, but the namespace for format strings is rather limited.
The kernel already uses different types for the same leading letter. For
instance: %pI4 vs %pI6, %pap vs %pad
A single 't' letter could do reasonably well.
Re: [PATCH v1 04/25] lib/vsprintf: Print time and date in human readable format via %pt
In reply to Arnd BergmannQuoted 6 lines · Arnd Bergmann
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Arnd Bergmann
On Thu, Jun 8, 2017 at 3:47 PM, Andy Shevchenko
<[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I really like the idea, and the implementation seems fine for this use case, but before we reserve %pt for
rtc_time, could we discuss whether we want that for printing struct tm, struct timespec64,time64_torktime_tinstead?How many users?
It's hard to predict, I would assume we get more users once there is an easy way to print the time.
So, at least for now we can guess using existing users, right?
I don't check yet how to calculate those cases of time64_t, timespec64, ktime_t and alike if they are about pretty ptintong time and date.
I'm speculating that there are (almost) none.
Quoted 10 lines
Quoted 1 line
For struct tm it's somelike 4 (which want to print its content).
Good point. I notice that they all convert from
time64_tortime_tinto struct tm immediately before printing it, so we can scratch that one as long as there is a way to pretty-print atime64_t. We also don't need to print atime_tas we want to kill that one off anyway.If we only care about printing
time64_tandrtc_time, we can easily use %pT for one and %pt for the other, but there may still be good reasons to print a timespec64 orktime_t.
No need, we may still use 3rd/4th letter in the format for that.
%pt(t/d) time/date + whatever modifications, like raw, validate, timespec, etc.
's' for timespec64, for example.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v1 04/25] lib/vsprintf: Print time and date in human readable format via %pt
Quoted 33 lines · Andy Shevchenko
Quoted 9 lines · Arnd Bergmann
Quoted 7 lines · Andy Shevchenko
Quoted 5 lines · Arnd Bergmann
On Thu, Jun 8, 2017 at 3:47 PM, Andy Shevchenko <[email protected]> wrote:
I really like the idea, and the implementation seems fine for this use case, but before we reserve %pt forrtc_time, could we discuss whether we want that for printing struct tm, struct timespec64,time64_torktime_tinstead?Quoted 4 lines
Quoted 1 line
How many users?
It's hard to predict, I would assume we get more users once there is an easy way to print the time.
So, at least for now we can guess using existing users, right?
I don't check yet how to calculate those cases of
time64_t, timespec64,ktime_tand alike if they are about pretty ptintong time and date.
I'm speculating that there are (almost) none.Quoted 10 lines
Quoted 1 line
For struct tm it's somelike 4 (which want to print its content).
Good point. I notice that they all convert from
time64_tortime_tinto struct tm immediately before printing it, so we can scratch that one as long as there is a way to pretty-print atime64_t. We also don't need to print atime_tas we want to kill that one off anyway.If we only care about printing
time64_tandrtc_time, we can easily use %pT for one and %pt for the other, but there may still be good reasons to print a timespec64 orktime_t.
Quoted 5 lines
No need, we may still use 3rd/4th letter in the format for that.
%pt(t/d) time/date + whatever modifications, like raw, validate, timespec, etc.
's' for timespec64, for example.
My preference would be for %pt[type]<output style> where <type> is mandatory and could be:
r for struct rtc_time
6 for time64_t
k for ktime_t
T for struct timespec64
etc
and <output style> has an unspecified default of
YYYY-MM-DD:hh:mm:ss
Perhaps use the "date" formats without the leading % uses for <output style> for additional styles.
Andy Shevchenko
reviewerPATCH 5/25 ds1302: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- drivers/char/ds1302.c | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-)
drivers/char/ds1302.c +10 -28
@@ -4,7 +4,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 *! *! --------------------------------------------------------------------------- *!
@@ -257,31 +257,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 = {
@@ -298,6 +273,7 @@ static int __initds1302_probe (void) {int retval, res, baur; +struct rtc_time tm; baur=(boot_cpu_data.bus_clock/(2 *1000 *1000 ));
@@ -319,8 +295,14 @@ ds1302_probe(void)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: %ptt\n" , &tm); +printk ("rtc_date\t: %ptd\n" , &tm); retval =1 ; }else {printk ("%s: RTC not found.\n" , ds1302_name);
Signature · 1 line
2.11.0
Re: [PATCH v1 05/25] ds1302: Switch to use %pt
Quoted 5 lines · Andy Shevchenko
Use %pt instead of open coded variant to print content of struct
rtc_timein human readable format.Cc Arnd Bergmann <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Andy Shevchenko
reviewerPATCH 6/25 rtc: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
Arnd Bergmann <[email protected]>
--- drivers/char/rtc.c | 7 +++---- drivers/rtc/hctosys.c | 8 ++------ drivers/rtc/interface.c | 8 ++------ drivers/rtc/rtc-proc.c | 36 +++++------------------------------- drivers/rtc/rtc-sysfs.c | 12 ++++-------- 5 files changed, 16 insertions(+), 55 deletions(-)
drivers/char/rtc.c +3 -4
@@ -1231,11 +1231,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: %ptt\n" +"rtc_date\t: %ptd\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);
drivers/rtc/hctosys.c +2 -6
@@ -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 %pt UTC (%lld)\n" , + &tm, (long long )tv64.tv_sec); err_read:rtc_class_close (rtc);
drivers/rtc/interface.c +2 -6
@@ -288,12 +288,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: %pt\n" , &alarm->time);return err; }
drivers/rtc/rtc-proc.c +5 -31
@@ -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: %ptt\n" +"rtc_date\t: %ptd\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: %pttv\n" , &alrm.time); +seq_printf (seq,"alrm_date\t: %ptdv\n" , &alrm.time);seq_printf (seq,"alarm_IRQ\t: %s\n" , alrm.enabled ?"yes" :"no" ); seq_printf(seq, "alrm_pending\t: %s\n",
drivers/rtc/rtc-sysfs.c +4 -8
@@ -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,"%ptd\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,"%ptt\n" , &tm);return retval; }
Signature · 1 line
2.11.0
Re: [PATCH v1 06/25] rtc: Switch to use %pt
Quoted 4 lines · Andy Shevchenko
Use %pt instead of open coded variant to print content of struct
rtc_timein human readable format.Arnd Bergmann <[email protected]>
Quoted 1 line
Signed-off-by Andy Shevchenko <[email protected]>
Re: [PATCH v1 06/25] rtc: Switch to use %pt
Quoted 7 lines · Greg Kroah-Hartman
Quoted 4 lines · Andy Shevchenko
Use %pt instead of open coded variant to print content of struct
rtc_timein human readable format.Arnd Bergmann <[email protected]>
Cc ?
Yep!
Fixed locally, will be in next version of the series.
Quoted 4 lines
Quoted 2 lines
Signed-off-by Andy Shevchenko <[email protected]>
Thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Andy Shevchenko
reviewerPATCH 7/25 rtc: at91rm9200: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- drivers/rtc/rtc-at91rm9200.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/rtc/rtc-at91rm9200.c +4 -12
@@ -151,9 +151,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(): %pt\n" , __func__, tm);return 0 ; }
@@ -165,9 +163,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(): %pt\n" , __func__, tm);wait_for_completion (&at91_rtc_upd_rdy);
@@ -214,9 +210,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(): %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(): %pt\n" , __func__, tm);return 0 ; }
@@ -254,9 +248,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__, - at91_alarm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, - tm.tm_min, tm.tm_sec); +dev_dbg (dev,"%s(): %pt\n" , __func__, &tm);return 0 ; }
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 8/25 rtc: at91sam9: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- drivers/rtc/rtc-at91sam9.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/rtc/rtc-at91sam9.c +4 -12
@@ -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: %pt\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: %pt\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: %pt\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: %pt\n" , __func__, tm);return 0 ; }
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 9/25 rtc: m41t80: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- drivers/rtc/rtc-m41t80.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/rtc/rtc-m41t80.c +1 -5
@@ -978,11 +978,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 %pt\n" , &tm); } rc =i2c_smbus_write_byte_data (client,M41T80_REG_ALARM_HOUR , rc & ~M41T80_ALHOUR_HT );
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 10/25 rtc: m48t59: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- drivers/rtc/rtc-m48t59.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/rtc/rtc-m48t59.c +2 -6
@@ -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 %pt\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 %pt\n" , tm);return rtc_valid_tm (tm); }
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 11/25 rtc: mcp795: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- drivers/rtc/rtc-mcp795.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/rtc/rtc-mcp795.c +6 -12
@@ -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: %pt\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: %pt\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: %ptdr(%d) %ptt\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: %ptdr(%d) %ptt\n" , + &alm->time, alm->time.tm_wday, &alm->time);return 0 ; }
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 12/25 rtc: pcf50633: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- drivers/rtc/rtc-pcf50633.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/rtc/rtc-pcf50633.c +2 -6
@@ -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: %ptr\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: %ptr\n" , tm);rtc2pcf_time (&pcf_tm, tm);
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 13/25 rtc: pic32: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- drivers/rtc/rtc-pic32.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/rtc/rtc-pic32.c +4 -14
@@ -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 %pt\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 %pt\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, %pt\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, %pt\n" , alrm->enabled, tm);writel (0x00 , base +PIC32_ALRMTIME );writel (0x00 , base +PIC32_ALRMDATE );
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 14/25 rtc: pm8xxx: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- drivers/rtc/rtc-pm8xxx.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/rtc/rtc-pm8xxx.c +5 -11
@@ -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 == %ptt, y-m-d = %ptdr\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=%ptt, y-m-d=%ptdr\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=%ptt, y-m-d=%ptdr\n" , + &alarm->time, &alarm->time);return 0 ; }
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 15/25 rtc: puv3: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
Guan Xuetao <[email protected]>
--- drivers/rtc/rtc-puv3.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/rtc/rtc-puv3.c +4 -14
@@ -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 %ptr\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 %ptr\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, %ptr\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, %ptr\n" , alrm->enabled, tm);rtc_tm_to_time (tm, &rtcalarm_count);writel (rtcalarm_count,RTC_RTAR );
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 16/25 rtc: rk808: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- drivers/rtc/rtc-rk808.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/rtc/rtc-rk808.c +6 -14
@@ -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 %ptd(%d) %ptt\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 %ptd(%d) %ptt\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 %ptd(%d) %ptt\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 %ptd(%d) %ptt\n" , + &alrm->time, alrm->time.tm_wday, &alrm->time);gregorian_to_rockchip (&alrm->time); alrm_data[0 ] =bin2bcd (alrm->time.tm_sec);
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 17/25 rtc: rx6110: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- drivers/rtc/rtc-rx6110.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/rtc/rtc-rx6110.c +3 -9
@@ -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 %ptr\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 %ptr\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 %ptr\n" , __func__, tm);return rtc_valid_tm (tm); }
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 18/25 rtc: rx8025: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- drivers/rtc/rtc-rx8025.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/rtc/rtc-rx8025.c +4 -15
@@ -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 %ptr\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: %ptr\n" , __func__, t); t->enabled = !!(rx8025->ctrl1 &RX8025_BIT_CTRL1_DALE ); t->pending = (ctrl2 &RX8025_BIT_CTRL2_DAFG ) && t->enabled;
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 19/25 rtc: s3c: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- drivers/rtc/rtc-s3c.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
drivers/rtc/rtc-s3c.c +5 -16
@@ -197,13 +197,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 %pt\n" , rtc_tm); +return rtc_valid_tm (rtc_tm); }
@@ -212,9 +209,7 @@ static int s3c_rtc_settime(struct device *dev, struct rtc_time *tm)struct s3c_rtc *info =dev_get_drvdata (dev);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 %pt\n" , tm);/* we get around y2k by simply not supporting it */
@@ -258,10 +253,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, %pt\n" , alm_en, alm_tm);/* decode the alarm enable field */ if (alm_en &S3C2410_RTCALM_SECEN )
@@ -294,10 +286,7 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)unsigned int alrm_en;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, %pt\n" , alrm->enabled, tm);s3c_rtc_enable_clk (info);
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 20/25 rtc: s5m: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- drivers/rtc/rtc-s5m.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-)
drivers/rtc/rtc-s5m.c +6 -21
@@ -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: %pt(%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: %pt(%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: %pt(%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: %pt(%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: %pt(%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: %pt(%d)\n" , __func__, &alrm->time, alrm->time.tm_wday); ret =s5m_rtc_stop_alarm (info);if (ret <0 )
Signature · 1 line
2.11.0
Re: [PATCH v1 20/25] rtc: s5m: Switch to use %pt
Quoted 10 lines · Andy Shevchenko
Use %pt instead of open coded variant to print content of struct
rtc_timein human readable format.Cc Krzysztof Kozlowski <[email protected]>Cc Bartlomiej Zolnierkiewicz <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- drivers/rtc/rtc-s5m.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-)
Best regards,
Krzysztof
Andy Shevchenko
reviewerPATCH 21/25 rtc: tegra: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- drivers/rtc/rtc-tegra.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-)
drivers/rtc/rtc-tegra.c +3 -27
@@ -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. %pt\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. %pt\n" , sec, tm);/* seconds only written if wait succeeded. */ ret =tegra_rtc_wait_while_busy (dev);
@@ -234,16 +218,8 @@ static int tegra_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)/* if successfully written and alarm is enabled ... */ if (sec) { +dev_vdbg (dev,"alarm set as %lu. %pt\n" , sec, &alarm->time);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); }else {/* disable alarm if 0 or write error. */ dev_vdbg (dev,"alarm disabled\n" );
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 22/25 mk68/mac: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- arch/m68k/mac/misc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/m68k/mac/misc.c +2 -6
@@ -660,13 +660,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 %pt\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 %pt\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);
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 23/25 Input: hp_sdc_rtc - Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- drivers/input/misc/hp_sdc_rtc.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/input/misc/hp_sdc_rtc.c +3 -5
@@ -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: %ptt\n" +"rtc_date\t: %ptd\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)) {
Signature · 1 line
2.11.0
Andy Shevchenko
reviewerPATCH 24/25 kdb: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- kernel/debug/kdb/kdb_main.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
kernel/debug/kdb/kdb_main.c +1 -6
@@ -2556,12 +2556,7 @@ static int kdb_summary(int argc, const char **argv) now =__current_kernel_time ();kdb_gmtime (&now, &tm); -kdb_printf ("date %04d-%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 %pt tz_minuteswest %d\n" , &tm, sys_tz.tz_minuteswest);kdb_sysinfo (&val);kdb_printf ("uptime " );if (val.uptime > (24 *60 *60 )) {
Signature · 1 line
2.11.0
Re: [PATCH v1 24/25] kdb: Switch to use %pt
Quoted 6 lines · Andy Shevchenko
Use %pt instead of open coded variant to print content of struct
rtc_timein human readable format.Cc Jason Wessel <[email protected]>Cc Ingo Molnar <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Quoted 23 lines
--- kernel/debug/kdb/kdb_main.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)kernel/debug/kdb/kdb_main.c +1
-6@@ -2556,12 +2556,7 @@ static int kdb_summary(int argc, const char **argv) now =__current_kernel_time ();kdb_gmtime (&now, &tm); -kdb_printf ("date %04d-%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 %pt tz_minuteswest %d\n" , &tm, sys_tz.tz_minuteswest);kdb_sysinfo (&val);kdb_printf ("uptime " );if (val.uptime > (24 *60 *60 )) {
Arnd Bergmann
maintainerRe: [PATCH v1 24/25] kdb: Switch to use %pt
In reply to Andy ShevchenkoQuoted 5 lines · Andy Shevchenko
kernel/debug/kdb/kdb_main.c +0
-0
kernel/debug/kdb/kdb_main.c static int kdb_summary(int argc, const char **argv) · line 2564
Quoted 9 lines
kernel/debug/kdb/kdb_main.c +0
-6@@ -2556,12 +2556,7 @@ static int kdb_summary(int argc, const char **argv) now =__current_kernel_time ();kdb_gmtime (&now, &tm); -kdb_printf ("date %04d-%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); -
I just experimented with a similar change and noticed your version.
You forgot to remove the kdb_gmtime() function that is now completely unneeded. My patch takes care of that now.
Arnd
Andy Shevchenko
reviewerRe: [PATCH v1 24/25] kdb: Switch to use %pt
Quoted 22 lines · Arnd Bergmann
Quoted 6 lines · Andy Shevchenko
kernel/debug/kdb/kdb_main.c +0
-0kernel/debug/kdb/kdb_main.c static int kdb_summary(int argc, const char · line 2565
Quoted 10 lines
kernel/debug/kdb/kdb_main.c +0
-6@@ -2556,12 +2556,7 @@ static int kdb_summary(int argc, const char **argv) now =__current_kernel_time ();kdb_gmtime (&now, &tm); -kdb_printf ("date %04d-%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); -I just experimented with a similar change and noticed your version.
Quoted 2 lines
You forgot to remove the
kdb_gmtime()function that is now completely unneeded. My patch takes care of that now.
So, are you going to substitute entire series by your variant?
What did you choose to be format for the %p extension?
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Arnd Bergmann
maintainerRe: [PATCH v1 24/25] kdb: Switch to use %pt
Quoted 23 lines · Andy Shevchenko
Quoted 22 lines · Arnd Bergmann
Quoted 6 lines · Andy Shevchenko
kernel/debug/kdb/kdb_main.c +0
-0kernel/debug/kdb/kdb_main.c static int kdb_summary(int argc, const char · line 2565
Quoted 10 lines
kernel/debug/kdb/kdb_main.c +0
-6@@ -2556,12 +2556,7 @@ static int kdb_summary(int argc, const char **argv) now =__current_kernel_time ();kdb_gmtime (&now, &tm); -kdb_printf ("date %04d-%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); -I just experimented with a similar change and noticed your version.
Quoted 6 lines
Quoted 2 lines
You forgot to remove the
kdb_gmtime()function that is now completely unneeded. My patch takes care of that now.So, are you going to substitute entire series by your variant?
What did you choose to be format for the %p extension?
My patch doesn't touch printf at all, instead it removes the __current_kernel_time() function, so it's unrelated but happens to change the same lines here. Since kdb_gmtime() doesn't work with 64-bit time_t, I replaced it using the generic time64_to_tm() helper and removed it here.
Arnd
Andy Shevchenko
reviewerPATCH 25/25 PM: Switch to use %pt
In reply to Andy ShevchenkoUse %pt instead of open coded variant to print content of struct rtc_time in human readable format.
--- drivers/base/power/trace.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/base/power/trace.c +1 -3
@@ -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: %ptt, date: %ptd\n" , &time, &time); val = time.tm_year;/* 100 years */ if (val >100 ) val -=100 ;
Signature · 1 line
2.11.0
Re: [PATCH v1 25/25] PM: Switch to use %pt
Quoted 6 lines · Andy Shevchenko
Use %pt instead of open coded variant to print content of struct
rtc_timein human readable format.Cc "Rafael J. Wysocki" <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Quoted 22 lines
--- drivers/base/power/trace.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/base/power/trace.c +1
-4@@ -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: %ptt, date: %ptd\n" , &time, &time); val = time.tm_year;/* 100 years */ if (val >100 ) val -=100 ; --2.11.0
Quoted 15 lines · Andy Shevchenko
Recently I have noticed too many users of struct
rtc_timethat printing its content field by field.In this series I introduce %pt[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].
Quoted 5 lines
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.
What I wonder about this series is how much larger it makes a typical kernel and how often multiple rtc clocks are built for a single kernel?
What is the size impact on an embedded kernel that uses a single rtc driver?
trivia:
Aren't there also uses of struct tm that are nearly identical?
e.g.: drivers/usb/host/xhci-tegra.c
Quoted 19 lines · Joe Perches
Quoted 18 lines · Andy Shevchenko
Recently I have noticed too many users of struct
rtc_timethat printing its content field by field.In this series I introduce %pt[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 :-)
Quoted 7 lines
Quoted 2 lines
Most of the users currently are RTC drivers, thus the patch series is assumed to go via RTC tree.
What I wonder about this series is how much larger it makes a typical kernel and how often multiple rtc clocks are built for a single kernel?
We may hide it under CONFIG_RTC_??? if we want to reduce kernel for non RTC cases.
Quoted 2 lines
What is the size impact on an embedded kernel that uses a single rtc driver?
I would
Quoted 1 line
trivia:
Actually not. See my answer to Arnd. I have patches for 4 users of struct tm, but it should be converted first to struct rtc_time first (otherwise it might uglify the code due to endianess of tm_year memeber)
Quoted 5 lines
Aren't there also uses of struct tm that are nearly identical?
e.g.:
drivers/usb/host/xhci-tegra.c
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 7 lines · Andy Shevchenko
Quoted 6 lines · Joe Perches
Quoted 5 lines · Andy Shevchenko
Recently I have noticed too many users of struct
rtc_timethat printing its content field by field.In this series I introduce %pt[dt][rv] specifier to make life a bit easier.
[]
Quoted 10 lines
Quoted 7 lines
Quoted 2 lines
Most of the users currently are RTC drivers, thus the patch series is assumed to go via RTC tree.
What I wonder about this series is how much larger it makes a typical kernel and how often multiple rtc clocks are built for a single kernel?
We may hide it under
CONFIG_RTC_??? if we want to reduce kernel for non RTC cases.
Depends whether it is for rtc_time only
Quoted 4 lines
Quoted 2 lines
What is the size impact on an embedded kernel that uses a single rtc driver?
I would
You would what?
Quoted 5 lines · Andy Shevchenko
Recently I have noticed too many users of struct
rtc_timethat printing its content field by field.In this series I introduce %pt[dt][rv] specifier to make life a bit easier.
Hey Andy.
I just saw a patch with a printk for rtc time from Mark Salyzyn.
https://lkml.org/lkml/2017/7/18/885
Any idea if you want to push this extension?
I like the concept and still think it could be extended a bit more.
from: https://lkml.org/lkml/2017/6/8/1134
My preference would be for %pt[type]<output style> where <type> is mandatory and could be:
r for struct rtc_time
6 for time64_t
k for ktime_t
T for struct timespec64
etc
and <output style> has an unspecified default of
YYYY-MM-DD:hh:mm:ss
Perhaps use the "date" formats without the leading % uses for <output style> for additional styles.
Andy Shevchenko
reviewerQuoted 5 lines · Joe Perches
Quoted 4 lines · Andy Shevchenko
Recently I have noticed too many users of struct
rtc_timethat printing
its content field by field.
Quoted 7 lines
Quoted 2 lines
In this series I introduce %pt[dt][rv] specifier to make life a bit easier.
Hey Andy.
I just saw a patch with a printk for rtc time from Mark Salyzyn.
https://lkml.org/lkml/2017/7/18/885
Same!
Quoted 1 line
Any idea if you want to push this extension?
Yes, just really lack of time for everything.
I like the idea to make it conditional (config BLABLABLA). It will address some comments about footprint for no users.
Quoted 4 lines
I like the concept and still think it could be extended a bit more.
Quoted 8 lines
My preference would be for %pt[type]<output style> where <type> is mandatory and could be:
r for struct
rtc_time
6 fortime64_t
k forktime_t
T for struct timespec64
etc
I dunno about this.
However, I like this more than do conversion in each case where input reference has different type.
Quoted 2 lines
and <output style> has an unspecified default of
YYYY-MM-DD:hh:mm:ss
I'm against this, sorry. Too many variations for almost no use (users).
Quoted 2 lines
Perhaps use the "date" formats without the leading % uses for <output style> for additional styles.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 14 lines · Andy Shevchenko
Quoted 5 lines · Joe Perches
Quoted 4 lines · Andy Shevchenko
Recently I have noticed too many users of struct
rtc_timethat printing
its content field by field.Quoted 7 lines
Quoted 2 lines
In this series I introduce %pt[dt][rv] specifier to make life a bit easier.
Hey Andy.
I just saw a patch with a printk for rtc time from Mark Salyzyn.
https://lkml.org/lkml/2017/7/18/885
Quoted 8 lines
Same!
Quoted 1 line
Any idea if you want to push this extension?
Yes, just really lack of time for everything.
I like the idea to make it conditional (config BLABLABLA). It will address some comments about footprint for no users.
Only one of the other %p<foo> extensions is conditional and that
conditional is probably not too useful.
I think the code size is relatively small and not particularly valuable for the additional complexity.
For instance, all of the code that emits MAC and IP[46] addresses %pM and %pI variants is 2.5K. (x86 allnoconfig)
There are lots more code size savings than that lying about.
And auditing all the code that might emit a MAC address when CONFIG_NET is not set is probably not worth the effort for the size reduction.
$ size lib/vsprintf.o* text data bss dec hex filename 12140 4 0 12144 2f70 lib/vsprintf.o.allnoconfig.new 14785 4 0 14789 39c5 lib/vsprintf.o.allnoconfig.old --- lib/vsprintf.c | 4 ++++ 1 file changed, 4 insertions(+)
lib/vsprintf.c +4 -0
@@ -933,6 +933,7 @@ char *bitmap_list_string(char *buf, char *end, unsigned long *bitmap,return buf; } +#ifdef CONFIG_NET static noinline_for_stack char *mac_address_string(char *buf, char *end, u8 *addr,struct printf_spec spec,const char *fmt)
@@ -1241,6 +1242,7 @@ char *ip4_addr_string_sa(char *buf, char *end, const struct sockaddr_in *sa,return string (buf, end, ip4_addr, spec); } +#endif static noinline_for_stack char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec,
@@ -1741,6 +1743,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,default :return bitmap_string (buf, end, ptr, spec, fmt); } +#ifdef CONFIG_NET case 'M' :/* Colon separated: 00:01:02:03:04:05 */ case 'm' :/* Contiguous: 000102030405 */ /* [mM]F (FDDI) */
@@ -1777,6 +1780,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, }} }break ; +#endif case 'E' :return escaped_string (buf, end, ptr, spec, fmt);case 'U' :
Quoted 26 lines · Joe Perches
Quoted 5 lines · Andy Shevchenko
Recently I have noticed too many users of struct
rtc_timethat printing its content field by field.In this series I introduce %pt[dt][rv] specifier to make life a bit easier.
Hey Andy.
I just saw a patch with a printk for rtc time from Mark Salyzyn.
https://lkml.org/lkml/2017/7/18/885Any idea if you want to push this extension?
I like the concept and still think it could be extended a bit more.
from: https://lkml.org/lkml/2017/6/8/1134
My preference would be for %pt[type]<output style> where <type> is mandatory and could be:
r for struct
rtc_time
6 fortime64_t
k forktime_t
T for struct timespec64
etc
Quoted 6 lines
and <output style> has an unspecified default of
YYYY-MM-DD:hh:mm:ssPerhaps use the "date" formats without the leading % uses for <output style> for additional styles.
YYYY-MM-DD hh:mm:ss.nnnnnnnnn ?
Andy Shevchenko
reviewerQuoted 30 lines · Mark Salyzyn
Quoted 29 lines · Joe Perches
Quoted 7 lines · Andy Shevchenko
Recently I have noticed too many users of struct
rtc_timethat printing
its content field by field.In this series I introduce %pt[dt][rv] specifier to make life a bit
easier.Hey Andy.
I just saw a patch with a printk for rtc time from Mark Salyzyn.
https://lkml.org/lkml/2017/7/18/885Any idea if you want to push this extension?
I like the concept and still think it could be extended a bit more.
from: https://lkml.org/lkml/2017/6/8/1134
My preference would be for %pt[type]<output style> where <type> is mandatory and could be:
r for struct
rtc_time
6 fortime64_t
k forktime_t
T for struct timespec64
etc
Quoted 8 lines
Quoted 6 lines
and <output style> has an unspecified default of
YYYY-MM-DD:hh:mm:ssPerhaps use the "date" formats without the leading % uses for <output style> for additional styles.
YYYY-MM-DD hh:mm:ss.nnnnnnnnn ?
As a separate modifier, yes.
See my answer to subthread in patch 4.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 33 lines · Andy Shevchenko
Quoted 32 lines · Mark Salyzyn
Quoted 31 lines · Joe Perches
Quoted 7 lines · Andy Shevchenko
Recently I have noticed too many users of struct
rtc_timethat printing
its content field by field.In this series I introduce %pt[dt][rv] specifier to make life a bit
easier.Hey Andy.
I just saw a patch with a printk for rtc time from Mark Salyzyn.
https://lkml.org/lkml/2017/7/18/885Any idea if you want to push this extension?
I like the concept and still think it could be extended a bit more.
from: https://lkml.org/lkml/2017/6/8/1134
My preference would be for %pt[type]<output style> where <type> is mandatory and could be:
r for struct
rtc_time
6 fortime64_t
k forktime_t
T for struct timespec64
etcand <output style> has an unspecified default of
YYYY-MM-DD:hh:mm:ss
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Perhaps use the "date" formats without the leading % uses for <output style> for additional styles.
YYYY-MM-DD hh:mm:ss.nnnnnnnnn ?
As a separate modifier, yes.
See my answer to subthread in patch 4.
It would probably need to take struct timespec64 as an argument. Pass by structure might be difficult to swallow, so pass by pointer?
As for my need for this in my suspend/resume/hibernate/restore patch set, we have already been told three times to _not_ report wall clock time. I could imagine being a consumer of it in the future if we have difficulty migrating the analysis tools ... so tepid support from me.
-- Mark
Quoted 2 lines · Mark Salyzyn
It would probably need to take struct timespec64 as an argument. Pass by structure might be difficult to swallow, so pass by pointer?
Every %p<foo> extension is passed via a pointer.