diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-01-01 16:24:31 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-01-01 16:24:31 -0500 |
commit | 28e8c4bc8eb483c22d977e147a0b98fc63efadf7 (patch) | |
tree | 8006dd759601c70d4dd1fc644ed817e9597cec55 /lib/test_printf.c | |
parent | c9bef4a651769927445900564781a9c99fdf6258 (diff) | |
parent | 36e14f5fdfdf7cec8887b7ff69cd9bb5051ecf62 (diff) |
Merge tag 'rtc-4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
Pull RTC updates from Alexandre Belloni:
"Subsystem:
- new %ptR printk format
- rename core files
- allow registration of multiple nvmem devices
New driver:
- i.MX system controller RTC
Driver updates:
- abx80x: handle voltage ioctls, correct binding doc
- m41t80: correct month in alarm reads
- pcf85363: add pcf85263 support
- pcf8523: properly handle battery low flag
- s3c: limit alarm to one year in the future as ALMYEAR is broken
- sun6i: rework clock output binding"
* tag 'rtc-4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (54 commits)
rtc: rename core files
rtc: nvmem: fix possible use after free
rtc: add i.MX system controller RTC support
dt-bindings: fsl: scu: add rtc binding
rtc: pcf2123: Add Microcrystal rv2123
rtc: class: reimplement devm_rtc_device_register
rtc: enforce rtc_timer_init private_data type
rtc: abx80x: Implement RTC_VL_READ,CLR ioctls
rtc: pcf85363: Add support for NXP pcf85263 rtc
dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock
rtc: pcf8523: don't return invalid date when battery is low
dt-bindings: rtc: use a generic node name for ds1307
PM: Switch to use %ptR
m68k/mac: Switch to use %ptR
Input: hp_sdc_rtc - Switch to use %ptR
rtc: tegra: Switch to use %ptR
rtc: s5m: Switch to use %ptR
rtc: s3c: Switch to use %ptR
rtc: rx8025: Switch to use %ptR
rtc: rx6110: Switch to use %ptR
...
Diffstat (limited to 'lib/test_printf.c')
-rw-r--r-- | lib/test_printf.c | 61 |
1 files changed, 58 insertions, 3 deletions
diff --git a/lib/test_printf.c b/lib/test_printf.c index 53527ea822b5..659b6cc0d483 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
10 | #include <linux/printk.h> | 10 | #include <linux/printk.h> |
11 | #include <linux/random.h> | 11 | #include <linux/random.h> |
12 | #include <linux/rtc.h> | ||
12 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
13 | #include <linux/string.h> | 14 | #include <linux/string.h> |
14 | 15 | ||
@@ -249,12 +250,11 @@ plain_format(void) | |||
249 | #endif /* BITS_PER_LONG == 64 */ | 250 | #endif /* BITS_PER_LONG == 64 */ |
250 | 251 | ||
251 | static int __init | 252 | static int __init |
252 | plain_hash(void) | 253 | plain_hash_to_buffer(const void *p, char *buf, size_t len) |
253 | { | 254 | { |
254 | char buf[PLAIN_BUF_SIZE]; | ||
255 | int nchars; | 255 | int nchars; |
256 | 256 | ||
257 | nchars = snprintf(buf, PLAIN_BUF_SIZE, "%p", PTR); | 257 | nchars = snprintf(buf, len, "%p", p); |
258 | 258 | ||
259 | if (nchars != PTR_WIDTH) | 259 | if (nchars != PTR_WIDTH) |
260 | return -1; | 260 | return -1; |
@@ -265,6 +265,20 @@ plain_hash(void) | |||
265 | return 0; | 265 | return 0; |
266 | } | 266 | } |
267 | 267 | ||
268 | return 0; | ||
269 | } | ||
270 | |||
271 | |||
272 | static int __init | ||
273 | plain_hash(void) | ||
274 | { | ||
275 | char buf[PLAIN_BUF_SIZE]; | ||
276 | int ret; | ||
277 | |||
278 | ret = plain_hash_to_buffer(PTR, buf, PLAIN_BUF_SIZE); | ||
279 | if (ret) | ||
280 | return ret; | ||
281 | |||
268 | if (strncmp(buf, PTR_STR, PTR_WIDTH) == 0) | 282 | if (strncmp(buf, PTR_STR, PTR_WIDTH) == 0) |
269 | return -1; | 283 | return -1; |
270 | 284 | ||
@@ -295,6 +309,23 @@ plain(void) | |||
295 | } | 309 | } |
296 | 310 | ||
297 | static void __init | 311 | static void __init |
312 | test_hashed(const char *fmt, const void *p) | ||
313 | { | ||
314 | char buf[PLAIN_BUF_SIZE]; | ||
315 | int ret; | ||
316 | |||
317 | /* | ||
318 | * No need to increase failed test counter since this is assumed | ||
319 | * to be called after plain(). | ||
320 | */ | ||
321 | ret = plain_hash_to_buffer(p, buf, PLAIN_BUF_SIZE); | ||
322 | if (ret) | ||
323 | return; | ||
324 | |||
325 | test(buf, fmt, p); | ||
326 | } | ||
327 | |||
328 | static void __init | ||
298 | symbol_ptr(void) | 329 | symbol_ptr(void) |
299 | { | 330 | { |
300 | } | 331 | } |
@@ -419,6 +450,29 @@ struct_va_format(void) | |||
419 | } | 450 | } |
420 | 451 | ||
421 | static void __init | 452 | static void __init |
453 | struct_rtc_time(void) | ||
454 | { | ||
455 | /* 1543210543 */ | ||
456 | const struct rtc_time tm = { | ||
457 | .tm_sec = 43, | ||
458 | .tm_min = 35, | ||
459 | .tm_hour = 5, | ||
460 | .tm_mday = 26, | ||
461 | .tm_mon = 10, | ||
462 | .tm_year = 118, | ||
463 | }; | ||
464 | |||
465 | test_hashed("%pt", &tm); | ||
466 | |||
467 | test("2018-11-26T05:35:43", "%ptR", &tm); | ||
468 | test("0118-10-26T05:35:43", "%ptRr", &tm); | ||
469 | test("05:35:43|2018-11-26", "%ptRt|%ptRd", &tm, &tm); | ||
470 | test("05:35:43|0118-10-26", "%ptRtr|%ptRdr", &tm, &tm); | ||
471 | test("05:35:43|2018-11-26", "%ptRttr|%ptRdtr", &tm, &tm); | ||
472 | test("05:35:43 tr|2018-11-26 tr", "%ptRt tr|%ptRd tr", &tm, &tm); | ||
473 | } | ||
474 | |||
475 | static void __init | ||
422 | struct_clk(void) | 476 | struct_clk(void) |
423 | { | 477 | { |
424 | } | 478 | } |
@@ -529,6 +583,7 @@ test_pointer(void) | |||
529 | uuid(); | 583 | uuid(); |
530 | dentry(); | 584 | dentry(); |
531 | struct_va_format(); | 585 | struct_va_format(); |
586 | struct_rtc_time(); | ||
532 | struct_clk(); | 587 | struct_clk(); |
533 | bitmap(); | 588 | bitmap(); |
534 | netdev_features(); | 589 | netdev_features(); |