diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2013-03-15 18:07:08 -0400 |
---|---|---|
committer | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2013-03-18 13:02:08 -0400 |
commit | 1a4d3c4b3750885733641216756de4e4d9b2443a (patch) | |
tree | 7238a7a9a1b898e40f15f66cc71386d15ab8fb74 | |
parent | 05cbf29f84f2cf17554b58a3ab4a0ac46d52eca6 (diff) |
Bluetooth: Add proper flag for fast connectable mode
In order to be able to represent fast connectable mode in the mgmt
settings we need to have a HCI dev flag for it. This patch adds the flag
and makes sure its value is changed whenever a mgmt_set_fast_connectable
command completes.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
-rw-r--r-- | include/net/bluetooth/hci.h | 4 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 16 |
2 files changed, 19 insertions, 1 deletions
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 1e40222e9dd0..b854506c859c 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h | |||
@@ -120,12 +120,14 @@ enum { | |||
120 | HCI_DISCOVERABLE, | 120 | HCI_DISCOVERABLE, |
121 | HCI_LINK_SECURITY, | 121 | HCI_LINK_SECURITY, |
122 | HCI_PERIODIC_INQ, | 122 | HCI_PERIODIC_INQ, |
123 | HCI_FAST_CONNECTABLE, | ||
123 | }; | 124 | }; |
124 | 125 | ||
125 | /* A mask for the flags that are supposed to remain when a reset happens | 126 | /* A mask for the flags that are supposed to remain when a reset happens |
126 | * or the HCI device is closed. | 127 | * or the HCI device is closed. |
127 | */ | 128 | */ |
128 | #define HCI_PERSISTENT_MASK (BIT(HCI_LE_SCAN) | BIT(HCI_PERIODIC_INQ)) | 129 | #define HCI_PERSISTENT_MASK (BIT(HCI_LE_SCAN) | BIT(HCI_PERIODIC_INQ) | \ |
130 | BIT(HCI_FAST_CONNECTABLE)) | ||
129 | 131 | ||
130 | /* HCI ioctl defines */ | 132 | /* HCI ioctl defines */ |
131 | #define HCIDEVUP _IOW('H', 201, int) | 133 | #define HCIDEVUP _IOW('H', 201, int) |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index e89938e0233c..b6a33c5e7685 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -410,6 +410,9 @@ static u32 get_current_settings(struct hci_dev *hdev) | |||
410 | if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) | 410 | if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) |
411 | settings |= MGMT_SETTING_CONNECTABLE; | 411 | settings |= MGMT_SETTING_CONNECTABLE; |
412 | 412 | ||
413 | if (test_bit(HCI_FAST_CONNECTABLE, &hdev->dev_flags)) | ||
414 | settings |= MGMT_SETTING_FAST_CONNECTABLE; | ||
415 | |||
413 | if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) | 416 | if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) |
414 | settings |= MGMT_SETTING_DISCOVERABLE; | 417 | settings |= MGMT_SETTING_DISCOVERABLE; |
415 | 418 | ||
@@ -2913,6 +2916,13 @@ static void fast_connectable_complete(struct hci_dev *hdev, u8 status) | |||
2913 | cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, | 2916 | cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, |
2914 | mgmt_status(status)); | 2917 | mgmt_status(status)); |
2915 | } else { | 2918 | } else { |
2919 | struct mgmt_mode *cp = cmd->param; | ||
2920 | |||
2921 | if (cp->val) | ||
2922 | set_bit(HCI_FAST_CONNECTABLE, &hdev->dev_flags); | ||
2923 | else | ||
2924 | clear_bit(HCI_FAST_CONNECTABLE, &hdev->dev_flags); | ||
2925 | |||
2916 | send_settings_rsp(cmd->sk, MGMT_OP_SET_FAST_CONNECTABLE, hdev); | 2926 | send_settings_rsp(cmd->sk, MGMT_OP_SET_FAST_CONNECTABLE, hdev); |
2917 | new_settings(hdev, cmd->sk); | 2927 | new_settings(hdev, cmd->sk); |
2918 | } | 2928 | } |
@@ -2959,6 +2969,12 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev, | |||
2959 | goto unlock; | 2969 | goto unlock; |
2960 | } | 2970 | } |
2961 | 2971 | ||
2972 | if (!!cp->val == test_bit(HCI_FAST_CONNECTABLE, &hdev->dev_flags)) { | ||
2973 | err = send_settings_rsp(sk, MGMT_OP_SET_FAST_CONNECTABLE, | ||
2974 | hdev); | ||
2975 | goto unlock; | ||
2976 | } | ||
2977 | |||
2962 | if (cp->val) { | 2978 | if (cp->val) { |
2963 | type = PAGE_SCAN_TYPE_INTERLACED; | 2979 | type = PAGE_SCAN_TYPE_INTERLACED; |
2964 | 2980 | ||