History

printk: Introduce kmsg_dump_reason_str()

The pstore subsystem already had a private version of this function. With the coming addition of the pstore/zone driver, this needs to be shared. As it really should live with printk, move it there instead.

Kees Cook committed 6 years ago

Commit fb13cb81 parent b1f6f163 files · +25 −17Browse files

Unified · Split

3 files
  1. fs/pstore/platform.c +1 −17
  2. include/linux/kmsg_dump.h +7 −0
  3. kernel/printk/printk.c +17 −0
fs/pstore/platform.c+1−17
@@ -135,22 +135,6 @@ enum pstore_type_id pstore_name_to_type(const char *name) · 134 unmodified lines
135135 }
136136 EXPORT_SYMBOL_GPL(pstore_name_to_type);
137137
138−static const char *get_reason_str(enum kmsg_dump_reason reason)
139−{
140− switch (reason) {
141− case KMSG_DUMP_PANIC:
142− return "Panic";
143− case KMSG_DUMP_OOPS:
144− return "Oops";
145− case KMSG_DUMP_EMERG:
146− return "Emergency";
147− case KMSG_DUMP_SHUTDOWN:
148− return "Shutdown";
149− default:
150− return "Unknown";
151− }
152−}
153−
154138 static void pstore_timer_kick(void)
155139 {
156140 if (pstore_update_ms < 0)
@@ -403,7 +387,7 @@ static void pstore_dump(struct kmsg_dumper *dumper, · 246 unmodified lines
403387 unsigned int part = 1;
404388 int ret;
405389
406− why = get_reason_str(reason);
390+ why = kmsg_dump_reason_str(reason);
407391
408392 if (down_trylock(&psinfo->buf_lock)) {
409393 /* Failed to acquire lock: give up if we cannot wait. */
include/linux/kmsg_dump.h+7−0
@@ -70,6 +70,8 @@ void kmsg_dump_rewind(struct kmsg_dumper *dumper); · 69 unmodified lines
7070 int kmsg_dump_register(struct kmsg_dumper *dumper);
7171
7272 int kmsg_dump_unregister(struct kmsg_dumper *dumper);
73+
74+const char *kmsg_dump_reason_str(enum kmsg_dump_reason reason);
7375 #else
7476 static inline void kmsg_dump(enum kmsg_dump_reason reason)
7577 {
@@ -111,6 +113,11 @@ static inline int kmsg_dump_unregister(struct kmsg_dumper *dumper) · 35 unmodified lines
111113 {
112114 return -EINVAL;
113115 }
116+
117+static inline const char *kmsg_dump_reason_str(enum kmsg_dump_reason reason)
118+{
119+ return "Disabled";
120+}
114121 #endif
115122
116123 #endif /* _LINUX_KMSG_DUMP_H */
kernel/printk/printk.c+17−0
@@ -3144,6 +3144,23 @@ EXPORT_SYMBOL_GPL(kmsg_dump_unregister); · 3143 unmodified lines
31443144 static bool always_kmsg_dump;
31453145 module_param_named(always_kmsg_dump, always_kmsg_dump, bool, S_IRUGO | S_IWUSR);
31463146
3147+const char *kmsg_dump_reason_str(enum kmsg_dump_reason reason)
3148+{
3149+ switch (reason) {
3150+ case KMSG_DUMP_PANIC:
3151+ return "Panic";
3152+ case KMSG_DUMP_OOPS:
3153+ return "Oops";
3154+ case KMSG_DUMP_EMERG:
3155+ return "Emergency";
3156+ case KMSG_DUMP_SHUTDOWN:
3157+ return "Shutdown";
3158+ default:
3159+ return "Unknown";
3160+ }
3161+}
3162+EXPORT_SYMBOL_GPL(kmsg_dump_reason_str);
3163+
31473164 /**
31483165 * kmsg_dump - dump kernel log to kernel message dumpers.
31493166 * @reason: the reason (oops, panic etc) for dumping

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t