Skip to content

Commit

Permalink
firmware: arm_scmi: Avoid padding in sensor message structure
Browse files Browse the repository at this point in the history
scmi_resp_sensor_reading_complete structure is meant to represent an
SCMI asynchronous reading complete message. The readings field with
a 64bit type forces padding and breaks reads in scmi_sensor_reading_get.

Split it in two adjacent 32bit readings_low/high subfields to avoid the
padding within the structure. Alternatively we could to mark the structure
packed.

Link: https://lore.kernel.org/r/[email protected]
Fixes: e2083d3 ("firmware: arm_scmi: Add SCMI v3.0 sensors timestamped reads")
Signed-off-by: Cristian Marussi <[email protected]>
Signed-off-by: Sudeep Holla <[email protected]>
  • Loading branch information
freefall75 authored and sudeep-holla committed Jul 13, 2021
1 parent b98cf55 commit 187a002
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/firmware/arm_scmi/sensors.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ struct scmi_msg_sensor_reading_get {

struct scmi_resp_sensor_reading_complete {
__le32 id;
__le64 readings;
__le32 readings_low;
__le32 readings_high;
};

struct scmi_sensor_reading_resp {
Expand Down Expand Up @@ -717,7 +718,8 @@ static int scmi_sensor_reading_get(const struct scmi_protocol_handle *ph,

resp = t->rx.buf;
if (le32_to_cpu(resp->id) == sensor_id)
*value = get_unaligned_le64(&resp->readings);
*value =
get_unaligned_le64(&resp->readings_low);
else
ret = -EPROTO;
}
Expand Down

0 comments on commit 187a002

Please sign in to comment.