Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <alexander.wilhelm@westermo.com>
Fixes: 9b8a11e82615 ("soc: qcom: Introduce QMI encoder/decoder")
Fixes: 3830d0771ef6 ("soc: qcom: Introduce QMI helpers")
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250522143530.3623809-3-alexander.wilhelm@westermo.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Alexander Wilhelm and committed by
Bjorn Andersson
07a46888 3ced38da

+9 -9
+3 -3
drivers/soc/qcom/qmi_encdec.c
··· 776 776 777 777 hdr = msg; 778 778 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); 782 782 783 783 *len = sizeof(*hdr) + msglen; 784 784
+3 -3
drivers/soc/qcom/qmi_interface.c
··· 400 400 401 401 for (handler = qmi->handlers; handler->fn; handler++) { 402 402 if (handler->type == hdr->type && 403 - handler->msg_id == hdr->msg_id) 403 + handler->msg_id == le16_to_cpu(hdr->msg_id)) 404 404 break; 405 405 } 406 406 ··· 488 488 /* If this is a response, find the matching transaction handle */ 489 489 if (hdr->type == QMI_RESPONSE) { 490 490 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)); 492 492 493 493 /* Ignore unexpected responses */ 494 494 if (!txn) { ··· 514 514 } else { 515 515 /* Create a txn based on the txn_id of the incoming message */ 516 516 memset(&tmp_txn, 0, sizeof(tmp_txn)); 517 - tmp_txn.id = hdr->txn_id; 517 + tmp_txn.id = le16_to_cpu(hdr->txn_id); 518 518 519 519 qmi_invoke_handler(qmi, sq, &tmp_txn, buf, len); 520 520 }
+3 -3
include/linux/soc/qcom/qmi.h
··· 24 24 */ 25 25 struct qmi_header { 26 26 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; 30 30 } __packed; 31 31 32 32 #define QMI_REQUEST 0