Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'printk-for-5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux

Pull printk updates from Petr Mladek:

- Herbert Xu made printk header file self-contained.

- Andy Shevchenko and Sergey Senozhatsky cleaned up console->setup()
error handling.

- Andy Shevchenko did some cleanups (e.g. sparse warning) in vsprintf
code.

- Minor documentation updates.

* tag 'printk-for-5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux:
lib/vsprintf: Force type of flags value for gfp_t
lib/vsprintf: Replace custom spec to print decimals with generic one
lib/vsprintf: Replace hidden BUILD_BUG_ON() with static_assert()
printk: Make linux/printk.h self-contained
doc:kmsg: explicitly state the return value in case of SEEK_CUR
Replace HTTP links with HTTPS ones: vsprintf
hvc: unify console setup naming
console: Fix trivia typo 'change' -> 'chance'
console: Propagate error code from console ->setup()
tty: hvc: Return proper error code from console ->setup() hook
serial: sunzilog: Return proper error code from console ->setup() hook
serial: sunsab: Return proper error code from console ->setup() hook
mips: Return proper error code from console ->setup() hook

+86 -58
+11
Documentation/ABI/testing/dev-kmsg
··· 56 56 seek after the last record available at the time 57 57 the last SYSLOG_ACTION_CLEAR was issued. 58 58 59 + Other seek operations or offsets are not supported because of 60 + the special behavior this device has. The device allows to read 61 + or write only whole variable length messages (records) that are 62 + stored in a ring buffer. 63 + 64 + Because of the non-standard behavior also the error values are 65 + non-standard. -ESPIPE is returned for non-zero offset. -EINVAL 66 + is returned for other operations, e.g. SEEK_CUR. This behavior 67 + and values are historical and could not be modified without the 68 + risk of breaking userspace. 69 + 59 70 The output format consists of a prefix carrying the syslog 60 71 prefix including priority and facility, the 64 bit message 61 72 sequence number and the monotonic timestamp in microseconds,
+2 -2
Documentation/core-api/printk-formats.rst
··· 317 317 318 318 The additional ``c`` specifier can be used with the ``I`` specifier to 319 319 print a compressed IPv6 address as described by 320 - http://tools.ietf.org/html/rfc5952 320 + https://tools.ietf.org/html/rfc5952 321 321 322 322 Passed by reference. 323 323 ··· 341 341 flowinfo a ``/`` and scope a ``%``, each followed by the actual value. 342 342 343 343 In case of an IPv6 address the compressed IPv6 address as described by 344 - http://tools.ietf.org/html/rfc5952 is being used if the additional 344 + https://tools.ietf.org/html/rfc5952 is being used if the additional 345 345 specifier ``c`` is given. The IPv6 address is surrounded by ``[``, ``]`` in 346 346 case of additional specifiers ``p``, ``f`` or ``s`` as suggested by 347 347 https://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-07
+3 -1
arch/mips/fw/arc/arc_con.c
··· 28 28 29 29 static int prom_console_setup(struct console *co, char *options) 30 30 { 31 - return !(prom_flags & PROM_FLAG_USE_AS_CONSOLE); 31 + if (prom_flags & PROM_FLAG_USE_AS_CONSOLE) 32 + return 0; 33 + return -ENODEV; 32 34 } 33 35 34 36 static struct console arc_cons = {
+1 -1
arch/s390/include/asm/bug.h
··· 2 2 #ifndef _ASM_S390_BUG_H 3 3 #define _ASM_S390_BUG_H 4 4 5 - #include <linux/kernel.h> 5 + #include <linux/compiler.h> 6 6 7 7 #ifdef CONFIG_BUG 8 8
+2 -2
drivers/tty/hvc/hvc_xen.c
··· 603 603 #endif 604 604 605 605 #ifdef CONFIG_EARLY_PRINTK 606 - static int __init xenboot_setup_console(struct console *console, char *string) 606 + static int __init xenboot_console_setup(struct console *console, char *string) 607 607 { 608 608 static struct xencons_info xenboot; 609 609 ··· 647 647 struct console xenboot_console = { 648 648 .name = "xenboot", 649 649 .write = xenboot_write_console, 650 - .setup = xenboot_setup_console, 650 + .setup = xenboot_console_setup, 651 651 .flags = CON_PRINTBUFFER | CON_BOOT | CON_ANYTIME, 652 652 .index = -1, 653 653 };
+1 -1
drivers/tty/hvc/hvsi.c
··· 1128 1128 int ret; 1129 1129 1130 1130 if (console->index < 0 || console->index >= hvsi_count) 1131 - return -1; 1131 + return -EINVAL; 1132 1132 hp = &hvsi_ports[console->index]; 1133 1133 1134 1134 /* give the FSP a chance to change the baud rate when we re-open */
+1 -1
drivers/tty/serial/sunsab.c
··· 886 886 * though... 887 887 */ 888 888 if (up->port.type != PORT_SUNSAB) 889 - return -1; 889 + return -EINVAL; 890 890 891 891 printk("Console: ttyS%d (SAB82532)\n", 892 892 (sunsab_reg.minor - 64) + con->index);
+1 -1
drivers/tty/serial/sunzilog.c
··· 1221 1221 int baud, brg; 1222 1222 1223 1223 if (up->port.type != PORT_SUNZILOG) 1224 - return -1; 1224 + return -EINVAL; 1225 1225 1226 1226 printk(KERN_INFO "Console: ttyS%d (SunZilog zs%d)\n", 1227 1227 (sunzilog_reg.minor - 64) + con->index, con->index);
+1
include/linux/printk.h
··· 7 7 #include <linux/kern_levels.h> 8 8 #include <linux/linkage.h> 9 9 #include <linux/cache.h> 10 + #include <linux/ratelimit_types.h> 10 11 11 12 extern const char linux_banner[]; 12 13 extern const char linux_proc_banner[];
+1 -35
include/linux/ratelimit.h
··· 2 2 #ifndef _LINUX_RATELIMIT_H 3 3 #define _LINUX_RATELIMIT_H 4 4 5 - #include <linux/param.h> 5 + #include <linux/ratelimit_types.h> 6 6 #include <linux/sched.h> 7 7 #include <linux/spinlock.h> 8 - 9 - #define DEFAULT_RATELIMIT_INTERVAL (5 * HZ) 10 - #define DEFAULT_RATELIMIT_BURST 10 11 - 12 - /* issue num suppressed message on exit */ 13 - #define RATELIMIT_MSG_ON_RELEASE BIT(0) 14 - 15 - struct ratelimit_state { 16 - raw_spinlock_t lock; /* protect the state */ 17 - 18 - int interval; 19 - int burst; 20 - int printed; 21 - int missed; 22 - unsigned long begin; 23 - unsigned long flags; 24 - }; 25 - 26 - #define RATELIMIT_STATE_INIT(name, interval_init, burst_init) { \ 27 - .lock = __RAW_SPIN_LOCK_UNLOCKED(name.lock), \ 28 - .interval = interval_init, \ 29 - .burst = burst_init, \ 30 - } 31 - 32 - #define RATELIMIT_STATE_INIT_DISABLED \ 33 - RATELIMIT_STATE_INIT(ratelimit_state, 0, DEFAULT_RATELIMIT_BURST) 34 - 35 - #define DEFINE_RATELIMIT_STATE(name, interval_init, burst_init) \ 36 - \ 37 - struct ratelimit_state name = \ 38 - RATELIMIT_STATE_INIT(name, interval_init, burst_init) \ 39 8 40 9 static inline void ratelimit_state_init(struct ratelimit_state *rs, 41 10 int interval, int burst) ··· 41 72 } 42 73 43 74 extern struct ratelimit_state printk_ratelimit_state; 44 - 45 - extern int ___ratelimit(struct ratelimit_state *rs, const char *func); 46 - #define __ratelimit(state) ___ratelimit(state, __func__) 47 75 48 76 #ifdef CONFIG_PRINTK 49 77
+43
include/linux/ratelimit_types.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_RATELIMIT_TYPES_H 3 + #define _LINUX_RATELIMIT_TYPES_H 4 + 5 + #include <linux/bits.h> 6 + #include <linux/param.h> 7 + #include <linux/spinlock_types.h> 8 + 9 + #define DEFAULT_RATELIMIT_INTERVAL (5 * HZ) 10 + #define DEFAULT_RATELIMIT_BURST 10 11 + 12 + /* issue num suppressed message on exit */ 13 + #define RATELIMIT_MSG_ON_RELEASE BIT(0) 14 + 15 + struct ratelimit_state { 16 + raw_spinlock_t lock; /* protect the state */ 17 + 18 + int interval; 19 + int burst; 20 + int printed; 21 + int missed; 22 + unsigned long begin; 23 + unsigned long flags; 24 + }; 25 + 26 + #define RATELIMIT_STATE_INIT(name, interval_init, burst_init) { \ 27 + .lock = __RAW_SPIN_LOCK_UNLOCKED(name.lock), \ 28 + .interval = interval_init, \ 29 + .burst = burst_init, \ 30 + } 31 + 32 + #define RATELIMIT_STATE_INIT_DISABLED \ 33 + RATELIMIT_STATE_INIT(ratelimit_state, 0, DEFAULT_RATELIMIT_BURST) 34 + 35 + #define DEFINE_RATELIMIT_STATE(name, interval_init, burst_init) \ 36 + \ 37 + struct ratelimit_state name = \ 38 + RATELIMIT_STATE_INIT(name, interval_init, burst_init) \ 39 + 40 + extern int ___ratelimit(struct ratelimit_state *rs, const char *func); 41 + #define __ratelimit(state) ___ratelimit(state, __func__) 42 + 43 + #endif /* _LINUX_RATELIMIT_TYPES_H */
+12 -4
kernel/printk/printk.c
··· 943 943 return ret; 944 944 } 945 945 946 + /* 947 + * Be careful when modifying this function!!! 948 + * 949 + * Only few operations are supported because the device works only with the 950 + * entire variable length messages (records). Non-standard values are 951 + * returned in the other cases and has been this way for quite some time. 952 + * User space applications might depend on this behavior. 953 + */ 946 954 static loff_t devkmsg_llseek(struct file *file, loff_t offset, int whence) 947 955 { 948 956 struct devkmsg_user *user = file->private_data; ··· 2666 2658 static int try_enable_new_console(struct console *newcon, bool user_specified) 2667 2659 { 2668 2660 struct console_cmdline *c; 2669 - int i; 2661 + int i, err; 2670 2662 2671 2663 for (i = 0, c = console_cmdline; 2672 2664 i < MAX_CMDLINECONSOLES && c->name[0]; ··· 2689 2681 return 0; 2690 2682 2691 2683 if (newcon->setup && 2692 - newcon->setup(newcon, c->options) != 0) 2693 - return -EIO; 2684 + (err = newcon->setup(newcon, c->options)) != 0) 2685 + return err; 2694 2686 } 2695 2687 newcon->flags |= CON_ENABLED; 2696 2688 if (i == preferred_console) { ··· 2703 2695 /* 2704 2696 * Some consoles, such as pstore and netconsole, can be enabled even 2705 2697 * without matching. Accept the pre-enabled consoles only when match() 2706 - * and setup() had a change to be called. 2698 + * and setup() had a chance to be called. 2707 2699 */ 2708 2700 if (newcon->flags & CON_ENABLED && c->user_specified == user_specified) 2709 2701 return 0;
+7 -10
lib/vsprintf.c
··· 381 381 #define SMALL 32 /* use lowercase in hex (must be 32 == 0x20) */ 382 382 #define SPECIAL 64 /* prefix hex with "0x", octal with "0" */ 383 383 384 + static_assert(ZEROPAD == ('0' - ' ')); 385 + static_assert(SMALL == ' '); 386 + 384 387 enum format_type { 385 388 FORMAT_TYPE_NONE, /* Just a string part */ 386 389 FORMAT_TYPE_WIDTH, ··· 510 507 /* zero or space padding */ 511 508 if (!(spec.flags & LEFT)) { 512 509 char c = ' ' + (spec.flags & ZEROPAD); 513 - BUILD_BUG_ON(' ' + ZEROPAD != '0'); 510 + 514 511 while (--field_width >= 0) { 515 512 if (buf < end) 516 513 *buf = c; ··· 1937 1934 names = vmaflag_names; 1938 1935 break; 1939 1936 case 'g': 1940 - flags = *(gfp_t *)flags_ptr; 1937 + flags = (__force unsigned long)(*(gfp_t *)flags_ptr); 1941 1938 names = gfpflag_names; 1942 1939 break; 1943 1940 default: ··· 1979 1976 char *buf_start = buf; 1980 1977 struct property *prop; 1981 1978 bool has_mult, pass; 1982 - static const struct printf_spec num_spec = { 1983 - .flags = SMALL, 1984 - .field_width = -1, 1985 - .precision = -1, 1986 - .base = 10, 1987 - }; 1988 1979 1989 1980 struct printf_spec str_spec = spec; 1990 1981 str_spec.field_width = -1; ··· 2018 2021 str_spec.precision = precision; 2019 2022 break; 2020 2023 case 'p': /* phandle */ 2021 - buf = number(buf, end, (unsigned int)dn->phandle, num_spec); 2024 + buf = number(buf, end, (unsigned int)dn->phandle, default_dec_spec); 2022 2025 break; 2023 2026 case 'P': /* path-spec */ 2024 2027 p = fwnode_get_name(of_fwnode_handle(dn)); ··· 2131 2134 * [4] or [6] and is able to print port [p], flowinfo [f], scope [s] 2132 2135 * - '[Ii][4S][hnbl]' IPv4 addresses in host, network, big or little endian order 2133 2136 * - 'I[6S]c' for IPv6 addresses printed as specified by 2134 - * http://tools.ietf.org/html/rfc5952 2137 + * https://tools.ietf.org/html/rfc5952 2135 2138 * - 'E[achnops]' For an escaped buffer, where rules are defined by combination 2136 2139 * of the following flags (see string_escape_mem() for the 2137 2140 * details):