diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2014-07-10 23:51:58 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2014-07-11 06:56:35 -0400 |
commit | 899de765667b63bb51526f0a31693aed6ad5f828 (patch) | |
tree | 84c23cd4e0d6fe263225f174d4c0155faee5d5a3 | |
parent | 863def58fec2fa494c8e9ca45471819c6d731ec3 (diff) |
Bluetooth: Move HCI request internals to net/bluetooth/hci_core.c
The internals of the HCI request framework should not be leaking to
its users. Move them all into net/bluetooth/hci_core.c and provide
a simple hci_req_pending helper function for the one user outside
the framework.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r-- | include/net/bluetooth/hci_core.h | 9 | ||||
-rw-r--r-- | net/bluetooth/hci_core.c | 14 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 2 |
3 files changed, 16 insertions, 9 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index fffd0da2e0fc..b52c2ef3f56d 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -1240,6 +1240,7 @@ void hci_req_add(struct hci_request *req, u16 opcode, u32 plen, | |||
1240 | void hci_req_add_ev(struct hci_request *req, u16 opcode, u32 plen, | 1240 | void hci_req_add_ev(struct hci_request *req, u16 opcode, u32 plen, |
1241 | const void *param, u8 event); | 1241 | const void *param, u8 event); |
1242 | void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status); | 1242 | void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status); |
1243 | bool hci_req_pending(struct hci_dev *hdev); | ||
1243 | 1244 | ||
1244 | void hci_req_add_le_scan_disable(struct hci_request *req); | 1245 | void hci_req_add_le_scan_disable(struct hci_request *req); |
1245 | void hci_req_add_le_passive_scan(struct hci_request *req); | 1246 | void hci_req_add_le_passive_scan(struct hci_request *req); |
@@ -1349,14 +1350,6 @@ void mgmt_new_conn_param(struct hci_dev *hdev, bdaddr_t *bdaddr, | |||
1349 | void mgmt_reenable_advertising(struct hci_dev *hdev); | 1350 | void mgmt_reenable_advertising(struct hci_dev *hdev); |
1350 | void mgmt_smp_complete(struct hci_conn *conn, bool complete); | 1351 | void mgmt_smp_complete(struct hci_conn *conn, bool complete); |
1351 | 1352 | ||
1352 | /* ----- HCI requests ----- */ | ||
1353 | #define HCI_REQ_DONE 0 | ||
1354 | #define HCI_REQ_PEND 1 | ||
1355 | #define HCI_REQ_CANCELED 2 | ||
1356 | |||
1357 | #define hci_req_lock(d) mutex_lock(&d->req_lock) | ||
1358 | #define hci_req_unlock(d) mutex_unlock(&d->req_lock) | ||
1359 | |||
1360 | u8 hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency, | 1353 | u8 hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency, |
1361 | u16 to_multiplier); | 1354 | u16 to_multiplier); |
1362 | void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __le64 rand, | 1355 | void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __le64 rand, |
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 52e8c91ea3e9..347f84fb66f9 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -54,6 +54,15 @@ DEFINE_RWLOCK(hci_cb_list_lock); | |||
54 | /* HCI ID Numbering */ | 54 | /* HCI ID Numbering */ |
55 | static DEFINE_IDA(hci_index_ida); | 55 | static DEFINE_IDA(hci_index_ida); |
56 | 56 | ||
57 | /* ----- HCI requests ----- */ | ||
58 | |||
59 | #define HCI_REQ_DONE 0 | ||
60 | #define HCI_REQ_PEND 1 | ||
61 | #define HCI_REQ_CANCELED 2 | ||
62 | |||
63 | #define hci_req_lock(d) mutex_lock(&d->req_lock) | ||
64 | #define hci_req_unlock(d) mutex_unlock(&d->req_lock) | ||
65 | |||
57 | /* ---- HCI notifications ---- */ | 66 | /* ---- HCI notifications ---- */ |
58 | 67 | ||
59 | static void hci_notify(struct hci_dev *hdev, int event) | 68 | static void hci_notify(struct hci_dev *hdev, int event) |
@@ -4432,6 +4441,11 @@ int hci_req_run(struct hci_request *req, hci_req_complete_t complete) | |||
4432 | return 0; | 4441 | return 0; |
4433 | } | 4442 | } |
4434 | 4443 | ||
4444 | bool hci_req_pending(struct hci_dev *hdev) | ||
4445 | { | ||
4446 | return (hdev->req_status == HCI_REQ_PEND); | ||
4447 | } | ||
4448 | |||
4435 | static struct sk_buff *hci_prepare_cmd(struct hci_dev *hdev, u16 opcode, | 4449 | static struct sk_buff *hci_prepare_cmd(struct hci_dev *hdev, u16 opcode, |
4436 | u32 plen, const void *param) | 4450 | u32 plen, const void *param) |
4437 | { | 4451 | { |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index a62e918d2641..f0f220057f21 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -4624,7 +4624,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) | |||
4624 | /* Received events are (currently) only needed when a request is | 4624 | /* Received events are (currently) only needed when a request is |
4625 | * ongoing so avoid unnecessary memory allocation. | 4625 | * ongoing so avoid unnecessary memory allocation. |
4626 | */ | 4626 | */ |
4627 | if (hdev->req_status == HCI_REQ_PEND) { | 4627 | if (hci_req_pending(hdev)) { |
4628 | kfree_skb(hdev->recv_evt); | 4628 | kfree_skb(hdev->recv_evt); |
4629 | hdev->recv_evt = skb_clone(skb, GFP_KERNEL); | 4629 | hdev->recv_evt = skb_clone(skb, GFP_KERNEL); |
4630 | } | 4630 | } |