Skip to content

Commit 80ae552

Browse files
committed
Merge branch 'for-5.14-vsprintf-pts' into for-linus
2 parents 4249cb7 + 2f9e0f8 commit 80ae552

File tree

6 files changed

+33
-35
lines changed

6 files changed

+33
-35
lines changed

Documentation/core-api/printk-formats.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,10 @@ Time and date
514514
::
515515

516516
%pt[RT] YYYY-mm-ddTHH:MM:SS
517+
%pt[RT]s YYYY-mm-dd HH:MM:SS
517518
%pt[RT]d YYYY-mm-dd
518519
%pt[RT]t HH:MM:SS
519-
%pt[RT][dt][r]
520+
%pt[RT][dt][r][s]
520521

521522
For printing date and time as represented by::
522523

@@ -528,6 +529,10 @@ in human readable format.
528529
By default year will be incremented by 1900 and month by 1.
529530
Use %pt[RT]r (raw) to suppress this behaviour.
530531

532+
The %pt[RT]s (space) will override ISO 8601 separator by using ' ' (space)
533+
instead of 'T' (Capital T) between date and time. It won't have any effect
534+
when date or time is omitted.
535+
531536
Passed by reference.
532537

533538
struct clk

drivers/usb/host/xhci-tegra.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,6 @@ static int tegra_xusb_load_firmware(struct tegra_xusb *tegra)
917917
struct xhci_op_regs __iomem *op;
918918
unsigned long timeout;
919919
time64_t timestamp;
920-
struct tm time;
921920
u64 address;
922921
u32 value;
923922
int err;
@@ -1014,11 +1013,8 @@ static int tegra_xusb_load_firmware(struct tegra_xusb *tegra)
10141013
}
10151014

10161015
timestamp = le32_to_cpu(header->fwimg_created_time);
1017-
time64_to_tm(timestamp, 0, &time);
10181016

1019-
dev_info(dev, "Firmware timestamp: %ld-%02d-%02d %02d:%02d:%02d UTC\n",
1020-
time.tm_year + 1900, time.tm_mon + 1, time.tm_mday,
1021-
time.tm_hour, time.tm_min, time.tm_sec);
1017+
dev_info(dev, "Firmware timestamp: %ptTs UTC\n", &timestamp);
10221018

10231019
return 0;
10241020
}

fs/nilfs2/sysfs.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,6 @@
1919
/* /sys/fs/<nilfs>/ */
2020
static struct kset *nilfs_kset;
2121

22-
#define NILFS_SHOW_TIME(time_t_val, buf) ({ \
23-
struct tm res; \
24-
int count = 0; \
25-
time64_to_tm(time_t_val, 0, &res); \
26-
res.tm_year += 1900; \
27-
res.tm_mon += 1; \
28-
count = scnprintf(buf, PAGE_SIZE, \
29-
"%ld-%.2d-%.2d %.2d:%.2d:%.2d\n", \
30-
res.tm_year, res.tm_mon, res.tm_mday, \
31-
res.tm_hour, res.tm_min, res.tm_sec);\
32-
count; \
33-
})
34-
3522
#define NILFS_DEV_INT_GROUP_OPS(name, parent_name) \
3623
static ssize_t nilfs_##name##_attr_show(struct kobject *kobj, \
3724
struct attribute *attr, char *buf) \
@@ -576,7 +563,7 @@ nilfs_segctor_last_seg_write_time_show(struct nilfs_segctor_attr *attr,
576563
ctime = nilfs->ns_ctime;
577564
up_read(&nilfs->ns_segctor_sem);
578565

579-
return NILFS_SHOW_TIME(ctime, buf);
566+
return sysfs_emit(buf, "%ptTs\n", &ctime);
580567
}
581568

582569
static ssize_t
@@ -604,7 +591,7 @@ nilfs_segctor_last_nongc_write_time_show(struct nilfs_segctor_attr *attr,
604591
nongc_ctime = nilfs->ns_nongc_ctime;
605592
up_read(&nilfs->ns_segctor_sem);
606593

607-
return NILFS_SHOW_TIME(nongc_ctime, buf);
594+
return sysfs_emit(buf, "%ptTs\n", &nongc_ctime);
608595
}
609596

610597
static ssize_t
@@ -724,7 +711,7 @@ nilfs_superblock_sb_write_time_show(struct nilfs_superblock_attr *attr,
724711
sbwtime = nilfs->ns_sbwtime;
725712
up_read(&nilfs->ns_sem);
726713

727-
return NILFS_SHOW_TIME(sbwtime, buf);
714+
return sysfs_emit(buf, "%ptTs\n", &sbwtime);
728715
}
729716

730717
static ssize_t

kernel/debug/kdb/kdb_main.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,7 +2488,6 @@ static void kdb_sysinfo(struct sysinfo *val)
24882488
static int kdb_summary(int argc, const char **argv)
24892489
{
24902490
time64_t now;
2491-
struct tm tm;
24922491
struct sysinfo val;
24932492

24942493
if (argc)
@@ -2502,13 +2501,7 @@ static int kdb_summary(int argc, const char **argv)
25022501
kdb_printf("domainname %s\n", init_uts_ns.name.domainname);
25032502

25042503
now = __ktime_get_real_seconds();
2505-
time64_to_tm(now, 0, &tm);
2506-
kdb_printf("date %04ld-%02d-%02d %02d:%02d:%02d "
2507-
"tz_minuteswest %d\n",
2508-
1900+tm.tm_year, tm.tm_mon+1, tm.tm_mday,
2509-
tm.tm_hour, tm.tm_min, tm.tm_sec,
2510-
sys_tz.tz_minuteswest);
2511-
2504+
kdb_printf("date %ptTs tz_minuteswest %d\n", &now, sys_tz.tz_minuteswest);
25122505
kdb_sysinfo(&val);
25132506
kdb_printf("uptime ");
25142507
if (val.uptime > (24*60*60)) {

lib/test_printf.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,11 @@ time_and_date(void)
528528
test("0119-00-04T15:32:23", "%ptTr", &t);
529529
test("15:32:23|2019-01-04", "%ptTt|%ptTd", &t, &t);
530530
test("15:32:23|0119-00-04", "%ptTtr|%ptTdr", &t, &t);
531+
532+
test("2019-01-04 15:32:23", "%ptTs", &t);
533+
test("0119-00-04 15:32:23", "%ptTsr", &t);
534+
test("15:32:23|2019-01-04", "%ptTts|%ptTds", &t, &t);
535+
test("15:32:23|0119-00-04", "%ptTtrs|%ptTdrs", &t, &t);
531536
}
532537

533538
static void __init

lib/vsprintf.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,7 +1798,8 @@ char *rtc_str(char *buf, char *end, const struct rtc_time *tm,
17981798
struct printf_spec spec, const char *fmt)
17991799
{
18001800
bool have_t = true, have_d = true;
1801-
bool raw = false;
1801+
bool raw = false, iso8601_separator = true;
1802+
bool found = true;
18021803
int count = 2;
18031804

18041805
if (check_pointer(&buf, end, tm, spec))
@@ -1815,14 +1816,25 @@ char *rtc_str(char *buf, char *end, const struct rtc_time *tm,
18151816
break;
18161817
}
18171818

1818-
raw = fmt[count] == 'r';
1819+
do {
1820+
switch (fmt[count++]) {
1821+
case 'r':
1822+
raw = true;
1823+
break;
1824+
case 's':
1825+
iso8601_separator = false;
1826+
break;
1827+
default:
1828+
found = false;
1829+
break;
1830+
}
1831+
} while (found);
18191832

18201833
if (have_d)
18211834
buf = date_str(buf, end, tm, raw);
18221835
if (have_d && have_t) {
1823-
/* Respect ISO 8601 */
18241836
if (buf < end)
1825-
*buf = 'T';
1837+
*buf = iso8601_separator ? 'T' : ' ';
18261838
buf++;
18271839
}
18281840
if (have_t)
@@ -2261,7 +2273,7 @@ early_param("no_hash_pointers", no_hash_pointers_enable);
22612273
* - 'd[234]' For a dentry name (optionally 2-4 last components)
22622274
* - 'D[234]' Same as 'd' but for a struct file
22632275
* - 'g' For block_device name (gendisk + partition number)
2264-
* - 't[RT][dt][r]' For time and date as represented by:
2276+
* - 't[RT][dt][r][s]' For time and date as represented by:
22652277
* R struct rtc_time
22662278
* T time64_t
22672279
* - 'C' For a clock, it prints the name (Common Clock Framework) or address

0 commit comments

Comments
 (0)