hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/arch/um/kernel/kmsg_dump.c
....@@ -1,35 +1,43 @@
11 // SPDX-License-Identifier: GPL-2.0
22 #include <linux/kmsg_dump.h>
3
+#include <linux/spinlock.h>
34 #include <linux/console.h>
45 #include <shared/init.h>
56 #include <shared/kern.h>
67 #include <os.h>
78
89 static void kmsg_dumper_stdout(struct kmsg_dumper *dumper,
9
- enum kmsg_dump_reason reason)
10
+ enum kmsg_dump_reason reason,
11
+ struct kmsg_dumper_iter *iter)
1012 {
13
+ static DEFINE_SPINLOCK(lock);
1114 static char line[1024];
12
-
15
+ struct console *con;
16
+ unsigned long flags;
1317 size_t len = 0;
14
- bool con_available = false;
1518
1619 /* only dump kmsg when no console is available */
1720 if (!console_trylock())
1821 return;
1922
20
- if (console_drivers != NULL)
21
- con_available = true;
23
+ for_each_console(con)
24
+ break;
2225
2326 console_unlock();
2427
25
- if (con_available == true)
28
+ if (con)
29
+ return;
30
+
31
+ if (!spin_trylock_irqsave(&lock, flags))
2632 return;
2733
2834 printf("kmsg_dump:\n");
29
- while (kmsg_dump_get_line(dumper, true, line, sizeof(line), &len)) {
35
+ while (kmsg_dump_get_line(iter, true, line, sizeof(line), &len)) {
3036 line[len] = '\0';
3137 printf("%s", line);
3238 }
39
+
40
+ spin_unlock_irqrestore(&lock, flags);
3341 }
3442
3543 static struct kmsg_dumper kmsg_dumper = {