diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2015-01-14 18:43:11 -0500 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2015-01-15 05:54:31 -0500 |
commit | 162a3bac8d007aae3d1ba9da9b0d0b9ecfef87cc (patch) | |
tree | 133dd1138167c94e30661c6c9e757b80b5855943 /net/bluetooth | |
parent | 7e7ec44564cacd4a19cca9523a7be1916b108aa6 (diff) |
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.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hci_core.c | 6 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 9 |
2 files changed, 12 insertions, 3 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index c04197347c90..34c17a0645ce 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -933,10 +933,8 @@ static int __hci_init(struct hci_dev *hdev) | |||
933 | if (lmp_bredr_capable(hdev)) | 933 | if (lmp_bredr_capable(hdev)) |
934 | hci_debugfs_create_bredr(hdev); | 934 | hci_debugfs_create_bredr(hdev); |
935 | 935 | ||
936 | if (lmp_le_capable(hdev)) { | 936 | if (lmp_le_capable(hdev)) |
937 | hci_debugfs_create_le(hdev); | 937 | hci_debugfs_create_le(hdev); |
938 | smp_register(hdev); | ||
939 | } | ||
940 | 938 | ||
941 | return 0; | 939 | return 0; |
942 | } | 940 | } |
@@ -2133,6 +2131,8 @@ static void hci_power_off(struct work_struct *work) | |||
2133 | BT_DBG("%s", hdev->name); | 2131 | BT_DBG("%s", hdev->name); |
2134 | 2132 | ||
2135 | hci_dev_do_close(hdev); | 2133 | hci_dev_do_close(hdev); |
2134 | |||
2135 | smp_unregister(hdev); | ||
2136 | } | 2136 | } |
2137 | 2137 | ||
2138 | static void hci_discov_off(struct work_struct *work) | 2138 | static void hci_discov_off(struct work_struct *work) |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index cae612658ba9..f5c4d2eed9a1 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -6232,6 +6232,15 @@ static void powered_complete(struct hci_dev *hdev, u8 status, u16 opcode) | |||
6232 | 6232 | ||
6233 | BT_DBG("status 0x%02x", status); | 6233 | BT_DBG("status 0x%02x", status); |
6234 | 6234 | ||
6235 | if (!status) { | ||
6236 | /* Register the available SMP channels (BR/EDR and LE) only | ||
6237 | * when successfully powering on the controller. This late | ||
6238 | * registration is required so that LE SMP can clearly | ||
6239 | * decide if the public address or static address is used. | ||
6240 | */ | ||
6241 | smp_register(hdev); | ||
6242 | } | ||
6243 | |||
6235 | hci_dev_lock(hdev); | 6244 | hci_dev_lock(hdev); |
6236 | 6245 | ||
6237 | mgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, settings_rsp, &match); | 6246 | mgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, settings_rsp, &match); |