aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2013-03-15 18:07:09 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2013-03-18 13:02:08 -0400
commit406d78045d6c3f5912aefe69b9b02e96479d51c8 (patch)
tree199253a8e0ab3b41d36c997d270c81a899ab6517
parent1a4d3c4b3750885733641216756de4e4d9b2443a (diff)
Bluetooth: Refactor fast connectable HCI commands
This patch refactors the fast connectable HCI commands into their own HCI function. This is necessary so that the same function can be reused fo the fast connectable change required by disabling the connectable setting. 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--net/bluetooth/mgmt.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index b6a33c5e7685..f03b10cf92e3 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1000,6 +1000,29 @@ failed:
1000 return err; 1000 return err;
1001} 1001}
1002 1002
1003static void write_fast_connectable(struct hci_request *req, bool enable)
1004{
1005 struct hci_cp_write_page_scan_activity acp;
1006 u8 type;
1007
1008 if (enable) {
1009 type = PAGE_SCAN_TYPE_INTERLACED;
1010
1011 /* 160 msec page scan interval */
1012 acp.interval = __constant_cpu_to_le16(0x0100);
1013 } else {
1014 type = PAGE_SCAN_TYPE_STANDARD; /* default */
1015
1016 /* default 1.28 sec page scan */
1017 acp.interval = __constant_cpu_to_le16(0x0800);
1018 }
1019
1020 acp.window = __constant_cpu_to_le16(0x0012);
1021
1022 hci_req_add(req, HCI_OP_WRITE_PAGE_SCAN_ACTIVITY, sizeof(acp), &acp);
1023 hci_req_add(req, HCI_OP_WRITE_PAGE_SCAN_TYPE, 1, &type);
1024}
1025
1003static void set_connectable_complete(struct hci_dev *hdev, u8 status) 1026static void set_connectable_complete(struct hci_dev *hdev, u8 status)
1004{ 1027{
1005 struct pending_cmd *cmd; 1028 struct pending_cmd *cmd;
@@ -2937,10 +2960,8 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
2937 void *data, u16 len) 2960 void *data, u16 len)
2938{ 2961{
2939 struct mgmt_mode *cp = data; 2962 struct mgmt_mode *cp = data;
2940 struct hci_cp_write_page_scan_activity acp;
2941 struct pending_cmd *cmd; 2963 struct pending_cmd *cmd;
2942 struct hci_request req; 2964 struct hci_request req;
2943 u8 type;
2944 int err; 2965 int err;
2945 2966
2946 BT_DBG("%s", hdev->name); 2967 BT_DBG("%s", hdev->name);
@@ -2975,21 +2996,6 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
2975 goto unlock; 2996 goto unlock;
2976 } 2997 }
2977 2998
2978 if (cp->val) {
2979 type = PAGE_SCAN_TYPE_INTERLACED;
2980
2981 /* 160 msec page scan interval */
2982 acp.interval = __constant_cpu_to_le16(0x0100);
2983 } else {
2984 type = PAGE_SCAN_TYPE_STANDARD; /* default */
2985
2986 /* default 1.28 sec page scan */
2987 acp.interval = __constant_cpu_to_le16(0x0800);
2988 }
2989
2990 /* default 11.25 msec page scan window */
2991 acp.window = __constant_cpu_to_le16(0x0012);
2992
2993 cmd = mgmt_pending_add(sk, MGMT_OP_SET_FAST_CONNECTABLE, hdev, 2999 cmd = mgmt_pending_add(sk, MGMT_OP_SET_FAST_CONNECTABLE, hdev,
2994 data, len); 3000 data, len);
2995 if (!cmd) { 3001 if (!cmd) {
@@ -2999,8 +3005,7 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
2999 3005
3000 hci_req_init(&req, hdev); 3006 hci_req_init(&req, hdev);
3001 3007
3002 hci_req_add(&req, HCI_OP_WRITE_PAGE_SCAN_ACTIVITY, sizeof(acp), &acp); 3008 write_fast_connectable(&req, cp->val);
3003 hci_req_add(&req, HCI_OP_WRITE_PAGE_SCAN_TYPE, 1, &type);
3004 3009
3005 err = hci_req_run(&req, fast_connectable_complete); 3010 err = hci_req_run(&req, fast_connectable_complete);
3006 if (err < 0) { 3011 if (err < 0) {