uqmi: fix big endian bugs in MBIM code
authorBjørn Mork <bjorn@mork.no>
Tue, 23 Aug 2016 12:31:05 +0000 (14:31 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 24 Aug 2016 09:06:32 +0000 (11:06 +0200)
All MBIM integer fields are 32bit little endian.  So we need to convert
then all on big endian systems.

Fixes: e69bf24b00d8 ("uqmi: add support for MBIM devices with QMI service")
Signed-off-by: Bjørn Mork <bjorn@mork.no>
mbim.c

diff --git a/mbim.c b/mbim.c
index 33ce19da0f9fcc611e30b5461bec1d281348e6c4..f5336b15a7f6bfa36a73ade553e2634ff81f6531 100644 (file)
--- a/mbim.c
+++ b/mbim.c
@@ -39,12 +39,12 @@ bool is_mbim_qmi(struct mbim_command_message *msg)
 void mbim_qmi_cmd(struct mbim_command_message *msg, int len, uint16_t tid)
 {
        msg->header.type = cpu_to_le32(MBIM_MESSAGE_TYPE_COMMAND);
-       msg->header.length = sizeof(*msg) + len;
+       msg->header.length = cpu_to_le32(sizeof(*msg) + len);
        msg->header.transaction_id = cpu_to_le32(tid);
-       msg->fragment_header.total = 1;
+       msg->fragment_header.total = cpu_to_le32(1);
        msg->fragment_header.current = 0;
        memcpy(msg->service_id, qmiuuid, 16);
        msg->command_id = cpu_to_le32(MBIM_CID_QMI_MSG);
        msg->command_type = cpu_to_le32(MBIM_MESSAGE_COMMAND_TYPE_SET);
-       msg->buffer_length = len;
+       msg->buffer_length = cpu_to_le32(len);
 }