diff options
author | Cédric Le Goater <clg@fr.ibm.com> | 2015-03-30 06:06:09 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2015-03-30 23:50:33 -0400 |
commit | e3c5c2e0bc857c7cbdb81f35a6b90236c5f330e9 (patch) | |
tree | bf62f0f6a535426d53b389a2e1aab229461ea302 | |
parent | acdb66857fb9a713c93bb3e6edba5ee478ba0678 (diff) |
powerpc/powernv: convert codes returned by OPAL calls
OPAL has its own list of return codes. The patch provides a translation
of such codes in errnos for the opal_sensor_read call, and possibly
others if needed.
Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r-- | arch/powerpc/include/asm/opal.h | 2 | ||||
-rw-r--r-- | arch/powerpc/platforms/powernv/opal-sensor.c | 6 | ||||
-rw-r--r-- | arch/powerpc/platforms/powernv/opal.c | 19 |
3 files changed, 25 insertions, 2 deletions
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h index c08de77f398a..fde90bacc65e 100644 --- a/arch/powerpc/include/asm/opal.h +++ b/arch/powerpc/include/asm/opal.h | |||
@@ -247,6 +247,8 @@ struct opal_sg_list *opal_vmalloc_to_sg_list(void *vmalloc_addr, | |||
247 | unsigned long vmalloc_size); | 247 | unsigned long vmalloc_size); |
248 | void opal_free_sg_list(struct opal_sg_list *sg); | 248 | void opal_free_sg_list(struct opal_sg_list *sg); |
249 | 249 | ||
250 | extern int opal_error_code(int rc); | ||
251 | |||
250 | #endif /* __ASSEMBLY__ */ | 252 | #endif /* __ASSEMBLY__ */ |
251 | 253 | ||
252 | #endif /* _ASM_POWERPC_OPAL_H */ | 254 | #endif /* _ASM_POWERPC_OPAL_H */ |
diff --git a/arch/powerpc/platforms/powernv/opal-sensor.c b/arch/powerpc/platforms/powernv/opal-sensor.c index 4ab67ef7abc9..e9c5d8f33d4c 100644 --- a/arch/powerpc/platforms/powernv/opal-sensor.c +++ b/arch/powerpc/platforms/powernv/opal-sensor.c | |||
@@ -46,8 +46,10 @@ int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data) | |||
46 | 46 | ||
47 | mutex_lock(&opal_sensor_mutex); | 47 | mutex_lock(&opal_sensor_mutex); |
48 | ret = opal_sensor_read(sensor_hndl, token, &data); | 48 | ret = opal_sensor_read(sensor_hndl, token, &data); |
49 | if (ret != OPAL_ASYNC_COMPLETION) | 49 | if (ret != OPAL_ASYNC_COMPLETION) { |
50 | ret = opal_error_code(ret); | ||
50 | goto out_token; | 51 | goto out_token; |
52 | } | ||
51 | 53 | ||
52 | ret = opal_async_wait_response(token, &msg); | 54 | ret = opal_async_wait_response(token, &msg); |
53 | if (ret) { | 55 | if (ret) { |
@@ -57,7 +59,7 @@ int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data) | |||
57 | } | 59 | } |
58 | 60 | ||
59 | *sensor_data = be32_to_cpu(data); | 61 | *sensor_data = be32_to_cpu(data); |
60 | ret = be64_to_cpu(msg.params[1]); | 62 | ret = opal_error_code(be64_to_cpu(msg.params[1])); |
61 | 63 | ||
62 | out_token: | 64 | out_token: |
63 | mutex_unlock(&opal_sensor_mutex); | 65 | mutex_unlock(&opal_sensor_mutex); |
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c index d403b2b08626..3fb981c0ca80 100644 --- a/arch/powerpc/platforms/powernv/opal.c +++ b/arch/powerpc/platforms/powernv/opal.c | |||
@@ -931,6 +931,25 @@ void opal_free_sg_list(struct opal_sg_list *sg) | |||
931 | } | 931 | } |
932 | } | 932 | } |
933 | 933 | ||
934 | int opal_error_code(int rc) | ||
935 | { | ||
936 | switch (rc) { | ||
937 | case OPAL_SUCCESS: return 0; | ||
938 | |||
939 | case OPAL_PARAMETER: return -EINVAL; | ||
940 | case OPAL_ASYNC_COMPLETION: return -EINPROGRESS; | ||
941 | case OPAL_BUSY_EVENT: return -EBUSY; | ||
942 | case OPAL_NO_MEM: return -ENOMEM; | ||
943 | |||
944 | case OPAL_UNSUPPORTED: return -EIO; | ||
945 | case OPAL_HARDWARE: return -EIO; | ||
946 | case OPAL_INTERNAL_ERROR: return -EIO; | ||
947 | default: | ||
948 | pr_err("%s: unexpected OPAL error %d\n", __func__, rc); | ||
949 | return -EIO; | ||
950 | } | ||
951 | } | ||
952 | |||
934 | EXPORT_SYMBOL_GPL(opal_poll_events); | 953 | EXPORT_SYMBOL_GPL(opal_poll_events); |
935 | EXPORT_SYMBOL_GPL(opal_rtc_read); | 954 | EXPORT_SYMBOL_GPL(opal_rtc_read); |
936 | EXPORT_SYMBOL_GPL(opal_rtc_write); | 955 | EXPORT_SYMBOL_GPL(opal_rtc_write); |