Blob Blame History Raw
From 4e46c718f42bf05e797c7fcfdd6cfc2a21fb4c91 Mon Sep 17 00:00:00 2001
From: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Date: Wed, 7 Jan 2015 14:26:15 -0500
Subject: [PATCH] PAPR requires that the status word is the first parameter in
 the return buffer for rtas calls. Due to this requirement the librtas
 sc_rtas_call function always performs a be32toh operation on the first
 parameter in the return buffer. However, the ibm,open-errinjct rtas is
 special in that its return buffer is switched. The "Open Token" is the first
 return parameter while the "Status" word is second.

This patch fixes this special case in the sc_errinjct_open function such
that the byteswapping of "status" and "otoken" are handled correctly.

Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
---
 librtas_src/syscall_calls.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/librtas_src/syscall_calls.c b/librtas_src/syscall_calls.c
index dc52370..a81c25c 100644
--- a/librtas_src/syscall_calls.c
+++ b/librtas_src/syscall_calls.c
@@ -493,20 +493,20 @@ int sc_errinjct_close(int token, int otoken)
 int sc_errinjct_open(int token, int *otoken)
 {
 	uint64_t elapsed = 0;
-	__be32 be_otoken;
+	__be32 be_status;
 	int status;
 	int rc;
 
 	do {
-		rc = sc_rtas_call(token, 0, 2, &be_otoken, &status);
+		rc = sc_rtas_call(token, 0, 2, otoken, &be_status);
 		if (rc)
 			return rc;
 
+		status = be32toh(be_status);
+
 		rc = handle_delay(status, &elapsed);
 	} while (rc == CALL_AGAIN);
 
-	*otoken = be32toh(be_otoken);
-
 	dbg1("(%p) = %d, %d\n", otoken, rc ? rc : status, *otoken);
 	return rc ? rc : status;
 }
-- 
1.9.3