linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Gavin Shan <gwshan@linux.vnet.ibm.com>
To: linuxppc-dev@ozlabs.org
Cc: mpe@ellerman.id.au, Gavin Shan <gwshan@linux.vnet.ibm.com>
Subject: [PATCH v2 5/8] powerpc/pseries: Cleanup on pseries_eeh_get_state()
Date: Thu,  8 Oct 2015 14:58:56 +1100	[thread overview]
Message-ID: <1444276739-20372-6-git-send-email-gwshan@linux.vnet.ibm.com> (raw)
In-Reply-To: <1444276739-20372-1-git-send-email-gwshan@linux.vnet.ibm.com>

This cleans up pseries_eeh_get_state(), no functional changes:

   * Return EEH_STATE_NOT_SUPPORT early when the 2nd RTAS output
     argument is zero to avoid nested if statements.
   * Skip clearing bits in the PE state represented by variable
     "result" to simplify the code.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/pseries/eeh_pseries.c | 60 ++++++++++++----------------
 1 file changed, 26 insertions(+), 34 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/eeh_pseries.c b/arch/powerpc/platforms/pseries/eeh_pseries.c
index 1ba55d0..ac3ffd9 100644
--- a/arch/powerpc/platforms/pseries/eeh_pseries.c
+++ b/arch/powerpc/platforms/pseries/eeh_pseries.c
@@ -433,42 +433,34 @@ static int pseries_eeh_get_state(struct eeh_pe *pe, int *state)
 		return ret;
 
 	/* Parse the result out */
-	result = 0;
-	if (rets[1]) {
-		switch(rets[0]) {
-		case 0:
-			result &= ~EEH_STATE_RESET_ACTIVE;
-			result |= EEH_STATE_MMIO_ACTIVE;
-			result |= EEH_STATE_DMA_ACTIVE;
-			break;
-		case 1:
-			result |= EEH_STATE_RESET_ACTIVE;
-			result |= EEH_STATE_MMIO_ACTIVE;
-			result |= EEH_STATE_DMA_ACTIVE;
-			break;
-		case 2:
-			result &= ~EEH_STATE_RESET_ACTIVE;
-			result &= ~EEH_STATE_MMIO_ACTIVE;
-			result &= ~EEH_STATE_DMA_ACTIVE;
-			break;
-		case 4:
-			result &= ~EEH_STATE_RESET_ACTIVE;
-			result &= ~EEH_STATE_MMIO_ACTIVE;
-			result &= ~EEH_STATE_DMA_ACTIVE;
-			result |= EEH_STATE_MMIO_ENABLED;
-			break;
-		case 5:
-			if (rets[2]) {
-				if (state) *state = rets[2];
-				result = EEH_STATE_UNAVAILABLE;
-			} else {
-				result = EEH_STATE_NOT_SUPPORT;
-			}
-			break;
-		default:
+	if (!rets[1])
+		return EEH_STATE_NOT_SUPPORT;
+
+	switch(rets[0]) {
+	case 0:
+		result = EEH_STATE_MMIO_ACTIVE |
+			 EEH_STATE_DMA_ACTIVE;
+		break;
+	case 1:
+		result = EEH_STATE_RESET_ACTIVE |
+			 EEH_STATE_MMIO_ACTIVE  |
+			 EEH_STATE_DMA_ACTIVE;
+		break;
+	case 2:
+		result = 0;
+		break;
+	case 4:
+		result = EEH_STATE_MMIO_ENABLED;
+		break;
+	case 5:
+		if (rets[2]) {
+			if (state) *state = rets[2];
+			result = EEH_STATE_UNAVAILABLE;
+		} else {
 			result = EEH_STATE_NOT_SUPPORT;
 		}
-	} else {
+		break;
+	default:
 		result = EEH_STATE_NOT_SUPPORT;
 	}
 
-- 
2.1.0

  parent reply	other threads:[~2015-10-08  4:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-08  3:58 [PATCH v2 0/8] EEH Improvement and Cleanup Gavin Shan
2015-10-08  3:58 ` [PATCH v2 1/8] powerpc/eeh: Don't unfreeze PHB PE after reset Gavin Shan
2015-10-21 11:41   ` [v2,1/8] " Michael Ellerman
2015-10-08  3:58 ` [PATCH v2 2/8] powerpc/eeh: More relexed hotplug criterion Gavin Shan
2015-10-12 22:55   ` Daniel Axtens
2015-10-12 23:25     ` Gavin Shan
2015-10-13  2:48       ` Daniel Axtens
2015-10-13  4:28         ` Gavin Shan
2015-10-13 23:48           ` Daniel Axtens
2015-10-14  1:33             ` Gavin Shan
2015-10-08  3:58 ` [PATCH v2 3/8] powerpc/eeh: Force reset on fenced PHB Gavin Shan
2015-10-13  1:43   ` Daniel Axtens
2015-10-13  5:01     ` Gavin Shan
2015-10-13  5:18       ` Daniel Axtens
2015-10-08  3:58 ` [PATCH v2 4/8] powerpc/eeh: More relxed condition for enabled IO path Gavin Shan
2015-10-08  3:58 ` Gavin Shan [this message]
2015-10-08  4:15   ` [PATCH v2 5/8] powerpc/pseries: Cleanup on pseries_eeh_get_state() Andrew Donnellan
2015-10-08  3:58 ` [PATCH v2 6/8] powerpc/powernv: Cleanup on EEH comments Gavin Shan
2015-10-08  3:58 ` [PATCH v2 7/8] powerpc/powernv: Remove pnv_eeh_cap_start() Gavin Shan
2015-10-08  4:18   ` Andrew Donnellan
2015-10-08  3:58 ` [PATCH v2 8/8] powerpc/powernv: Simplify pnv_eeh_set_option() Gavin Shan
2015-10-08  4:33   ` Andrew Donnellan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444276739-20372-6-git-send-email-gwshan@linux.vnet.ibm.com \
    --to=gwshan@linux.vnet.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mpe@ellerman.id.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).