Skip to contentSkip to conversation

powerpc/rtas: Replace magic values with defines

PATCH Applied Thomas Huth 3 participants 3 messages Jul 22, 2015 – Aug 3, 2015 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/rtas: Replace magic values with defines

rtas.h already has some nice #defines for RTAS return status codes - let's use them instead of hard-coded "magic" values!

---
 arch/powerpc/kernel/rtas.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
arch/powerpc/kernel/rtas.c +5 -3
index 7a488c1..10fb402 100644
@@ -478,8 +478,9 @@ unsigned int rtas_busy_delay_time(int status)
 
 	if (status == RTAS_BUSY) {
 		ms = 1;
-	} else if (status >= 9900 && status <= 9905) {
-		order = status - 9900;
+	} else if (status >= RTAS_EXTENDED_DELAY_MIN &&
+		   status <= RTAS_EXTENDED_DELAY_MAX) {
+		order = status - RTAS_EXTENDED_DELAY_MIN;
 		for (ms = 1; order > 0; order--)
 			ms *= 10;
 	}
@@ -641,7 +642,8 @@ int rtas_set_indicator_fast(int indicator, int index, int new_value)
 
 	rc = rtas_call(token, 3, 1, NULL, indicator, index, new_value);
 
-	WARN_ON(rc == -2 || (rc >= 9900 && rc <= 9905));
+	WARN_ON(rc == RTAS_BUSY || (rc >= RTAS_EXTENDED_DELAY_MIN &&
+				    rc <= RTAS_EXTENDED_DELAY_MAX));
 
 	if (rc < 0)
 		return rtas_error_rc(rc);
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Thomas Huth

rtas.h already has some nice #defines for RTAS return status codes - let's use them instead of hard-coded "magic" values!

Quoted 31 lines
---
 arch/powerpc/kernel/rtas.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
arch/powerpc/kernel/rtas.c +5 -3
index 7a488c1..10fb402 100644
@@ -478,8 +478,9 @@ unsigned int rtas_busy_delay_time(int status)
 
 	if (status == RTAS_BUSY) {
 		ms = 1;
-	} else if (status >= 9900 && status <= 9905) {
-		order = status - 9900;
+	} else if (status >= RTAS_EXTENDED_DELAY_MIN &&
+		   status <= RTAS_EXTENDED_DELAY_MAX) {
+		order = status - RTAS_EXTENDED_DELAY_MIN;
 		for (ms = 1; order > 0; order--)
 			ms *= 10;
 	}
@@ -641,7 +642,8 @@ int rtas_set_indicator_fast(int indicator, int index, int new_value)
 
 	rc = rtas_call(token, 3, 1, NULL, indicator, index, new_value);
 
-	WARN_ON(rc == -2 || (rc >= 9900 && rc <= 9905));
+	WARN_ON(rc == RTAS_BUSY || (rc >= RTAS_EXTENDED_DELAY_MIN &&
+				    rc <= RTAS_EXTENDED_DELAY_MAX));
 
 	if (rc < 0)
 		return rtas_error_rc(rc);