[PATCH] Fix endianness bug in hci_core.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);
       }



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux