Commit f3d75cf5 authored by Chris Down's avatar Chris Down Committed by Petr Mladek
Browse files

printk: Rework parse_prefix into printk_parse_prefix



parse_prefix is needed externally by later patches, so move it into a
context where it can be used as such. Also give it the printk_ prefix to
reduce the chance of collisions.

Signed-off-by: default avatarChris Down <chris@chrisdown.name>
Cc: Petr Mladek <pmladek@suse.com>
Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
Acked-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/b22ba314a860e5c7f887958f1eab2649f9bd1d06.1623775748.git.chris@chrisdown.name
parent a1ad4b8a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -57,6 +57,8 @@ bool printk_percpu_data_ready(void);

void defer_console_output(void);

u16 printk_parse_prefix(const char *text, int *level,
			enum printk_info_flags *flags);
#else

/*
+4 −4
Original line number Diff line number Diff line
@@ -1956,7 +1956,7 @@ static inline u32 printk_caller_id(void)
}

/**
 * parse_prefix - Parse level and control flags.
 * printk_parse_prefix - Parse level and control flags.
 *
 * @text:     The terminated text message.
 * @level:    A pointer to the current level value, will be updated.
@@ -1972,7 +1972,7 @@ static inline u32 printk_caller_id(void)
 *
 * Return: The length of the parsed level and control flags.
 */
static u16 parse_prefix(char *text, int *level,
u16 printk_parse_prefix(const char *text, int *level,
			enum printk_info_flags *flags)
{
	u16 prefix_len = 0;
@@ -2018,7 +2018,7 @@ static u16 printk_sprint(char *text, u16 size, int facility,
	if (facility == 0) {
		u16 prefix_len;

		prefix_len = parse_prefix(text, NULL, NULL);
		prefix_len = printk_parse_prefix(text, NULL, NULL);
		if (prefix_len) {
			text_len -= prefix_len;
			memmove(text, text + prefix_len, text_len);
@@ -2067,7 +2067,7 @@ int vprintk_store(int facility, int level,

	/* Extract log level or control flags. */
	if (facility == 0)
		parse_prefix(&prefix_buf[0], &level, &flags);
		printk_parse_prefix(&prefix_buf[0], &level, &flags);

	if (level == LOGLEVEL_DEFAULT)
		level = default_message_loglevel;