Skip to contentSkip to conversation

Bluetooth: Bind the SMP channel registration to management power state

PATCH Superseded Marcel Holtmann 1 participant 1 message Jan 14, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

PATCH 3/3 Bluetooth: Bind the SMP channel registration to management power state

When the controller gets powered on via the management interface, then register the supported SMP channels. There is no point in registering these channels earlier since it is not know what identity address the controller is going to operate with.

When powering down a controller unregister all SMP channels. This is required since a powered down controller is allowed to change its identity address.

In addition the SMP channels are only available when the controller is powered via the management interface. When using legacy ioctl, then Bluetooth Low Energy is not supported and registering kernel side SMP integration may actually cause confusion.

---
 net/bluetooth/hci_core.c | 6 +++---
 net/bluetooth/mgmt.c     | 9 +++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)
net/bluetooth/hci_core.c +3 -3
index c04197347c90..34c17a0645ce 100644
@@ -933,10 +933,8 @@ static int __hci_init(struct hci_dev *hdev)
 	if (lmp_bredr_capable(hdev))
 		hci_debugfs_create_bredr(hdev);
 
-	if (lmp_le_capable(hdev)) {
+	if (lmp_le_capable(hdev))
 		hci_debugfs_create_le(hdev);
-		smp_register(hdev);
-	}
 
 	return 0;
 }
@@ -2133,6 +2131,8 @@ static void hci_power_off(struct work_struct *work)
 	BT_DBG("%s", hdev->name);
 
 	hci_dev_do_close(hdev);
+
+	smp_unregister(hdev);
 }
 
 static void hci_discov_off(struct work_struct *work)
net/bluetooth/mgmt.c +9 -0
index cae612658ba9..f5c4d2eed9a1 100644
@@ -6232,6 +6232,15 @@ static void powered_complete(struct hci_dev *hdev, u8 status, u16 opcode)
 
 	BT_DBG("status 0x%02x", status);
 
+	if (!status) {
+		/* Register the available SMP channels (BR/EDR and LE) only
+		 * when successfully powering on the controller. This late
+		 * registration is required so that LE SMP can clearly
+		 * decide if the public address or static address is used.
+		 */
+		smp_register(hdev);
+	}
+
 	hci_dev_lock(hdev);
 
 	mgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, settings_rsp, &match);
Signature · 1 line
2.1.0