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
135}135}
136EXPORT_SYMBOL_GPL(pstore_name_to_type);136EXPORT_SYMBOL_GPL(pstore_name_to_type);
137 137
138static 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
154static void pstore_timer_kick(void)138static void pstore_timer_kick(void)
155{139{
156 if (pstore_update_ms < 0)140 if (pstore_update_ms < 0)
@@ -403,7 +387,7 @@ static void pstore_dump(struct kmsg_dumper *dumper, · 246 unmodified lines
403 unsigned int part = 1;387 unsigned int part = 1;
404 int ret;388 int ret;
405 389
406 why = get_reason_str(reason);390 why = kmsg_dump_reason_str(reason);
407 391
408 if (down_trylock(&psinfo->buf_lock)) {392 if (down_trylock(&psinfo->buf_lock)) {
409 /* Failed to acquire lock: give up if we cannot wait. */393 /* 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
70int kmsg_dump_register(struct kmsg_dumper *dumper);70int kmsg_dump_register(struct kmsg_dumper *dumper);
71 71
72int kmsg_dump_unregister(struct kmsg_dumper *dumper);72int kmsg_dump_unregister(struct kmsg_dumper *dumper);
73
74const char *kmsg_dump_reason_str(enum kmsg_dump_reason reason);
73#else75#else
74static inline void kmsg_dump(enum kmsg_dump_reason reason)76static inline void kmsg_dump(enum kmsg_dump_reason reason)
75{77{
@@ -111,6 +113,11 @@ static inline int kmsg_dump_unregister(struct kmsg_dumper *dumper) · 35 unmodified lines
111{113{
112 return -EINVAL;114 return -EINVAL;
113}115}
116
117static inline const char *kmsg_dump_reason_str(enum kmsg_dump_reason reason)
118{
119 return "Disabled";
120}
114#endif121#endif
115 122
116#endif /* _LINUX_KMSG_DUMP_H */123#endif /* _LINUX_KMSG_DUMP_H */
kernel/printk/printk.c+17−0
@@ -3144,6 +3144,23 @@ EXPORT_SYMBOL_GPL(kmsg_dump_unregister); · 3143 unmodified lines
3144static bool always_kmsg_dump;3144static bool always_kmsg_dump;
3145module_param_named(always_kmsg_dump, always_kmsg_dump, bool, S_IRUGO | S_IWUSR);3145module_param_named(always_kmsg_dump, always_kmsg_dump, bool, S_IRUGO | S_IWUSR);
3146 3146
3147const 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}
3162EXPORT_SYMBOL_GPL(kmsg_dump_reason_str);
3163
3147/**3164/**
3148 * kmsg_dump - dump kernel log to kernel message dumpers.3165 * kmsg_dump - dump kernel log to kernel message dumpers.
3149 * @reason: the reason (oops, panic etc) for dumping3166 * @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