提交 83a6060c 编写于 作者: H Heiner Kallweit 提交者: Sudeep Holla

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: NKevin Hilman <khilman@baylibre.com>
Signed-off-by: NHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: NSudeep Holla <sudeep.holla@arm.com>
上级 7cd49a26
...@@ -347,9 +347,8 @@ struct _scpi_sensor_info { ...@@ -347,9 +347,8 @@ struct _scpi_sensor_info {
}; };
struct sensor_value { struct sensor_value {
__le32 lo_val; __le64 val;
__le32 hi_val; };
} __packed;
struct dev_pstate_set { struct dev_pstate_set {
__le16 dev_id; __le16 dev_id;
...@@ -777,11 +776,10 @@ static int scpi_sensor_get_value(u16 sensor, u64 *val) ...@@ -777,11 +776,10 @@ static int scpi_sensor_get_value(u16 sensor, u64 *val)
return ret; return ret;
if (scpi_info->is_legacy) if (scpi_info->is_legacy)
/* only 32-bits supported, hi_val can be junk */ /* only 32-bits supported, upper 32 bits can be junk */
*val = le32_to_cpu(buf.lo_val); *val = le32_to_cpup((__le32 *)&buf.val);
else else
*val = (u64)le32_to_cpu(buf.hi_val) << 32 | *val = le64_to_cpu(buf.val);
le32_to_cpu(buf.lo_val);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册