diff mbox series

[1/4] Bluetooth: Fix incorrect parsing of LE_PHY params

Message ID 20210722053843.6691-2-ayush.garg@samsung.com
State New
Headers show
Series [1/4] Bluetooth: Fix incorrect parsing of LE_PHY params | expand

Commit Message

Ayush Garg July 22, 2021, 5:38 a.m. UTC
This change is fixing the parsing of PHY LE CODED which is
represented with value 0x03 instead of 0x04 in LE PHY Update
Complete event.

> HCI Event: LE Meta Event (0x3e) plen 6
	  LE PHY Update Complete (0x0c)
		Status: Success (0x00)
		Handle: 0
		TX PHY: LE Coded (0x03)
		RX PHY: LE Coded (0x03)

Reviewed-by: Anupam Roy <anupam.r@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
---
 include/net/bluetooth/hci.h |  4 ++++
 net/bluetooth/hci_conn.c    | 21 +++++++++------------
 2 files changed, 13 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index b80415011dcd..56542a09ec43 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -1681,6 +1681,10 @@  struct hci_cp_le_set_default_phy {
 #define HCI_LE_SET_PHY_2M		0x02
 #define HCI_LE_SET_PHY_CODED		0x04
 
+#define HCI_LE_READ_PHY_1M		0x01
+#define HCI_LE_READ_PHY_2M		0x02
+#define HCI_LE_READ_PHY_CODED		0x03
+
 #define HCI_OP_LE_SET_EXT_SCAN_PARAMS   0x2041
 struct hci_cp_le_set_ext_scan_params {
 	__u8    own_addr_type;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 2b5059a56cda..383efd969840 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -1915,22 +1915,19 @@  u32 hci_conn_get_phy(struct hci_conn *conn)
 		break;
 
 	case LE_LINK:
-		if (conn->le_tx_phy & HCI_LE_SET_PHY_1M)
-			phys |= BT_PHY_LE_1M_TX;
-
-		if (conn->le_rx_phy & HCI_LE_SET_PHY_1M)
-			phys |= BT_PHY_LE_1M_RX;
 
-		if (conn->le_tx_phy & HCI_LE_SET_PHY_2M)
+		if (conn->le_tx_phy == HCI_LE_READ_PHY_1M)
+			phys |= BT_PHY_LE_1M_TX;
+		else if (conn->le_tx_phy == HCI_LE_READ_PHY_2M)
 			phys |= BT_PHY_LE_2M_TX;
-
-		if (conn->le_rx_phy & HCI_LE_SET_PHY_2M)
-			phys |= BT_PHY_LE_2M_RX;
-
-		if (conn->le_tx_phy & HCI_LE_SET_PHY_CODED)
+		else if (conn->le_tx_phy == HCI_LE_READ_PHY_CODED)
 			phys |= BT_PHY_LE_CODED_TX;
 
-		if (conn->le_rx_phy & HCI_LE_SET_PHY_CODED)
+		if (conn->le_rx_phy == HCI_LE_READ_PHY_1M)
+			phys |= BT_PHY_LE_1M_RX;
+		else if (conn->le_rx_phy == HCI_LE_READ_PHY_2M)
+			phys |= BT_PHY_LE_2M_RX;
+		else if (conn->le_rx_phy == HCI_LE_READ_PHY_CODED)
 			phys |= BT_PHY_LE_CODED_RX;
 
 		break;