summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiner Kallweit <hkallweit1@gmail.com>2017-12-05 23:16:58 +0100
committerSudeep Holla <sudeep.holla@arm.com>2018-02-23 16:12:47 +0100
commit83a6060c0cd07cafdf8baa08e26c602a06977a2c (patch)
treecbf1d02654b0dbf809e8ac895ecb22f006286e10
parentfirmware: arm_scpi: improve handling of protocol and firmware version subfields (diff)
downloadlinux-83a6060c0cd07cafdf8baa08e26c602a06977a2c.tar.xz
linux-83a6060c0cd07cafdf8baa08e26c602a06977a2c.zip
firmware: arm_scpi: improve struct sensor_value
lo_val and hi_val together in this order are a little endian 64 bit value. Therefore we can simplify struct sensor_value and the code by defining it as a __le64 value and by using le64_to_cpu. Tested-by: Kevin Hilman <khilman@baylibre.com> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
-rw-r--r--drivers/firmware/arm_scpi.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
index 63441e403f60..4447af482fe9 100644
--- a/drivers/firmware/arm_scpi.c
+++ b/drivers/firmware/arm_scpi.c
@@ -347,9 +347,8 @@ struct _scpi_sensor_info {
};
struct sensor_value {
- __le32 lo_val;
- __le32 hi_val;
-} __packed;
+ __le64 val;
+};
struct dev_pstate_set {
__le16 dev_id;
@@ -777,11 +776,10 @@ static int scpi_sensor_get_value(u16 sensor, u64 *val)
return ret;
if (scpi_info->is_legacy)
- /* only 32-bits supported, hi_val can be junk */
- *val = le32_to_cpu(buf.lo_val);
+ /* only 32-bits supported, upper 32 bits can be junk */
+ *val = le32_to_cpup((__le32 *)&buf.val);
else
- *val = (u64)le32_to_cpu(buf.hi_val) << 32 |
- le32_to_cpu(buf.lo_val);
+ *val = le64_to_cpu(buf.val);
return 0;
}