public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [Patch]Introduce get_reason_str() to pstore
@ 2012-03-16 17:01 Seiji Aguchi
  2012-03-16 17:51 ` Don Zickus
  2012-03-24  7:10 ` Andrew Morton
  0 siblings, 2 replies; 5+ messages in thread
From: Seiji Aguchi @ 2012-03-16 17:01 UTC (permalink / raw)
  To: Adrian Hunter, linux-kernel@vger.kernel.org,
	Luck, Tony (tony.luck@intel.com),
	Chen Gong (gong.chen@linux.intel.com),
	Matthew Garrett (mjg@redhat.com), dzickus@redhat.com
  Cc: dle-develop@lists.sourceforge.net, Satoru Moriya

Hi,

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) A order of "enum kmsg_dump_reason" was modified.
     http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=c22ab332902333f83766017478c1ef6607ace681

 This patch removes reason_str array and add get_reason_str() in accordance with Adrian's comment below.
 https://lkml.org/lkml/2012/3/16/63

 Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
 Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

---
 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 9ec22d3..82c585f 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -68,9 +68,25 @@ void pstore_set_kmsg_bytes(int bytes)
 /* Tag each group of saved records with a sequence number */
 static int	oopscount;
 
-static char *reason_str[] = {
-	"Oops", "Panic", "Kexec", "Restart", "Halt", "Poweroff", "Emergency"
-};
+static const char *get_reason_str(enum kmsg_dump_reason reason) {
+	switch (reason) {
+	case KMSG_DUMP_PANIC:
+		return "Panic";
+	case KMSG_DUMP_OOPS:
+		return "Oops";
+	case KMSG_DUMP_EMERG:
+		return "Emergency";
+	case KMSG_DUMP_RESTART:
+		return "Restart";
+	case KMSG_DUMP_HALT:
+		return "Halt";
+	case KMSG_DUMP_POWEROFF:
+		return "Poweroff";
+	default:
+		return "Unknown";
+	}
+}
 
 /*
  * callback from kmsg_dump. (s2,l2) has the most recently @@ -85,17 +101,15 @@ static void pstore_dump(struct kmsg_dumper *dumper,
 	unsigned long	s1_start, s2_start;
 	unsigned long	l1_cpy, l2_cpy;
 	unsigned long	size, total = 0;
-	char		*dst, *why;
+	char		*dst;
+	const char	*why;
 	u64		id;
 	int		hsize, ret;
 	unsigned int	part = 1;
 	unsigned long	flags = 0;
 	int		is_locked = 0;
 
-	if (reason < ARRAY_SIZE(reason_str))
-		why = reason_str[reason];
-	else
-		why = "Unknown";
+	why = get_reason_str(reason);
 
 	if (in_nmi()) {
 		is_locked = spin_trylock(&psinfo->buf_lock);
--
1.7.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Patch]Introduce get_reason_str() to pstore
  2012-03-16 17:01 [Patch]Introduce get_reason_str() to pstore Seiji Aguchi
@ 2012-03-16 17:51 ` Don Zickus
  2012-03-16 22:47   ` Tony Luck
  2012-03-24  7:10 ` Andrew Morton
  1 sibling, 1 reply; 5+ messages in thread
From: Don Zickus @ 2012-03-16 17:51 UTC (permalink / raw)
  To: Seiji Aguchi
  Cc: Adrian Hunter, linux-kernel@vger.kernel.org,
	Luck, Tony (tony.luck@intel.com),
	Chen Gong (gong.chen@linux.intel.com),
	Matthew Garrett (mjg@redhat.com),
	dle-develop@lists.sourceforge.net, Satoru Moriya

On Fri, Mar 16, 2012 at 01:01:49PM -0400, Seiji Aguchi wrote:
> Hi,
> 
> 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) A order of "enum kmsg_dump_reason" was modified.
>      http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=c22ab332902333f83766017478c1ef6607ace681
> 
>  This patch removes reason_str array and add get_reason_str() in accordance with Adrian's comment below.
>  https://lkml.org/lkml/2012/3/16/63

Future proofs things a little bit.  Looks good to me.

Acked-by: Don Zickus <dzickus@redhat.com>

> 
>  Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
>  Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> 
> ---
>  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 9ec22d3..82c585f 100644
> --- a/fs/pstore/platform.c
> +++ b/fs/pstore/platform.c
> @@ -68,9 +68,25 @@ void pstore_set_kmsg_bytes(int bytes)
>  /* Tag each group of saved records with a sequence number */
>  static int	oopscount;
>  
> -static char *reason_str[] = {
> -	"Oops", "Panic", "Kexec", "Restart", "Halt", "Poweroff", "Emergency"
> -};
> +static const char *get_reason_str(enum kmsg_dump_reason reason) {
> +	switch (reason) {
> +	case KMSG_DUMP_PANIC:
> +		return "Panic";
> +	case KMSG_DUMP_OOPS:
> +		return "Oops";
> +	case KMSG_DUMP_EMERG:
> +		return "Emergency";
> +	case KMSG_DUMP_RESTART:
> +		return "Restart";
> +	case KMSG_DUMP_HALT:
> +		return "Halt";
> +	case KMSG_DUMP_POWEROFF:
> +		return "Poweroff";
> +	default:
> +		return "Unknown";
> +	}
> +}
>  
>  /*
>   * callback from kmsg_dump. (s2,l2) has the most recently @@ -85,17 +101,15 @@ static void pstore_dump(struct kmsg_dumper *dumper,
>  	unsigned long	s1_start, s2_start;
>  	unsigned long	l1_cpy, l2_cpy;
>  	unsigned long	size, total = 0;
> -	char		*dst, *why;
> +	char		*dst;
> +	const char	*why;
>  	u64		id;
>  	int		hsize, ret;
>  	unsigned int	part = 1;
>  	unsigned long	flags = 0;
>  	int		is_locked = 0;
>  
> -	if (reason < ARRAY_SIZE(reason_str))
> -		why = reason_str[reason];
> -	else
> -		why = "Unknown";
> +	why = get_reason_str(reason);
>  
>  	if (in_nmi()) {
>  		is_locked = spin_trylock(&psinfo->buf_lock);
> --
> 1.7.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Patch]Introduce get_reason_str() to pstore
  2012-03-16 17:51 ` Don Zickus
@ 2012-03-16 22:47   ` Tony Luck
  0 siblings, 0 replies; 5+ messages in thread
From: Tony Luck @ 2012-03-16 22:47 UTC (permalink / raw)
  To: Don Zickus
  Cc: Seiji Aguchi, Adrian Hunter, linux-kernel@vger.kernel.org,
	Chen Gong (gong.chen@linux.intel.com),
	Matthew Garrett (mjg@redhat.com),
	dle-develop@lists.sourceforge.net, Satoru Moriya

> Future proofs things a little bit.  Looks good to me.
>
> Acked-by: Don Zickus <dzickus@redhat.com>

Looks good to me too. Applied.

Should show up in the next linux-next tree. Will ask Linus to pull in
next merge window.

-Tony

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Patch]Introduce get_reason_str() to pstore
  2012-03-16 17:01 [Patch]Introduce get_reason_str() to pstore Seiji Aguchi
  2012-03-16 17:51 ` Don Zickus
@ 2012-03-24  7:10 ` Andrew Morton
  2012-03-24 16:03   ` Seiji Aguchi
  1 sibling, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2012-03-24  7:10 UTC (permalink / raw)
  To: Seiji Aguchi
  Cc: Adrian Hunter, linux-kernel@vger.kernel.org,
	Luck, Tony (tony.luck@intel.com),
	Chen Gong (gong.chen@linux.intel.com),
	Matthew Garrett (mjg@redhat.com), dzickus@redhat.com,
	dle-develop@lists.sourceforge.net, Satoru Moriya

On Fri, 16 Mar 2012 13:01:49 -0400 Seiji Aguchi <seiji.aguchi@hds.com> wrote:

> Hi,
> 
> 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) A order of "enum kmsg_dump_reason" was modified.
>      http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=c22ab332902333f83766017478c1ef6607ace681
> 
>  This patch removes reason_str array and add get_reason_str() in accordance with Adrian's comment below.
>  https://lkml.org/lkml/2012/3/16/63
> 
>  Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
>  Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> 
> ---
>  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 9ec22d3..82c585f 100644
> --- a/fs/pstore/platform.c
> +++ b/fs/pstore/platform.c
> @@ -68,9 +68,25 @@ void pstore_set_kmsg_bytes(int bytes)
>  /* Tag each group of saved records with a sequence number */
>  static int	oopscount;
>  
> -static char *reason_str[] = {
> -	"Oops", "Panic", "Kexec", "Restart", "Halt", "Poweroff", "Emergency"
> -};
> +static const char *get_reason_str(enum kmsg_dump_reason reason) {
> +	switch (reason) {
> +	case KMSG_DUMP_PANIC:
> +		return "Panic";
> +	case KMSG_DUMP_OOPS:
> +		return "Oops";
> +	case KMSG_DUMP_EMERG:
> +		return "Emergency";
> +	case KMSG_DUMP_RESTART:
> +		return "Restart";
> +	case KMSG_DUMP_HALT:
> +		return "Halt";
> +	case KMSG_DUMP_POWEROFF:
> +		return "Poweroff";
> +	default:
> +		return "Unknown";
> +	}
> +}

Better:

static char *reason_str[] = {
	[KMSG_DUMP_OOPS] = "Oops",
	[KMSG_DUMP_PANIC] = "Panic",
	...
	[KMSG_DUMP_POWEROFF] = "Poweroff",
};


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [Patch]Introduce get_reason_str() to pstore
  2012-03-24  7:10 ` Andrew Morton
@ 2012-03-24 16:03   ` Seiji Aguchi
  0 siblings, 0 replies; 5+ messages in thread
From: Seiji Aguchi @ 2012-03-24 16:03 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Adrian Hunter, linux-kernel@vger.kernel.org,
	Luck, Tony (tony.luck@intel.com),
	Chen Gong (gong.chen@linux.intel.com),
	Matthew Garrett (mjg@redhat.com), dzickus@redhat.com,
	dle-develop@lists.sourceforge.net, Satoru Moriya


> Better:
> 
> static char *reason_str[] = {
> 	[KMSG_DUMP_OOPS] = "Oops",
> 	[KMSG_DUMP_PANIC] = "Panic",
> 	...
> 	[KMSG_DUMP_POWEROFF] = "Poweroff",
> };

Thanks, Andrew.

I will update my patch.

Seiji

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-03-24 16:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-16 17:01 [Patch]Introduce get_reason_str() to pstore Seiji Aguchi
2012-03-16 17:51 ` Don Zickus
2012-03-16 22:47   ` Tony Luck
2012-03-24  7:10 ` Andrew Morton
2012-03-24 16:03   ` Seiji Aguchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox