From 7f841902eb50ca77c3aa884e3fd924c2bbd817ca Mon Sep 17 00:00:00 2001
From: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Date: Mon, 13 Jun 2016 09:33:57 -0400
Subject: [PATCH] librtas: Fix endianess issue in errinjct rtas call
Unlike other RTAS calls, first output parameter of "ibm,open-errinjct"
is "open token", not status value.
With commit ee457b1c, we endedup calling be32toh twice for otoken and
didn't convert status from BE to host format.
This patch fixes above issue.
Fixes: ee457b1c (librtas: consolidate common actions in making a rtas call)
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Reviewed-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
---
librtas_src/syscall_calls.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/librtas_src/syscall_calls.c b/librtas_src/syscall_calls.c
index cb668dc..a194e4b 100644
--- a/librtas_src/syscall_calls.c
+++ b/librtas_src/syscall_calls.c
@@ -466,15 +466,20 @@ int rtas_errinjct_close(int otoken)
*/
int rtas_errinjct_open(int *otoken)
{
- __be32 be_otoken;
+ __be32 be_status;
int rc, status;
rc = sanity_check();
if (rc)
return rc;
- rc = rtas_call("ibm,open-errinjct", 0, 2, &be_otoken, &status);
- *otoken = be32toh(be_otoken);
+ /*
+ * Unlike other RTAS calls, here first output parameter is otoken,
+ * not status. rtas_call converts otoken to host endianess. We
+ * have to convert status parameter.
+ */
+ rc = rtas_call("ibm,open-errinjct", 0, 2, otoken, &be_status);
+ status = be32toh(be_status);
dbg("(%p) = %d, %d\n", otoken, rc ? rc : status, *otoken);
return rc ? rc : status;
--
2.4.11