Commit 6bc08d03 authored by Cédric Le Goater's avatar Cédric Le Goater Committed by Michael Ellerman

powerpc/powernv: handle OPAL_SUCCESS return in opal_sensor_read

Currently, when a sensor value is read, the kernel calls OPAL, which in
turn builds a message for the FSP, and waits for a message back.

The new device tree for OPAL sensors [1] adds new sensors that can be
read synchronously (core temperatures for instance) and that don't need
to wait for a response.

This patch modifies the opal call to accept an OPAL_SUCCESS return value
and cover the case above.

[1] https://lists.ozlabs.org/pipermail/skiboot/2015-March/000639.htmlSigned-off-by: default avatarCédric Le Goater <clg@fr.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent e3c5c2e0
...@@ -46,11 +46,8 @@ int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data) ...@@ -46,11 +46,8 @@ int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data)
mutex_lock(&opal_sensor_mutex); mutex_lock(&opal_sensor_mutex);
ret = opal_sensor_read(sensor_hndl, token, &data); ret = opal_sensor_read(sensor_hndl, token, &data);
if (ret != OPAL_ASYNC_COMPLETION) { switch (ret) {
ret = opal_error_code(ret); case OPAL_ASYNC_COMPLETION:
goto out_token;
}
ret = opal_async_wait_response(token, &msg); ret = opal_async_wait_response(token, &msg);
if (ret) { if (ret) {
pr_err("%s: Failed to wait for the async response, %d\n", pr_err("%s: Failed to wait for the async response, %d\n",
...@@ -58,8 +55,19 @@ int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data) ...@@ -58,8 +55,19 @@ int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data)
goto out_token; goto out_token;
} }
*sensor_data = be32_to_cpu(data);
ret = opal_error_code(be64_to_cpu(msg.params[1])); ret = opal_error_code(be64_to_cpu(msg.params[1]));
*sensor_data = be32_to_cpu(data);
break;
case OPAL_SUCCESS:
ret = 0;
*sensor_data = be32_to_cpu(data);
break;
default:
ret = opal_error_code(ret);
break;
}
out_token: out_token:
mutex_unlock(&opal_sensor_mutex); mutex_unlock(&opal_sensor_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment