Skip to contentSkip to conversation

um: Don't use console_drivers directly

PATCH In review Andy Shevchenko 2 participants 3 messages Feb 12, 2020 – Mar 29, 2020 User-mode Linux (UML)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 um: Don't use console_drivers directly

console_drivers is kind of (semi-)private variable to the console code. Direct use of it make us stuck with it being exported here and there. Reduce use of console_drivers by replacing it with for_each_console().

---
v2: fix condition (we do NOT want to have a console), remove confusing comment

 arch/um/kernel/kmsg_dump.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
arch/um/kernel/kmsg_dump.c +4 -5
index 98bdf69e4c2e..e4abac6c9727 100644
@@ -9,20 +9,19 @@ static void kmsg_dumper_stdout(struct kmsg_dumper *dumper,
 				enum kmsg_dump_reason reason)
 {
 	static char line[1024];
-
+	struct console *con;
 	size_t len = 0;
-	bool con_available = false;
 
 	/* only dump kmsg when no console is available */
 	if (!console_trylock())
 		return;
 
-	if (console_drivers != NULL)
-		con_available = true;
+	for_each_console(con)
+		break;
 
 	console_unlock();
 
-	if (con_available == true)
+	if (con)
 		return;
 
 	printf("kmsg_dump:\n");
Signature · 7 lines
2.25.0


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
#1 lore raw
Quoted 3 lines · Andy Shevchenko

console_drivers is kind of (semi-)private variable to the console code. Direct use of it make us stuck with it being exported here and there. Reduce use of console_drivers by replacing it with for_each_console().

Any comments?

Quoted 39 lines

---
v2: fix condition (we do NOT want to have a console), remove confusing comment

 arch/um/kernel/kmsg_dump.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
arch/um/kernel/kmsg_dump.c +4 -5
index 98bdf69e4c2e..e4abac6c9727 100644
@@ -9,20 +9,19 @@ static void kmsg_dumper_stdout(struct kmsg_dumper *dumper,
 				enum kmsg_dump_reason reason)
 {
 	static char line[1024];
-
+	struct console *con;
 	size_t len = 0;
-	bool con_available = false;
 
 	/* only dump kmsg when no console is available */
 	if (!console_trylock())
 		return;
 
-	if (console_drivers != NULL)
-		con_available = true;
+	for_each_console(con)
+		break;
 
 	console_unlock();
 
-	if (con_available == true)
+	if (con)
 		return;
 
 	printf("kmsg_dump:\n");
Signature · 1 line
2.25.0
Signature · 9 lines
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
#2 lore raw
Quoted 37 lines · Andy Shevchenko
Quoted 3 lines · Andy Shevchenko

console_drivers is kind of (semi-)private variable to the console code. Direct use of it make us stuck with it being exported here and there. Reduce use of console_drivers by replacing it with for_each_console().

Any comments?

Quoted 29 lines

---
v2: fix condition (we do NOT want to have a console), remove confusing comment

 arch/um/kernel/kmsg_dump.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
arch/um/kernel/kmsg_dump.c +3 -4
index 98bdf69e4c2e..e4abac6c9727 100644
@@ -9,20 +9,19 @@ static void kmsg_dumper_stdout(struct kmsg_dumper *dumper,
                              enum kmsg_dump_reason reason)
 {
      static char line[1024];
-
+     struct console *con;
      size_t len = 0;
-     bool con_available = false;
 
      /* only dump kmsg when no console is available */
      if (!console_trylock())
              return;
 
-     if (console_drivers != NULL)
-             con_available = true;
+     for_each_console(con)
+             break;
 
Quoted 8 lines

arch/um/kernel/kmsg_dump.c static void kmsg_dumper_stdout(struct kmsg_dumper *dumper,

Quoted 8 lines
arch/um/kernel/kmsg_dump.c +1 -2
      console_unlock();
 
-     if (con_available == true)
+     if (con)
              return;
 
      printf("kmsg_dump:\n");
--

Thanks for cleaning this up, applied.

Signature · 7 lines
Thanks,
//richard

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um