printk: Rework parse_prefix into printk_parse_prefix
authorChris Down <chris@chrisdown.name>
Tue, 15 Jun 2021 16:52:51 +0000 (17:52 +0100)
committerPetr Mladek <pmladek@suse.com>
Mon, 19 Jul 2021 09:57:18 +0000 (11:57 +0200)
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: Chris Down <chris@chrisdown.name>
Cc: Petr Mladek <pmladek@suse.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/b22ba314a860e5c7f887958f1eab2649f9bd1d06.1623775748.git.chris@chrisdown.name
kernel/printk/internal.h
kernel/printk/printk.c

index 1075e60..1596e28 100644 (file)
@@ -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
 
 /*
index 39f1ec2..03956c3 100644 (file)
@@ -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;