[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-bluetooth
Subject:    [PATCH] Fix endianness bug in hci_core.c
From:       Andrey Batyiev <batyiev () gmail ! com>
Date:       2019-07-08 0:04:42
Message-ID: CAEQQxWxQ9A6D+jdc8hVjBjgGbvBovJFxEf7K9Rta+O4noRmSFg () mail ! gmail ! com
[Download RAW message or body]

Hello everyone,

I'm using Linux on big endian CPU (one of MIPS-based home routers).
Also, I'm trying to use Cypress CYW20704A2 USB-Bluetooth dongle on it.
However, `hciconfig hci0 up` failed, and `btmon` showed very specific problem:



< HCI Command: LE Write Suggested Default Data Length (0x08|0x0024) plen 4
        TX octets: 64256
        TX time: 18440
> HCI Event: Command Complete (0x0e) plen 4
      LE Write Suggested Default Data Length (0x08|0x0024) ncmd 1
        Status: Invalid HCI Command Parameters (0x12)



After comparing with similar log on the Linux desktop (where TX octets
value is `251`), I came to conclusion that it's an endianness problem,
therefore here is a patch that fixes it.

Thanks,
    Andrey

--- linux-4.14.104-old/net/bluetooth/hci_core.c 2019-07-07
23:39:44.069862824 +0000
+++ linux-4.14.104/net/bluetooth/hci_core.c     2019-07-07
22:43:21.291838543 +0000
@@ -802,8 +802,8 @@
       if (hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) {
               struct hci_cp_le_write_def_data_len cp;

-               cp.tx_len = hdev->le_max_tx_len;
-               cp.tx_time = hdev->le_max_tx_time;
+               cp.tx_len = cpu_to_le16(hdev->le_max_tx_len);
+               cp.tx_time = cpu_to_le16(hdev->le_max_tx_time);
               hci_req_add(req, HCI_OP_LE_WRITE_DEF_DATA_LEN, sizeof(cp), &cp);
       }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic