aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGautham R. Shenoy <ego@linux.vnet.ibm.com>2020-04-27 20:26:41 +0530
committerVasant Hegde <hegdevasant@linux.vnet.ibm.com>2020-06-06 10:18:44 +0530
commit2c0df45c265db388d90ce036ce72ac9d4ce75f97 (patch)
tree0bbf83da99c14ea5623b4d84a58a4e242a11038f
parent42e2125a1d576207e51947d7a26e9d91eda5e2c8 (diff)
downloadskiboot-2c0df45c265db388d90ce036ce72ac9d4ce75f97.zip
skiboot-2c0df45c265db388d90ce036ce72ac9d4ce75f97.tar.gz
skiboot-2c0df45c265db388d90ce036ce72ac9d4ce75f97.tar.bz2
sensors: occ: Fix a bug when sensor values are zero
[ Upstream commit 1beb1519f4c39c3d4c418aafa219236568c38c8d ] 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> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
-rw-r--r--hw/occ-sensor.c3
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;