Skip to content

Commit 07a4688

Browse files
Alexander Wilhelmandersson
authored andcommitted
soc: qcom: fix endianness for QMI header
The members of QMI header have to be swapped on big endian platforms. Use __le16 types instead of u16 ones. Signed-off-by: Alexander Wilhelm <[email protected]> Fixes: 9b8a11e ("soc: qcom: Introduce QMI encoder/decoder") Fixes: 3830d07 ("soc: qcom: Introduce QMI helpers") Reviewed-by: Dmitry Baryshkov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 3ced38d commit 07a4688

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

drivers/soc/qcom/qmi_encdec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,9 @@ void *qmi_encode_message(int type, unsigned int msg_id, size_t *len,
776776

777777
hdr = msg;
778778
hdr->type = type;
779-
hdr->txn_id = txn_id;
780-
hdr->msg_id = msg_id;
781-
hdr->msg_len = msglen;
779+
hdr->txn_id = cpu_to_le16(txn_id);
780+
hdr->msg_id = cpu_to_le16(msg_id);
781+
hdr->msg_len = cpu_to_le16(msglen);
782782

783783
*len = sizeof(*hdr) + msglen;
784784

drivers/soc/qcom/qmi_interface.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ static void qmi_invoke_handler(struct qmi_handle *qmi, struct sockaddr_qrtr *sq,
400400

401401
for (handler = qmi->handlers; handler->fn; handler++) {
402402
if (handler->type == hdr->type &&
403-
handler->msg_id == hdr->msg_id)
403+
handler->msg_id == le16_to_cpu(hdr->msg_id))
404404
break;
405405
}
406406

@@ -488,7 +488,7 @@ static void qmi_handle_message(struct qmi_handle *qmi,
488488
/* If this is a response, find the matching transaction handle */
489489
if (hdr->type == QMI_RESPONSE) {
490490
mutex_lock(&qmi->txn_lock);
491-
txn = idr_find(&qmi->txns, hdr->txn_id);
491+
txn = idr_find(&qmi->txns, le16_to_cpu(hdr->txn_id));
492492

493493
/* Ignore unexpected responses */
494494
if (!txn) {
@@ -514,7 +514,7 @@ static void qmi_handle_message(struct qmi_handle *qmi,
514514
} else {
515515
/* Create a txn based on the txn_id of the incoming message */
516516
memset(&tmp_txn, 0, sizeof(tmp_txn));
517-
tmp_txn.id = hdr->txn_id;
517+
tmp_txn.id = le16_to_cpu(hdr->txn_id);
518518

519519
qmi_invoke_handler(qmi, sq, &tmp_txn, buf, len);
520520
}

include/linux/soc/qcom/qmi.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ struct socket;
2424
*/
2525
struct qmi_header {
2626
u8 type;
27-
u16 txn_id;
28-
u16 msg_id;
29-
u16 msg_len;
27+
__le16 txn_id;
28+
__le16 msg_id;
29+
__le16 msg_len;
3030
} __packed;
3131

3232
#define QMI_REQUEST 0

0 commit comments

Comments
 (0)