[printk,v2,4/7] printk: Add struct console_buffers

Message ID 20221123231400.614679-5-john.ogness@linutronix.de
State New
Headers
Series printk: cleanup buffer handling |

Commit Message

John Ogness Nov. 23, 2022, 11:13 p.m. UTC
  From: Thomas Gleixner <tglx@linutronix.de>

Create a data structure to replace the open coded separate buffers for
regular, extended, and dropped message formatting.

A separate @ext_text buffer is needed because info_print_ext_header()
and msg_print_ext_body() are not able to add the needed extra
information in-place.

@ext_text can be used for dropped text because they are never used at
the same time.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
 include/linux/console.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
  

Comments

Petr Mladek Nov. 24, 2022, 2:52 p.m. UTC | #1
On Thu 2022-11-24 00:19:57, John Ogness wrote:
> From: Thomas Gleixner <tglx@linutronix.de>
> 
> Create a data structure to replace the open coded separate buffers for
> regular, extended, and dropped message formatting.
> 
> A separate @ext_text buffer is needed because info_print_ext_header()
> and msg_print_ext_body() are not able to add the needed extra
> information in-place.
> 
> @ext_text can be used for dropped text because they are never used at
> the same time.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: John Ogness <john.ogness@linutronix.de>

If we agree to use the static buffers in struct console, feel free to use:

Reviewed-by: Petr Mladek <pmladek@suse.com>

Otherwise, it should get moved into some internal header.

Best Regards,
Petr
  
John Ogness Nov. 24, 2022, 8:22 p.m. UTC | #2
On 2022-11-24, Petr Mladek <pmladek@suse.com> wrote:
> If we agree to use the static buffers in struct console, feel free to use:
>
> Reviewed-by: Petr Mladek <pmladek@suse.com>

I will move the struct definition and size defines into printk.c for v3.

John
  

Patch

diff --git a/include/linux/console.h b/include/linux/console.h
index b2cf256c23b6..641c1ca7fb67 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -178,6 +178,16 @@  enum cons_flags {
 	CON_EXTENDED		= BIT(6),
 };
 
+/**
+ * struct console_buffers - console output text buffers
+ * @ext_text:		Buffer for extended log format or dropped text
+ * @text:		Buffer for ringbuffer text
+ */
+struct console_buffers {
+	char	ext_text[CONSOLE_EXT_LOG_MAX];
+	char	text[CONSOLE_LOG_MAX];
+};
+
 /**
  * struct console - The console descriptor structure
  * @name:		The name of the console driver