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