diff options
| author | Seiji Aguchi <seiji.aguchi@hds.com> | 2012-03-16 18:36:59 -0400 |
|---|---|---|
| committer | Tony Luck <tony.luck@intel.com> | 2012-03-16 18:36:59 -0400 |
| commit | 381b872cf7942ab8c95de156ce403bd906f3915d (patch) | |
| tree | 0dcd83a7c76ed3a6324bef178e02a4ee3ea815bd /fs/pstore | |
| parent | fde7d9049e55ab85a390be7f415d74c9f62dd0f9 (diff) | |
pstore: Introduce get_reason_str() to pstore
Recently, there has been some changes in kmsg_dump() below and they have been applied to linus-tree.
(1) kmsg_dump(KMSG_DUMP_KEXEC) was removed.
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=a3dd3323058d281abd584b15ad4c5b65064d7a61
(2) The order of "enum kmsg_dump_reason" was modified.
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=c22ab332902333f83766017478c1ef6607ace681
Replace the fragile reason_str array with a more robust solution that
will not be broken by future re-arrangements of the enum values.
Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Don Zickus <dzickus@redhat.com>
Link: https://lkml.org/lkml/2012/3/16/417
Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'fs/pstore')
| -rw-r--r-- | fs/pstore/platform.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 9ec22d3b4293..82c585f715e3 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c | |||
| @@ -68,9 +68,25 @@ void pstore_set_kmsg_bytes(int bytes) | |||
| 68 | /* Tag each group of saved records with a sequence number */ | 68 | /* Tag each group of saved records with a sequence number */ |
| 69 | static int oopscount; | 69 | static int oopscount; |
| 70 | 70 | ||
| 71 | static char *reason_str[] = { | 71 | static const char *get_reason_str(enum kmsg_dump_reason reason) |
| 72 | "Oops", "Panic", "Kexec", "Restart", "Halt", "Poweroff", "Emergency" | 72 | { |
| 73 | }; | 73 | switch (reason) { |
| 74 | case KMSG_DUMP_PANIC: | ||
| 75 | return "Panic"; | ||
| 76 | case KMSG_DUMP_OOPS: | ||
| 77 | return "Oops"; | ||
| 78 | case KMSG_DUMP_EMERG: | ||
| 79 | return "Emergency"; | ||
| 80 | case KMSG_DUMP_RESTART: | ||
| 81 | return "Restart"; | ||
| 82 | case KMSG_DUMP_HALT: | ||
| 83 | return "Halt"; | ||
| 84 | case KMSG_DUMP_POWEROFF: | ||
| 85 | return "Poweroff"; | ||
| 86 | default: | ||
| 87 | return "Unknown"; | ||
| 88 | } | ||
| 89 | } | ||
| 74 | 90 | ||
| 75 | /* | 91 | /* |
| 76 | * callback from kmsg_dump. (s2,l2) has the most recently | 92 | * callback from kmsg_dump. (s2,l2) has the most recently |
| @@ -85,17 +101,15 @@ static void pstore_dump(struct kmsg_dumper *dumper, | |||
| 85 | unsigned long s1_start, s2_start; | 101 | unsigned long s1_start, s2_start; |
| 86 | unsigned long l1_cpy, l2_cpy; | 102 | unsigned long l1_cpy, l2_cpy; |
| 87 | unsigned long size, total = 0; | 103 | unsigned long size, total = 0; |
| 88 | char *dst, *why; | 104 | char *dst; |
| 105 | const char *why; | ||
| 89 | u64 id; | 106 | u64 id; |
| 90 | int hsize, ret; | 107 | int hsize, ret; |
| 91 | unsigned int part = 1; | 108 | unsigned int part = 1; |
| 92 | unsigned long flags = 0; | 109 | unsigned long flags = 0; |
| 93 | int is_locked = 0; | 110 | int is_locked = 0; |
| 94 | 111 | ||
| 95 | if (reason < ARRAY_SIZE(reason_str)) | 112 | why = get_reason_str(reason); |
| 96 | why = reason_str[reason]; | ||
| 97 | else | ||
| 98 | why = "Unknown"; | ||
| 99 | 113 | ||
| 100 | if (in_nmi()) { | 114 | if (in_nmi()) { |
| 101 | is_locked = spin_trylock(&psinfo->buf_lock); | 115 | is_locked = spin_trylock(&psinfo->buf_lock); |
