Skip to contentSkip to conversation

Bluetooth: Use only 2 bits for controller type information

PATCH In review Marcel Holtmann 2 participants 5 messages Sep 29, 2013 – Oct 2, 2013

Subsystems (2)
lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

PATCH 1/1 Bluetooth: Use only 2 bits for controller type information

The controller type is limited to BR/EDR/LE and AMP controllers. This can be easily encoded with just 2 bits and still leave enough room for future controller types.

---
 net/bluetooth/hci_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/hci_core.c +1 -1
index 4549b5c..ebba5a6 100644
@@ -1610,7 +1610,7 @@ int hci_get_dev_info(void __user *arg)
 
 	strcpy(di.name, hdev->name);
 	di.bdaddr   = hdev->bdaddr;
-	di.type     = (hdev->bus & 0x0f) | (hdev->dev_type << 4);
+	di.type     = (hdev->bus & 0x0f) | ((hdev->dev_type & 0x30) << 4);
 	di.flags    = hdev->flags;
 	di.pkt_type = hdev->pkt_type;
 	if (lmp_bredr_capable(hdev)) {
Signature · 1 line
1.8.3.1
#1 lore raw

Hi Marcel,

Quoted 14 lines · Marcel Holtmann

The controller type is limited to BR/EDR/LE and AMP controllers. This can be easily encoded with just 2 bits and still leave enough room for future controller types.

---
 net/bluetooth/hci_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/hci_core.c +0 -0
index 4549b5c..ebba5a6 100644

net/bluetooth/hci_core.c int hci_get_dev_info(void __user *arg) · line 1613

Quoted 5 lines
net/bluetooth/hci_core.c +1 -1
@@ -1610,7 +1610,7 @@ int hci_get_dev_info(void __user *arg)
 
        strcpy(di.name, hdev->name);
        di.bdaddr   = hdev->bdaddr;
-       di.type     = (hdev->bus & 0x0f) | (hdev->dev_type << 4);
+       di.type     = (hdev->bus & 0x0f) | ((hdev->dev_type & 0x30) << 4);

Shouldn't it be (hdev->dev_type & 0x03) here?

Best Regards,

Signature · 3 lines
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
author maintainer
#2 lore raw

Hi Anderson,

Quoted 15 lines
Quoted 15 lines

The controller type is limited to BR/EDR/LE and AMP controllers. This can be easily encoded with just 2 bits and still leave enough room for future controller types.

---
net/bluetooth/hci_core.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/hci_core.c +0 -0
index 4549b5c..ebba5a6 100644
@@ -1610,7 +1610,7 @@ int hci_get_dev_info(void __user *arg)
 
Quoted 6 lines

net/bluetooth/hci_core.c int hci_get_dev_info(void __user *arg) · line 1613

Quoted 4 lines
net/bluetooth/hci_core.c +1 -1
       strcpy(di.name, hdev->name);
       di.bdaddr   = hdev->bdaddr;
-       di.type     = (hdev->bus & 0x0f) | (hdev->dev_type << 4);
+       di.type     = (hdev->bus & 0x0f) | ((hdev->dev_type & 0x30) << 4);

Shouldn't it be (hdev->dev_type & 0x03) here?

yes, this it should be 0x03 here. My mistake.

Regards

Marcel

#3 lore raw

Hi Marcel,

Quoted 6 lines · Marcel Holtmann
Quoted 4 lines

net/bluetooth/hci_core.c int hci_get_dev_info(void __user *arg) · line 1613

Quoted 2 lines
net/bluetooth/hci_core.c +1 -1
-       di.type     = (hdev->bus & 0x0f) | (hdev->dev_type << 4);
+       di.type     = (hdev->bus & 0x0f) | ((hdev->dev_type & 0x30) << 4);

Shouldn't it be (hdev->dev_type & 0x03) here?

yes, this it should be 0x03 here. My mistake.

Just a reminder that userspace needs fixing as well.

Best Regards,

Signature · 3 lines
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
#4 lore raw

Hi Marcel,

Quoted 11 lines · Anderson Lizardo

Hi Marcel,

Quoted 6 lines · Marcel Holtmann
Quoted 4 lines

net/bluetooth/hci_core.c int hci_get_dev_info(void __user *arg) · line 1613

Quoted 2 lines
net/bluetooth/hci_core.c +1 -1
-       di.type     = (hdev->bus & 0x0f) | (hdev->dev_type << 4);
+       di.type     = (hdev->bus & 0x0f) | ((hdev->dev_type & 0x30) << 4);

Shouldn't it be (hdev->dev_type & 0x03) here?

yes, this it should be 0x03 here. My mistake.

Just a reminder that userspace needs fixing as well.

My mistake, userspace is fine. :)

Best Regards,

Signature · 3 lines
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil