powerpc/powernv: convert OPAL codes returned by sysparam calls
authorCédric Le Goater <clg@fr.ibm.com>
Wed, 8 Apr 2015 07:31:10 +0000 (09:31 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 4 Jun 2015 12:27:56 +0000 (22:27 +1000)
The opal_{get,set}_param calls return internal error codes which need
to be translated in errnos in Linux.

Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/platforms/powernv/opal-sysparam.c
arch/powerpc/platforms/powernv/opal.c

index 2e52b47393e734bc6f19f2936dfa9cd7785f2e70..afe66c576a385f4204860766fa69b9d6fd3e590f 100644 (file)
@@ -55,8 +55,10 @@ static ssize_t opal_get_sys_param(u32 param_id, u32 length, void *buffer)
        }
 
        ret = opal_get_param(token, param_id, (u64)buffer, length);
-       if (ret != OPAL_ASYNC_COMPLETION)
+       if (ret != OPAL_ASYNC_COMPLETION) {
+               ret = opal_error_code(ret);
                goto out_token;
+       }
 
        ret = opal_async_wait_response(token, &msg);
        if (ret) {
@@ -65,7 +67,7 @@ static ssize_t opal_get_sys_param(u32 param_id, u32 length, void *buffer)
                goto out_token;
        }
 
-       ret = be64_to_cpu(msg.params[1]);
+       ret = opal_error_code(be64_to_cpu(msg.params[1]));
 
 out_token:
        opal_async_release_token(token);
@@ -89,8 +91,10 @@ static int opal_set_sys_param(u32 param_id, u32 length, void *buffer)
 
        ret = opal_set_param(token, param_id, (u64)buffer, length);
 
-       if (ret != OPAL_ASYNC_COMPLETION)
+       if (ret != OPAL_ASYNC_COMPLETION) {
+               ret = opal_error_code(ret);
                goto out_token;
+       }
 
        ret = opal_async_wait_response(token, &msg);
        if (ret) {
@@ -99,7 +103,7 @@ static int opal_set_sys_param(u32 param_id, u32 length, void *buffer)
                goto out_token;
        }
 
-       ret = be64_to_cpu(msg.params[1]);
+       ret = opal_error_code(be64_to_cpu(msg.params[1]));
 
 out_token:
        opal_async_release_token(token);
index 8403307c53624d0bc7f94c98782545b10789d59d..fd694bd51b80a64c5a281eb8df0639da75ea9591 100644 (file)
@@ -830,6 +830,7 @@ int opal_error_code(int rc)
        case OPAL_ASYNC_COMPLETION:     return -EINPROGRESS;
        case OPAL_BUSY_EVENT:           return -EBUSY;
        case OPAL_NO_MEM:               return -ENOMEM;
+       case OPAL_PERMISSION:           return -EPERM;
 
        case OPAL_UNSUPPORTED:          return -EIO;
        case OPAL_HARDWARE:             return -EIO;