Skip to content

Commit

Permalink
firmware: arm_scpi: improve struct sensor_value
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
  • Loading branch information
Heiner Kallweit authored and Sudeep Holla committed Oct 5, 2017
1 parent 4864dca commit 5c7ae64
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions drivers/firmware/arm_scpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -785,11 +784,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;
}
Expand Down

0 comments on commit 5c7ae64

Please sign in to comment.