Skip to contentSkip to conversation

Bluetooth: Fix Class of Device indication when powering off

PATCH In review Johan Hedberg 3 participants 3 messages Jan 16, 2013 – Jan 23, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: Fix Class of Device indication when powering off

From: Johan Hedberg <[email protected]>

When a HCI device is powered off the Management interface specification dictates that the class of device value is indicated as zero. This patch fixes sending of the appropriate class of device changed event when a HCI device is powered off.

---
 net/bluetooth/mgmt.c |    6 ++++++
 1 file changed, 6 insertions(+)
net/bluetooth/mgmt.c +6 -0
index fc171f2..54f3ddba 100644
@@ -2987,7 +2987,13 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered)
 		}
 	} else {
 		u8 status = MGMT_STATUS_NOT_POWERED;
+		u8 zero_cod[] = { 0, 0, 0 };
+
 		mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status);
+
+		if (memcmp(hdev->dev_class, zero_cod, sizeof(zero_cod)) != 0)
+			mgmt_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev,
+				   zero_cod, sizeof(zero_cod), NULL);
 	}
 
 	err = new_settings(hdev, match.sk);
Signature · 1 line
1.7.10.4
maintainer Acked-by on v1 1/1
#1 lore raw

Hi Johan,

Quoted 15 lines

When a HCI device is powered off the Management interface specification dictates that the class of device value is indicated as zero. This patch fixes sending of the appropriate class of device changed event when a HCI device is powered off.

---
 net/bluetooth/mgmt.c |    6 ++++++
 1 file changed, 6 insertions(+)
net/bluetooth/mgmt.c +0 -0
index fc171f2..54f3ddba 100644

net/bluetooth/mgmt.c int mgmt_powered(struct hci_dev *hdev, u8 powered) · line 2994

Quoted 8 lines
net/bluetooth/mgmt.c +4 -0
@@ -2987,7 +2987,13 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered)
 		}
 	} else {
 		u8 status = MGMT_STATUS_NOT_POWERED;
+		u8 zero_cod[] = { 0, 0, 0 };
+
 		mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status);
+
+		if (memcmp(hdev->dev_class, zero_cod, sizeof(zero_cod)) != 0)

shouldn't we better use if (memcmp( ...)) here.

net/bluetooth/mgmt.c int mgmt_powered(struct hci_dev *hdev, u8 powered) · line 2997

Quoted 3 lines
net/bluetooth/mgmt.c +2 -0
+			mgmt_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev,
+				   zero_cod, sizeof(zero_cod), NULL);
 	}

Otherwise this is fine with me.

Regards

Marcel

#2 lore raw
In reply to Johan Hedberg

Hi Johan,

Quoted 11 lines · Johan Hedberg

From: Johan Hedberg <[email protected]>

When a HCI device is powered off the Management interface specification dictates that the class of device value is indicated as zero. This patch fixes sending of the appropriate class of device changed event when a HCI device is powered off.

---
 net/bluetooth/mgmt.c |    6 ++++++
 1 file changed, 6 insertions(+)

Patch has been applied to bluetooth-next. Thanks.

Gustavo