diff options
author | Gautham R. Shenoy <ego@linux.vnet.ibm.com> | 2020-04-27 20:26:41 +0530 |
---|---|---|
committer | Oliver O'Halloran <oohall@gmail.com> | 2020-05-26 14:30:29 +1000 |
commit | 1beb1519f4c39c3d4c418aafa219236568c38c8d (patch) | |
tree | e58621a0724b67d26f847d0fad9e18e5c3aee7f3 /hw | |
parent | f3ac046b386fea80286c72c3217acb407230a8c6 (diff) | |
download | skiboot-1beb1519f4c39c3d4c418aafa219236568c38c8d.zip skiboot-1beb1519f4c39c3d4c418aafa219236568c38c8d.tar.gz skiboot-1beb1519f4c39c3d4c418aafa219236568c38c8d.tar.bz2 |
sensors: occ: Fix a bug when sensor values are zero
The commit 1b9a449d ("opal-api: add endian conversions to most opal
calls") modified the code in opal_read_sensor() to make it
Little-Endian safe. In the process, it changed the code so that if a
sensor value was zero, it would simply return OPAL_SUCCESS without
updating the return buffer. As a result, the return buffer contained
bogus values which were reflected on those sensors being read by the
Kernel.
This patch fixes it by ensuring that the return buffer is updated with
the value read from the sensor every time.
Thanks to Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> for
spotting the missing return-buffer update.
cc: skiboot-stable@lists.ozlabs.org
Fixes: commit 1b9a449d ("opal-api: add endian conversions to most opal
calls")
Reported-by: Pavaman Subramaniyam <pavsubra@in.ibm.com>
Tested-by: Pavaman Subramaniyam <pavsubra@in.ibm.com>
Reviewed-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/occ-sensor.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/occ-sensor.c b/hw/occ-sensor.c index d97cc33..8605c40 100644 --- a/hw/occ-sensor.c +++ b/hw/occ-sensor.c @@ -276,7 +276,7 @@ int occ_sensor_read(u32 handle, __be64 *data) d = read_sensor(buff, attr); if (!d) - return OPAL_SUCCESS; + goto out_success; md = get_names_block(hb); if (be16_to_cpu(md[id].type) == OCC_SENSOR_TYPE_POWER && attr == SENSOR_ACCUMULATOR) @@ -284,6 +284,7 @@ int occ_sensor_read(u32 handle, __be64 *data) else scale_sensor(&md[id], &d); +out_success: *data = cpu_to_be64(d); return OPAL_SUCCESS; |