summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2015-03-06 14:08:55 -0500
committerMarcel Holtmann <marcel@holtmann.org>2015-03-06 14:15:21 -0500
commit3b0602cd01a571177e169c594e5e52b7b740cf08 (patch)
tree361543ec10b5b105650047898cdf83101c60e0e3 /net/bluetooth/mgmt.c
parent2a1afb5ac8d580d2013c2ccc548b4f2689c5ad7a (diff)
Bluetooth: Rename pending_cmd to mgmt_pending_cmd
This patch renames the pending_cmd struct (used for tracking pending mgmt commands) to mgmt_pending_cmd, so that it can be moved to a more generic place and be used also by other modules using other HCI channels. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c176
1 files changed, 89 insertions, 87 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 835a459531ab..62c23927684f 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -135,7 +135,7 @@ static const u16 mgmt_events[] = {
135#define ZERO_KEY "\x00\x00\x00\x00\x00\x00\x00\x00" \ 135#define ZERO_KEY "\x00\x00\x00\x00\x00\x00\x00\x00" \
136 "\x00\x00\x00\x00\x00\x00\x00\x00" 136 "\x00\x00\x00\x00\x00\x00\x00\x00"
137 137
138struct pending_cmd { 138struct mgmt_pending_cmd {
139 struct list_head list; 139 struct list_head list;
140 u16 opcode; 140 u16 opcode;
141 int index; 141 int index;
@@ -143,7 +143,7 @@ struct pending_cmd {
143 size_t param_len; 143 size_t param_len;
144 struct sock *sk; 144 struct sock *sk;
145 void *user_data; 145 void *user_data;
146 int (*cmd_complete)(struct pending_cmd *cmd, u8 status); 146 int (*cmd_complete)(struct mgmt_pending_cmd *cmd, u8 status);
147}; 147};
148 148
149/* HCI to MGMT error code conversion table */ 149/* HCI to MGMT error code conversion table */
@@ -771,9 +771,10 @@ static u8 *create_uuid128_list(struct hci_dev *hdev, u8 *data, ptrdiff_t len)
771 return ptr; 771 return ptr;
772} 772}
773 773
774static struct pending_cmd *mgmt_pending_find(u16 opcode, struct hci_dev *hdev) 774static struct mgmt_pending_cmd *mgmt_pending_find(u16 opcode,
775 struct hci_dev *hdev)
775{ 776{
776 struct pending_cmd *cmd; 777 struct mgmt_pending_cmd *cmd;
777 778
778 list_for_each_entry(cmd, &hdev->mgmt_pending, list) { 779 list_for_each_entry(cmd, &hdev->mgmt_pending, list) {
779 if (cmd->opcode == opcode) 780 if (cmd->opcode == opcode)
@@ -783,11 +784,11 @@ static struct pending_cmd *mgmt_pending_find(u16 opcode, struct hci_dev *hdev)
783 return NULL; 784 return NULL;
784} 785}
785 786
786static struct pending_cmd *mgmt_pending_find_data(u16 opcode, 787static struct mgmt_pending_cmd *mgmt_pending_find_data(u16 opcode,
787 struct hci_dev *hdev, 788 struct hci_dev *hdev,
788 const void *data) 789 const void *data)
789{ 790{
790 struct pending_cmd *cmd; 791 struct mgmt_pending_cmd *cmd;
791 792
792 list_for_each_entry(cmd, &hdev->mgmt_pending, list) { 793 list_for_each_entry(cmd, &hdev->mgmt_pending, list) {
793 if (cmd->user_data != data) 794 if (cmd->user_data != data)
@@ -852,7 +853,7 @@ static void update_scan_rsp_data(struct hci_request *req)
852 853
853static u8 get_adv_discov_flags(struct hci_dev *hdev) 854static u8 get_adv_discov_flags(struct hci_dev *hdev)
854{ 855{
855 struct pending_cmd *cmd; 856 struct mgmt_pending_cmd *cmd;
856 857
857 /* If there's a pending mgmt command the flags will not yet have 858 /* If there's a pending mgmt command the flags will not yet have
858 * their final values, so check for this first. 859 * their final values, so check for this first.
@@ -1060,7 +1061,7 @@ static void update_class(struct hci_request *req)
1060 1061
1061static bool get_connectable(struct hci_dev *hdev) 1062static bool get_connectable(struct hci_dev *hdev)
1062{ 1063{
1063 struct pending_cmd *cmd; 1064 struct mgmt_pending_cmd *cmd;
1064 1065
1065 /* If there's a pending mgmt command the flag will not yet have 1066 /* If there's a pending mgmt command the flag will not yet have
1066 * it's final value, so check for this first. 1067 * it's final value, so check for this first.
@@ -1210,18 +1211,18 @@ static int read_controller_info(struct sock *sk, struct hci_dev *hdev,
1210 sizeof(rp)); 1211 sizeof(rp));
1211} 1212}
1212 1213
1213static void mgmt_pending_free(struct pending_cmd *cmd) 1214static void mgmt_pending_free(struct mgmt_pending_cmd *cmd)
1214{ 1215{
1215 sock_put(cmd->sk); 1216 sock_put(cmd->sk);
1216 kfree(cmd->param); 1217 kfree(cmd->param);
1217 kfree(cmd); 1218 kfree(cmd);
1218} 1219}
1219 1220
1220static struct pending_cmd *mgmt_pending_add(struct sock *sk, u16 opcode, 1221static struct mgmt_pending_cmd *mgmt_pending_add(struct sock *sk, u16 opcode,
1221 struct hci_dev *hdev, void *data, 1222 struct hci_dev *hdev,
1222 u16 len) 1223 void *data, u16 len)
1223{ 1224{
1224 struct pending_cmd *cmd; 1225 struct mgmt_pending_cmd *cmd;
1225 1226
1226 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); 1227 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
1227 if (!cmd) 1228 if (!cmd)
@@ -1247,11 +1248,11 @@ static struct pending_cmd *mgmt_pending_add(struct sock *sk, u16 opcode,
1247} 1248}
1248 1249
1249static void mgmt_pending_foreach(u16 opcode, struct hci_dev *hdev, 1250static void mgmt_pending_foreach(u16 opcode, struct hci_dev *hdev,
1250 void (*cb)(struct pending_cmd *cmd, 1251 void (*cb)(struct mgmt_pending_cmd *cmd,
1251 void *data), 1252 void *data),
1252 void *data) 1253 void *data)
1253{ 1254{
1254 struct pending_cmd *cmd, *tmp; 1255 struct mgmt_pending_cmd *cmd, *tmp;
1255 1256
1256 list_for_each_entry_safe(cmd, tmp, &hdev->mgmt_pending, list) { 1257 list_for_each_entry_safe(cmd, tmp, &hdev->mgmt_pending, list) {
1257 if (opcode > 0 && cmd->opcode != opcode) 1258 if (opcode > 0 && cmd->opcode != opcode)
@@ -1261,7 +1262,7 @@ static void mgmt_pending_foreach(u16 opcode, struct hci_dev *hdev,
1261 } 1262 }
1262} 1263}
1263 1264
1264static void mgmt_pending_remove(struct pending_cmd *cmd) 1265static void mgmt_pending_remove(struct mgmt_pending_cmd *cmd)
1265{ 1266{
1266 list_del(&cmd->list); 1267 list_del(&cmd->list);
1267 mgmt_pending_free(cmd); 1268 mgmt_pending_free(cmd);
@@ -1390,7 +1391,7 @@ static int set_powered(struct sock *sk, struct hci_dev *hdev, void *data,
1390 u16 len) 1391 u16 len)
1391{ 1392{
1392 struct mgmt_mode *cp = data; 1393 struct mgmt_mode *cp = data;
1393 struct pending_cmd *cmd; 1394 struct mgmt_pending_cmd *cmd;
1394 int err; 1395 int err;
1395 1396
1396 BT_DBG("request for %s", hdev->name); 1397 BT_DBG("request for %s", hdev->name);
@@ -1472,7 +1473,7 @@ struct cmd_lookup {
1472 u8 mgmt_status; 1473 u8 mgmt_status;
1473}; 1474};
1474 1475
1475static void settings_rsp(struct pending_cmd *cmd, void *data) 1476static void settings_rsp(struct mgmt_pending_cmd *cmd, void *data)
1476{ 1477{
1477 struct cmd_lookup *match = data; 1478 struct cmd_lookup *match = data;
1478 1479
@@ -1488,7 +1489,7 @@ static void settings_rsp(struct pending_cmd *cmd, void *data)
1488 mgmt_pending_free(cmd); 1489 mgmt_pending_free(cmd);
1489} 1490}
1490 1491
1491static void cmd_status_rsp(struct pending_cmd *cmd, void *data) 1492static void cmd_status_rsp(struct mgmt_pending_cmd *cmd, void *data)
1492{ 1493{
1493 u8 *status = data; 1494 u8 *status = data;
1494 1495
@@ -1496,7 +1497,7 @@ static void cmd_status_rsp(struct pending_cmd *cmd, void *data)
1496 mgmt_pending_remove(cmd); 1497 mgmt_pending_remove(cmd);
1497} 1498}
1498 1499
1499static void cmd_complete_rsp(struct pending_cmd *cmd, void *data) 1500static void cmd_complete_rsp(struct mgmt_pending_cmd *cmd, void *data)
1500{ 1501{
1501 if (cmd->cmd_complete) { 1502 if (cmd->cmd_complete) {
1502 u8 *status = data; 1503 u8 *status = data;
@@ -1510,13 +1511,13 @@ static void cmd_complete_rsp(struct pending_cmd *cmd, void *data)
1510 cmd_status_rsp(cmd, data); 1511 cmd_status_rsp(cmd, data);
1511} 1512}
1512 1513
1513static int generic_cmd_complete(struct pending_cmd *cmd, u8 status) 1514static int generic_cmd_complete(struct mgmt_pending_cmd *cmd, u8 status)
1514{ 1515{
1515 return mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, status, 1516 return mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, status,
1516 cmd->param, cmd->param_len); 1517 cmd->param, cmd->param_len);
1517} 1518}
1518 1519
1519static int addr_cmd_complete(struct pending_cmd *cmd, u8 status) 1520static int addr_cmd_complete(struct mgmt_pending_cmd *cmd, u8 status)
1520{ 1521{
1521 return mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, status, 1522 return mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, status,
1522 cmd->param, sizeof(struct mgmt_addr_info)); 1523 cmd->param, sizeof(struct mgmt_addr_info));
@@ -1545,7 +1546,7 @@ static u8 mgmt_le_support(struct hci_dev *hdev)
1545static void set_discoverable_complete(struct hci_dev *hdev, u8 status, 1546static void set_discoverable_complete(struct hci_dev *hdev, u8 status,
1546 u16 opcode) 1547 u16 opcode)
1547{ 1548{
1548 struct pending_cmd *cmd; 1549 struct mgmt_pending_cmd *cmd;
1549 struct mgmt_mode *cp; 1550 struct mgmt_mode *cp;
1550 struct hci_request req; 1551 struct hci_request req;
1551 bool changed; 1552 bool changed;
@@ -1606,7 +1607,7 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
1606 u16 len) 1607 u16 len)
1607{ 1608{
1608 struct mgmt_cp_set_discoverable *cp = data; 1609 struct mgmt_cp_set_discoverable *cp = data;
1609 struct pending_cmd *cmd; 1610 struct mgmt_pending_cmd *cmd;
1610 struct hci_request req; 1611 struct hci_request req;
1611 u16 timeout; 1612 u16 timeout;
1612 u8 scan; 1613 u8 scan;
@@ -1805,7 +1806,7 @@ static void write_fast_connectable(struct hci_request *req, bool enable)
1805static void set_connectable_complete(struct hci_dev *hdev, u8 status, 1806static void set_connectable_complete(struct hci_dev *hdev, u8 status,
1806 u16 opcode) 1807 u16 opcode)
1807{ 1808{
1808 struct pending_cmd *cmd; 1809 struct mgmt_pending_cmd *cmd;
1809 struct mgmt_mode *cp; 1810 struct mgmt_mode *cp;
1810 bool conn_changed, discov_changed; 1811 bool conn_changed, discov_changed;
1811 1812
@@ -1885,7 +1886,7 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data,
1885 u16 len) 1886 u16 len)
1886{ 1887{
1887 struct mgmt_mode *cp = data; 1888 struct mgmt_mode *cp = data;
1888 struct pending_cmd *cmd; 1889 struct mgmt_pending_cmd *cmd;
1889 struct hci_request req; 1890 struct hci_request req;
1890 u8 scan; 1891 u8 scan;
1891 int err; 1892 int err;
@@ -2022,7 +2023,7 @@ static int set_link_security(struct sock *sk, struct hci_dev *hdev, void *data,
2022 u16 len) 2023 u16 len)
2023{ 2024{
2024 struct mgmt_mode *cp = data; 2025 struct mgmt_mode *cp = data;
2025 struct pending_cmd *cmd; 2026 struct mgmt_pending_cmd *cmd;
2026 u8 val, status; 2027 u8 val, status;
2027 int err; 2028 int err;
2028 2029
@@ -2091,7 +2092,7 @@ failed:
2091static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) 2092static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
2092{ 2093{
2093 struct mgmt_mode *cp = data; 2094 struct mgmt_mode *cp = data;
2094 struct pending_cmd *cmd; 2095 struct mgmt_pending_cmd *cmd;
2095 u8 status; 2096 u8 status;
2096 int err; 2097 int err;
2097 2098
@@ -2270,7 +2271,7 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
2270{ 2271{
2271 struct mgmt_mode *cp = data; 2272 struct mgmt_mode *cp = data;
2272 struct hci_cp_write_le_host_supported hci_cp; 2273 struct hci_cp_write_le_host_supported hci_cp;
2273 struct pending_cmd *cmd; 2274 struct mgmt_pending_cmd *cmd;
2274 struct hci_request req; 2275 struct hci_request req;
2275 int err; 2276 int err;
2276 u8 val, enabled; 2277 u8 val, enabled;
@@ -2363,7 +2364,7 @@ unlock:
2363 */ 2364 */
2364static bool pending_eir_or_class(struct hci_dev *hdev) 2365static bool pending_eir_or_class(struct hci_dev *hdev)
2365{ 2366{
2366 struct pending_cmd *cmd; 2367 struct mgmt_pending_cmd *cmd;
2367 2368
2368 list_for_each_entry(cmd, &hdev->mgmt_pending, list) { 2369 list_for_each_entry(cmd, &hdev->mgmt_pending, list) {
2369 switch (cmd->opcode) { 2370 switch (cmd->opcode) {
@@ -2399,7 +2400,7 @@ static u8 get_uuid_size(const u8 *uuid)
2399 2400
2400static void mgmt_class_complete(struct hci_dev *hdev, u16 mgmt_op, u8 status) 2401static void mgmt_class_complete(struct hci_dev *hdev, u16 mgmt_op, u8 status)
2401{ 2402{
2402 struct pending_cmd *cmd; 2403 struct mgmt_pending_cmd *cmd;
2403 2404
2404 hci_dev_lock(hdev); 2405 hci_dev_lock(hdev);
2405 2406
@@ -2426,7 +2427,7 @@ static void add_uuid_complete(struct hci_dev *hdev, u8 status, u16 opcode)
2426static int add_uuid(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) 2427static int add_uuid(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
2427{ 2428{
2428 struct mgmt_cp_add_uuid *cp = data; 2429 struct mgmt_cp_add_uuid *cp = data;
2429 struct pending_cmd *cmd; 2430 struct mgmt_pending_cmd *cmd;
2430 struct hci_request req; 2431 struct hci_request req;
2431 struct bt_uuid *uuid; 2432 struct bt_uuid *uuid;
2432 int err; 2433 int err;
@@ -2506,7 +2507,7 @@ static int remove_uuid(struct sock *sk, struct hci_dev *hdev, void *data,
2506 u16 len) 2507 u16 len)
2507{ 2508{
2508 struct mgmt_cp_remove_uuid *cp = data; 2509 struct mgmt_cp_remove_uuid *cp = data;
2509 struct pending_cmd *cmd; 2510 struct mgmt_pending_cmd *cmd;
2510 struct bt_uuid *match, *tmp; 2511 struct bt_uuid *match, *tmp;
2511 u8 bt_uuid_any[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2512 u8 bt_uuid_any[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2512 struct hci_request req; 2513 struct hci_request req;
@@ -2592,7 +2593,7 @@ static int set_dev_class(struct sock *sk, struct hci_dev *hdev, void *data,
2592 u16 len) 2593 u16 len)
2593{ 2594{
2594 struct mgmt_cp_set_dev_class *cp = data; 2595 struct mgmt_cp_set_dev_class *cp = data;
2595 struct pending_cmd *cmd; 2596 struct mgmt_pending_cmd *cmd;
2596 struct hci_request req; 2597 struct hci_request req;
2597 int err; 2598 int err;
2598 2599
@@ -2760,7 +2761,7 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data,
2760 struct mgmt_cp_unpair_device *cp = data; 2761 struct mgmt_cp_unpair_device *cp = data;
2761 struct mgmt_rp_unpair_device rp; 2762 struct mgmt_rp_unpair_device rp;
2762 struct hci_cp_disconnect dc; 2763 struct hci_cp_disconnect dc;
2763 struct pending_cmd *cmd; 2764 struct mgmt_pending_cmd *cmd;
2764 struct hci_conn *conn; 2765 struct hci_conn *conn;
2765 int err; 2766 int err;
2766 2767
@@ -2874,7 +2875,7 @@ static int disconnect(struct sock *sk, struct hci_dev *hdev, void *data,
2874{ 2875{
2875 struct mgmt_cp_disconnect *cp = data; 2876 struct mgmt_cp_disconnect *cp = data;
2876 struct mgmt_rp_disconnect rp; 2877 struct mgmt_rp_disconnect rp;
2877 struct pending_cmd *cmd; 2878 struct mgmt_pending_cmd *cmd;
2878 struct hci_conn *conn; 2879 struct hci_conn *conn;
2879 int err; 2880 int err;
2880 2881
@@ -3014,7 +3015,7 @@ unlock:
3014static int send_pin_code_neg_reply(struct sock *sk, struct hci_dev *hdev, 3015static int send_pin_code_neg_reply(struct sock *sk, struct hci_dev *hdev,
3015 struct mgmt_cp_pin_code_neg_reply *cp) 3016 struct mgmt_cp_pin_code_neg_reply *cp)
3016{ 3017{
3017 struct pending_cmd *cmd; 3018 struct mgmt_pending_cmd *cmd;
3018 int err; 3019 int err;
3019 3020
3020 cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_NEG_REPLY, hdev, cp, 3021 cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_NEG_REPLY, hdev, cp,
@@ -3036,7 +3037,7 @@ static int pin_code_reply(struct sock *sk, struct hci_dev *hdev, void *data,
3036 struct hci_conn *conn; 3037 struct hci_conn *conn;
3037 struct mgmt_cp_pin_code_reply *cp = data; 3038 struct mgmt_cp_pin_code_reply *cp = data;
3038 struct hci_cp_pin_code_reply reply; 3039 struct hci_cp_pin_code_reply reply;
3039 struct pending_cmd *cmd; 3040 struct mgmt_pending_cmd *cmd;
3040 int err; 3041 int err;
3041 3042
3042 BT_DBG(""); 3043 BT_DBG("");
@@ -3116,10 +3117,10 @@ static int set_io_capability(struct sock *sk, struct hci_dev *hdev, void *data,
3116 NULL, 0); 3117 NULL, 0);
3117} 3118}
3118 3119
3119static struct pending_cmd *find_pairing(struct hci_conn *conn) 3120static struct mgmt_pending_cmd *find_pairing(struct hci_conn *conn)
3120{ 3121{
3121 struct hci_dev *hdev = conn->hdev; 3122 struct hci_dev *hdev = conn->hdev;
3122 struct pending_cmd *cmd; 3123 struct mgmt_pending_cmd *cmd;
3123 3124
3124 list_for_each_entry(cmd, &hdev->mgmt_pending, list) { 3125 list_for_each_entry(cmd, &hdev->mgmt_pending, list) {
3125 if (cmd->opcode != MGMT_OP_PAIR_DEVICE) 3126 if (cmd->opcode != MGMT_OP_PAIR_DEVICE)
@@ -3134,7 +3135,7 @@ static struct pending_cmd *find_pairing(struct hci_conn *conn)
3134 return NULL; 3135 return NULL;
3135} 3136}
3136 3137
3137static int pairing_complete(struct pending_cmd *cmd, u8 status) 3138static int pairing_complete(struct mgmt_pending_cmd *cmd, u8 status)
3138{ 3139{
3139 struct mgmt_rp_pair_device rp; 3140 struct mgmt_rp_pair_device rp;
3140 struct hci_conn *conn = cmd->user_data; 3141 struct hci_conn *conn = cmd->user_data;
@@ -3166,7 +3167,7 @@ static int pairing_complete(struct pending_cmd *cmd, u8 status)
3166void mgmt_smp_complete(struct hci_conn *conn, bool complete) 3167void mgmt_smp_complete(struct hci_conn *conn, bool complete)
3167{ 3168{
3168 u8 status = complete ? MGMT_STATUS_SUCCESS : MGMT_STATUS_FAILED; 3169 u8 status = complete ? MGMT_STATUS_SUCCESS : MGMT_STATUS_FAILED;
3169 struct pending_cmd *cmd; 3170 struct mgmt_pending_cmd *cmd;
3170 3171
3171 cmd = find_pairing(conn); 3172 cmd = find_pairing(conn);
3172 if (cmd) { 3173 if (cmd) {
@@ -3177,7 +3178,7 @@ void mgmt_smp_complete(struct hci_conn *conn, bool complete)
3177 3178
3178static void pairing_complete_cb(struct hci_conn *conn, u8 status) 3179static void pairing_complete_cb(struct hci_conn *conn, u8 status)
3179{ 3180{
3180 struct pending_cmd *cmd; 3181 struct mgmt_pending_cmd *cmd;
3181 3182
3182 BT_DBG("status %u", status); 3183 BT_DBG("status %u", status);
3183 3184
@@ -3193,7 +3194,7 @@ static void pairing_complete_cb(struct hci_conn *conn, u8 status)
3193 3194
3194static void le_pairing_complete_cb(struct hci_conn *conn, u8 status) 3195static void le_pairing_complete_cb(struct hci_conn *conn, u8 status)
3195{ 3196{
3196 struct pending_cmd *cmd; 3197 struct mgmt_pending_cmd *cmd;
3197 3198
3198 BT_DBG("status %u", status); 3199 BT_DBG("status %u", status);
3199 3200
@@ -3215,7 +3216,7 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
3215{ 3216{
3216 struct mgmt_cp_pair_device *cp = data; 3217 struct mgmt_cp_pair_device *cp = data;
3217 struct mgmt_rp_pair_device rp; 3218 struct mgmt_rp_pair_device rp;
3218 struct pending_cmd *cmd; 3219 struct mgmt_pending_cmd *cmd;
3219 u8 sec_level, auth_type; 3220 u8 sec_level, auth_type;
3220 struct hci_conn *conn; 3221 struct hci_conn *conn;
3221 int err; 3222 int err;
@@ -3341,7 +3342,7 @@ static int cancel_pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
3341 u16 len) 3342 u16 len)
3342{ 3343{
3343 struct mgmt_addr_info *addr = data; 3344 struct mgmt_addr_info *addr = data;
3344 struct pending_cmd *cmd; 3345 struct mgmt_pending_cmd *cmd;
3345 struct hci_conn *conn; 3346 struct hci_conn *conn;
3346 int err; 3347 int err;
3347 3348
@@ -3384,7 +3385,7 @@ static int user_pairing_resp(struct sock *sk, struct hci_dev *hdev,
3384 struct mgmt_addr_info *addr, u16 mgmt_op, 3385 struct mgmt_addr_info *addr, u16 mgmt_op,
3385 u16 hci_op, __le32 passkey) 3386 u16 hci_op, __le32 passkey)
3386{ 3387{
3387 struct pending_cmd *cmd; 3388 struct mgmt_pending_cmd *cmd;
3388 struct hci_conn *conn; 3389 struct hci_conn *conn;
3389 int err; 3390 int err;
3390 3391
@@ -3527,7 +3528,7 @@ static void update_name(struct hci_request *req)
3527static void set_name_complete(struct hci_dev *hdev, u8 status, u16 opcode) 3528static void set_name_complete(struct hci_dev *hdev, u8 status, u16 opcode)
3528{ 3529{
3529 struct mgmt_cp_set_local_name *cp; 3530 struct mgmt_cp_set_local_name *cp;
3530 struct pending_cmd *cmd; 3531 struct mgmt_pending_cmd *cmd;
3531 3532
3532 BT_DBG("status 0x%02x", status); 3533 BT_DBG("status 0x%02x", status);
3533 3534
@@ -3556,7 +3557,7 @@ static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data,
3556 u16 len) 3557 u16 len)
3557{ 3558{
3558 struct mgmt_cp_set_local_name *cp = data; 3559 struct mgmt_cp_set_local_name *cp = data;
3559 struct pending_cmd *cmd; 3560 struct mgmt_pending_cmd *cmd;
3560 struct hci_request req; 3561 struct hci_request req;
3561 int err; 3562 int err;
3562 3563
@@ -3624,7 +3625,7 @@ failed:
3624static int read_local_oob_data(struct sock *sk, struct hci_dev *hdev, 3625static int read_local_oob_data(struct sock *sk, struct hci_dev *hdev,
3625 void *data, u16 data_len) 3626 void *data, u16 data_len)
3626{ 3627{
3627 struct pending_cmd *cmd; 3628 struct mgmt_pending_cmd *cmd;
3628 int err; 3629 int err;
3629 3630
3630 BT_DBG("%s", hdev->name); 3631 BT_DBG("%s", hdev->name);
@@ -3913,7 +3914,7 @@ static bool trigger_discovery(struct hci_request *req, u8 *status)
3913static void start_discovery_complete(struct hci_dev *hdev, u8 status, 3914static void start_discovery_complete(struct hci_dev *hdev, u8 status,
3914 u16 opcode) 3915 u16 opcode)
3915{ 3916{
3916 struct pending_cmd *cmd; 3917 struct mgmt_pending_cmd *cmd;
3917 unsigned long timeout; 3918 unsigned long timeout;
3918 3919
3919 BT_DBG("status %d", status); 3920 BT_DBG("status %d", status);
@@ -3980,7 +3981,7 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
3980 void *data, u16 len) 3981 void *data, u16 len)
3981{ 3982{
3982 struct mgmt_cp_start_discovery *cp = data; 3983 struct mgmt_cp_start_discovery *cp = data;
3983 struct pending_cmd *cmd; 3984 struct mgmt_pending_cmd *cmd;
3984 struct hci_request req; 3985 struct hci_request req;
3985 u8 status; 3986 u8 status;
3986 int err; 3987 int err;
@@ -4042,7 +4043,8 @@ failed:
4042 return err; 4043 return err;
4043} 4044}
4044 4045
4045static int service_discovery_cmd_complete(struct pending_cmd *cmd, u8 status) 4046static int service_discovery_cmd_complete(struct mgmt_pending_cmd *cmd,
4047 u8 status)
4046{ 4048{
4047 return mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, status, 4049 return mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, status,
4048 cmd->param, 1); 4050 cmd->param, 1);
@@ -4052,7 +4054,7 @@ static int start_service_discovery(struct sock *sk, struct hci_dev *hdev,
4052 void *data, u16 len) 4054 void *data, u16 len)
4053{ 4055{
4054 struct mgmt_cp_start_service_discovery *cp = data; 4056 struct mgmt_cp_start_service_discovery *cp = data;
4055 struct pending_cmd *cmd; 4057 struct mgmt_pending_cmd *cmd;
4056 struct hci_request req; 4058 struct hci_request req;
4057 const u16 max_uuid_count = ((U16_MAX - sizeof(*cp)) / 16); 4059 const u16 max_uuid_count = ((U16_MAX - sizeof(*cp)) / 16);
4058 u16 uuid_count, expected_len; 4060 u16 uuid_count, expected_len;
@@ -4159,7 +4161,7 @@ failed:
4159 4161
4160static void stop_discovery_complete(struct hci_dev *hdev, u8 status, u16 opcode) 4162static void stop_discovery_complete(struct hci_dev *hdev, u8 status, u16 opcode)
4161{ 4163{
4162 struct pending_cmd *cmd; 4164 struct mgmt_pending_cmd *cmd;
4163 4165
4164 BT_DBG("status %d", status); 4166 BT_DBG("status %d", status);
4165 4167
@@ -4181,7 +4183,7 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data,
4181 u16 len) 4183 u16 len)
4182{ 4184{
4183 struct mgmt_cp_stop_discovery *mgmt_cp = data; 4185 struct mgmt_cp_stop_discovery *mgmt_cp = data;
4184 struct pending_cmd *cmd; 4186 struct mgmt_pending_cmd *cmd;
4185 struct hci_request req; 4187 struct hci_request req;
4186 int err; 4188 int err;
4187 4189
@@ -4420,7 +4422,7 @@ static int set_advertising(struct sock *sk, struct hci_dev *hdev, void *data,
4420 u16 len) 4422 u16 len)
4421{ 4423{
4422 struct mgmt_mode *cp = data; 4424 struct mgmt_mode *cp = data;
4423 struct pending_cmd *cmd; 4425 struct mgmt_pending_cmd *cmd;
4424 struct hci_request req; 4426 struct hci_request req;
4425 u8 val, enabled, status; 4427 u8 val, enabled, status;
4426 int err; 4428 int err;
@@ -4600,7 +4602,7 @@ static int set_scan_params(struct sock *sk, struct hci_dev *hdev,
4600static void fast_connectable_complete(struct hci_dev *hdev, u8 status, 4602static void fast_connectable_complete(struct hci_dev *hdev, u8 status,
4601 u16 opcode) 4603 u16 opcode)
4602{ 4604{
4603 struct pending_cmd *cmd; 4605 struct mgmt_pending_cmd *cmd;
4604 4606
4605 BT_DBG("status 0x%02x", status); 4607 BT_DBG("status 0x%02x", status);
4606 4608
@@ -4635,7 +4637,7 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
4635 void *data, u16 len) 4637 void *data, u16 len)
4636{ 4638{
4637 struct mgmt_mode *cp = data; 4639 struct mgmt_mode *cp = data;
4638 struct pending_cmd *cmd; 4640 struct mgmt_pending_cmd *cmd;
4639 struct hci_request req; 4641 struct hci_request req;
4640 int err; 4642 int err;
4641 4643
@@ -4698,7 +4700,7 @@ unlock:
4698 4700
4699static void set_bredr_complete(struct hci_dev *hdev, u8 status, u16 opcode) 4701static void set_bredr_complete(struct hci_dev *hdev, u8 status, u16 opcode)
4700{ 4702{
4701 struct pending_cmd *cmd; 4703 struct mgmt_pending_cmd *cmd;
4702 4704
4703 BT_DBG("status 0x%02x", status); 4705 BT_DBG("status 0x%02x", status);
4704 4706
@@ -4731,7 +4733,7 @@ unlock:
4731static int set_bredr(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) 4733static int set_bredr(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
4732{ 4734{
4733 struct mgmt_mode *cp = data; 4735 struct mgmt_mode *cp = data;
4734 struct pending_cmd *cmd; 4736 struct mgmt_pending_cmd *cmd;
4735 struct hci_request req; 4737 struct hci_request req;
4736 int err; 4738 int err;
4737 4739
@@ -4842,7 +4844,7 @@ unlock:
4842 4844
4843static void sc_enable_complete(struct hci_dev *hdev, u8 status, u16 opcode) 4845static void sc_enable_complete(struct hci_dev *hdev, u8 status, u16 opcode)
4844{ 4846{
4845 struct pending_cmd *cmd; 4847 struct mgmt_pending_cmd *cmd;
4846 struct mgmt_mode *cp; 4848 struct mgmt_mode *cp;
4847 4849
4848 BT_DBG("%s status %u", hdev->name, status); 4850 BT_DBG("%s status %u", hdev->name, status);
@@ -4889,7 +4891,7 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev,
4889 void *data, u16 len) 4891 void *data, u16 len)
4890{ 4892{
4891 struct mgmt_mode *cp = data; 4893 struct mgmt_mode *cp = data;
4892 struct pending_cmd *cmd; 4894 struct mgmt_pending_cmd *cmd;
4893 struct hci_request req; 4895 struct hci_request req;
4894 u8 val; 4896 u8 val;
4895 int err; 4897 int err;
@@ -5265,7 +5267,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
5265 return err; 5267 return err;
5266} 5268}
5267 5269
5268static int conn_info_cmd_complete(struct pending_cmd *cmd, u8 status) 5270static int conn_info_cmd_complete(struct mgmt_pending_cmd *cmd, u8 status)
5269{ 5271{
5270 struct hci_conn *conn = cmd->user_data; 5272 struct hci_conn *conn = cmd->user_data;
5271 struct mgmt_rp_get_conn_info rp; 5273 struct mgmt_rp_get_conn_info rp;
@@ -5296,7 +5298,7 @@ static void conn_info_refresh_complete(struct hci_dev *hdev, u8 hci_status,
5296 u16 opcode) 5298 u16 opcode)
5297{ 5299{
5298 struct hci_cp_read_rssi *cp; 5300 struct hci_cp_read_rssi *cp;
5299 struct pending_cmd *cmd; 5301 struct mgmt_pending_cmd *cmd;
5300 struct hci_conn *conn; 5302 struct hci_conn *conn;
5301 u16 handle; 5303 u16 handle;
5302 u8 status; 5304 u8 status;
@@ -5409,7 +5411,7 @@ static int get_conn_info(struct sock *sk, struct hci_dev *hdev, void *data,
5409 struct hci_request req; 5411 struct hci_request req;
5410 struct hci_cp_read_tx_power req_txp_cp; 5412 struct hci_cp_read_tx_power req_txp_cp;
5411 struct hci_cp_read_rssi req_rssi_cp; 5413 struct hci_cp_read_rssi req_rssi_cp;
5412 struct pending_cmd *cmd; 5414 struct mgmt_pending_cmd *cmd;
5413 5415
5414 hci_req_init(&req, hdev); 5416 hci_req_init(&req, hdev);
5415 req_rssi_cp.handle = cpu_to_le16(conn->handle); 5417 req_rssi_cp.handle = cpu_to_le16(conn->handle);
@@ -5466,7 +5468,7 @@ unlock:
5466 return err; 5468 return err;
5467} 5469}
5468 5470
5469static int clock_info_cmd_complete(struct pending_cmd *cmd, u8 status) 5471static int clock_info_cmd_complete(struct mgmt_pending_cmd *cmd, u8 status)
5470{ 5472{
5471 struct hci_conn *conn = cmd->user_data; 5473 struct hci_conn *conn = cmd->user_data;
5472 struct mgmt_rp_get_clock_info rp; 5474 struct mgmt_rp_get_clock_info rp;
@@ -5505,7 +5507,7 @@ complete:
5505static void get_clock_info_complete(struct hci_dev *hdev, u8 status, u16 opcode) 5507static void get_clock_info_complete(struct hci_dev *hdev, u8 status, u16 opcode)
5506{ 5508{
5507 struct hci_cp_read_clock *hci_cp; 5509 struct hci_cp_read_clock *hci_cp;
5508 struct pending_cmd *cmd; 5510 struct mgmt_pending_cmd *cmd;
5509 struct hci_conn *conn; 5511 struct hci_conn *conn;
5510 5512
5511 BT_DBG("%s status %u", hdev->name, status); 5513 BT_DBG("%s status %u", hdev->name, status);
@@ -5540,7 +5542,7 @@ static int get_clock_info(struct sock *sk, struct hci_dev *hdev, void *data,
5540 struct mgmt_cp_get_clock_info *cp = data; 5542 struct mgmt_cp_get_clock_info *cp = data;
5541 struct mgmt_rp_get_clock_info rp; 5543 struct mgmt_rp_get_clock_info rp;
5542 struct hci_cp_read_clock hci_cp; 5544 struct hci_cp_read_clock hci_cp;
5543 struct pending_cmd *cmd; 5545 struct mgmt_pending_cmd *cmd;
5544 struct hci_request req; 5546 struct hci_request req;
5545 struct hci_conn *conn; 5547 struct hci_conn *conn;
5546 int err; 5548 int err;
@@ -5683,7 +5685,7 @@ static void device_added(struct sock *sk, struct hci_dev *hdev,
5683 5685
5684static void add_device_complete(struct hci_dev *hdev, u8 status, u16 opcode) 5686static void add_device_complete(struct hci_dev *hdev, u8 status, u16 opcode)
5685{ 5687{
5686 struct pending_cmd *cmd; 5688 struct mgmt_pending_cmd *cmd;
5687 5689
5688 BT_DBG("status 0x%02x", status); 5690 BT_DBG("status 0x%02x", status);
5689 5691
@@ -5704,7 +5706,7 @@ static int add_device(struct sock *sk, struct hci_dev *hdev,
5704 void *data, u16 len) 5706 void *data, u16 len)
5705{ 5707{
5706 struct mgmt_cp_add_device *cp = data; 5708 struct mgmt_cp_add_device *cp = data;
5707 struct pending_cmd *cmd; 5709 struct mgmt_pending_cmd *cmd;
5708 struct hci_request req; 5710 struct hci_request req;
5709 u8 auto_conn, addr_type; 5711 u8 auto_conn, addr_type;
5710 int err; 5712 int err;
@@ -5806,7 +5808,7 @@ static void device_removed(struct sock *sk, struct hci_dev *hdev,
5806 5808
5807static void remove_device_complete(struct hci_dev *hdev, u8 status, u16 opcode) 5809static void remove_device_complete(struct hci_dev *hdev, u8 status, u16 opcode)
5808{ 5810{
5809 struct pending_cmd *cmd; 5811 struct mgmt_pending_cmd *cmd;
5810 5812
5811 BT_DBG("status 0x%02x", status); 5813 BT_DBG("status 0x%02x", status);
5812 5814
@@ -5827,7 +5829,7 @@ static int remove_device(struct sock *sk, struct hci_dev *hdev,
5827 void *data, u16 len) 5829 void *data, u16 len)
5828{ 5830{
5829 struct mgmt_cp_remove_device *cp = data; 5831 struct mgmt_cp_remove_device *cp = data;
5830 struct pending_cmd *cmd; 5832 struct mgmt_pending_cmd *cmd;
5831 struct hci_request req; 5833 struct hci_request req;
5832 int err; 5834 int err;
5833 5835
@@ -6530,7 +6532,7 @@ new_settings:
6530 6532
6531void mgmt_set_powered_failed(struct hci_dev *hdev, int err) 6533void mgmt_set_powered_failed(struct hci_dev *hdev, int err)
6532{ 6534{
6533 struct pending_cmd *cmd; 6535 struct mgmt_pending_cmd *cmd;
6534 u8 status; 6536 u8 status;
6535 6537
6536 cmd = mgmt_pending_find(MGMT_OP_SET_POWERED, hdev); 6538 cmd = mgmt_pending_find(MGMT_OP_SET_POWERED, hdev);
@@ -6781,7 +6783,7 @@ void mgmt_device_connected(struct hci_dev *hdev, struct hci_conn *conn,
6781 sizeof(*ev) + eir_len, NULL); 6783 sizeof(*ev) + eir_len, NULL);
6782} 6784}
6783 6785
6784static void disconnect_rsp(struct pending_cmd *cmd, void *data) 6786static void disconnect_rsp(struct mgmt_pending_cmd *cmd, void *data)
6785{ 6787{
6786 struct sock **sk = data; 6788 struct sock **sk = data;
6787 6789
@@ -6793,7 +6795,7 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data)
6793 mgmt_pending_remove(cmd); 6795 mgmt_pending_remove(cmd);
6794} 6796}
6795 6797
6796static void unpair_device_rsp(struct pending_cmd *cmd, void *data) 6798static void unpair_device_rsp(struct mgmt_pending_cmd *cmd, void *data)
6797{ 6799{
6798 struct hci_dev *hdev = data; 6800 struct hci_dev *hdev = data;
6799 struct mgmt_cp_unpair_device *cp = cmd->param; 6801 struct mgmt_cp_unpair_device *cp = cmd->param;
@@ -6806,7 +6808,7 @@ static void unpair_device_rsp(struct pending_cmd *cmd, void *data)
6806 6808
6807bool mgmt_powering_down(struct hci_dev *hdev) 6809bool mgmt_powering_down(struct hci_dev *hdev)
6808{ 6810{
6809 struct pending_cmd *cmd; 6811 struct mgmt_pending_cmd *cmd;
6810 struct mgmt_mode *cp; 6812 struct mgmt_mode *cp;
6811 6813
6812 cmd = mgmt_pending_find(MGMT_OP_SET_POWERED, hdev); 6814 cmd = mgmt_pending_find(MGMT_OP_SET_POWERED, hdev);
@@ -6861,7 +6863,7 @@ void mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr,
6861{ 6863{
6862 u8 bdaddr_type = link_to_bdaddr(link_type, addr_type); 6864 u8 bdaddr_type = link_to_bdaddr(link_type, addr_type);
6863 struct mgmt_cp_disconnect *cp; 6865 struct mgmt_cp_disconnect *cp;
6864 struct pending_cmd *cmd; 6866 struct mgmt_pending_cmd *cmd;
6865 6867
6866 mgmt_pending_foreach(MGMT_OP_UNPAIR_DEVICE, hdev, unpair_device_rsp, 6868 mgmt_pending_foreach(MGMT_OP_UNPAIR_DEVICE, hdev, unpair_device_rsp,
6867 hdev); 6869 hdev);
@@ -6916,7 +6918,7 @@ void mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure)
6916void mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, 6918void mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
6917 u8 status) 6919 u8 status)
6918{ 6920{
6919 struct pending_cmd *cmd; 6921 struct mgmt_pending_cmd *cmd;
6920 6922
6921 cmd = mgmt_pending_find(MGMT_OP_PIN_CODE_REPLY, hdev); 6923 cmd = mgmt_pending_find(MGMT_OP_PIN_CODE_REPLY, hdev);
6922 if (!cmd) 6924 if (!cmd)
@@ -6929,7 +6931,7 @@ void mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
6929void mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, 6931void mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
6930 u8 status) 6932 u8 status)
6931{ 6933{
6932 struct pending_cmd *cmd; 6934 struct mgmt_pending_cmd *cmd;
6933 6935
6934 cmd = mgmt_pending_find(MGMT_OP_PIN_CODE_NEG_REPLY, hdev); 6936 cmd = mgmt_pending_find(MGMT_OP_PIN_CODE_NEG_REPLY, hdev);
6935 if (!cmd) 6937 if (!cmd)
@@ -6974,7 +6976,7 @@ static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
6974 u8 link_type, u8 addr_type, u8 status, 6976 u8 link_type, u8 addr_type, u8 status,
6975 u8 opcode) 6977 u8 opcode)
6976{ 6978{
6977 struct pending_cmd *cmd; 6979 struct mgmt_pending_cmd *cmd;
6978 6980
6979 cmd = mgmt_pending_find(opcode, hdev); 6981 cmd = mgmt_pending_find(opcode, hdev);
6980 if (!cmd) 6982 if (!cmd)
@@ -7035,7 +7037,7 @@ int mgmt_user_passkey_notify(struct hci_dev *hdev, bdaddr_t *bdaddr,
7035void mgmt_auth_failed(struct hci_conn *conn, u8 hci_status) 7037void mgmt_auth_failed(struct hci_conn *conn, u8 hci_status)
7036{ 7038{
7037 struct mgmt_ev_auth_failed ev; 7039 struct mgmt_ev_auth_failed ev;
7038 struct pending_cmd *cmd; 7040 struct mgmt_pending_cmd *cmd;
7039 u8 status = mgmt_status(hci_status); 7041 u8 status = mgmt_status(hci_status);
7040 7042
7041 bacpy(&ev.addr.bdaddr, &conn->dst); 7043 bacpy(&ev.addr.bdaddr, &conn->dst);
@@ -7150,7 +7152,7 @@ void mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status)
7150 hci_req_run(&req, NULL); 7152 hci_req_run(&req, NULL);
7151} 7153}
7152 7154
7153static void sk_lookup(struct pending_cmd *cmd, void *data) 7155static void sk_lookup(struct mgmt_pending_cmd *cmd, void *data)
7154{ 7156{
7155 struct cmd_lookup *match = data; 7157 struct cmd_lookup *match = data;
7156 7158
@@ -7180,7 +7182,7 @@ void mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class,
7180void mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status) 7182void mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status)
7181{ 7183{
7182 struct mgmt_cp_set_local_name ev; 7184 struct mgmt_cp_set_local_name ev;
7183 struct pending_cmd *cmd; 7185 struct mgmt_pending_cmd *cmd;
7184 7186
7185 if (status) 7187 if (status)
7186 return; 7188 return;
@@ -7208,7 +7210,7 @@ void mgmt_read_local_oob_data_complete(struct hci_dev *hdev, u8 *hash192,
7208 u8 *rand192, u8 *hash256, u8 *rand256, 7210 u8 *rand192, u8 *hash256, u8 *rand256,
7209 u8 status) 7211 u8 status)
7210{ 7212{
7211 struct pending_cmd *cmd; 7213 struct mgmt_pending_cmd *cmd;
7212 7214
7213 BT_DBG("%s status %u", hdev->name, status); 7215 BT_DBG("%s status %u", hdev->name, status);
7214 7216