Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 369003
b: refs/heads/master
c: 3119ae9
h: refs/heads/master
i:
  369001: 746906f
  368999: f594f70
v: v3
  • Loading branch information
Johan Hedberg authored and Gustavo Padovan committed Mar 8, 2013
1 parent 28f1534 commit 086bd10
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2177bab507d2715ae3b745f47056eacd38b79fa7
refs/heads/master: 3119ae9599e5cdc1b9838563905c500b582ab6a5
10 changes: 10 additions & 0 deletions trunk/include/net/bluetooth/bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,22 @@ struct l2cap_ctrl {
__u8 retries;
};

struct hci_dev;

typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status);

struct hci_req_ctrl {
bool start;
hci_req_complete_t complete;
};

struct bt_skb_cb {
__u8 pkt_type;
__u8 incoming;
__u16 expect;
__u8 force_active;
struct l2cap_ctrl control;
struct hci_req_ctrl req;
};
#define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb))

Expand Down
8 changes: 8 additions & 0 deletions trunk/include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,14 @@ static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type, u8 *data,
int hci_register_cb(struct hci_cb *hcb);
int hci_unregister_cb(struct hci_cb *hcb);

struct hci_request {
struct hci_dev *hdev;
struct sk_buff_head cmd_q;
};

void hci_req_init(struct hci_request *req, struct hci_dev *hdev);
int hci_req_run(struct hci_request *req, hci_req_complete_t complete);

int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param);
void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags);
void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb);
Expand Down
30 changes: 30 additions & 0 deletions trunk/net/bluetooth/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2439,6 +2439,36 @@ static int hci_send_frame(struct sk_buff *skb)
return hdev->send(skb);
}

void hci_req_init(struct hci_request *req, struct hci_dev *hdev)
{
skb_queue_head_init(&req->cmd_q);
req->hdev = hdev;
}

int hci_req_run(struct hci_request *req, hci_req_complete_t complete)
{
struct hci_dev *hdev = req->hdev;
struct sk_buff *skb;
unsigned long flags;

BT_DBG("length %u", skb_queue_len(&req->cmd_q));

/* Do not allow empty requests */
if (skb_queue_empty(&req->cmd_q))
return -EINVAL;

skb = skb_peek_tail(&req->cmd_q);
bt_cb(skb)->req.complete = complete;

spin_lock_irqsave(&hdev->cmd_q.lock, flags);
skb_queue_splice_tail(&req->cmd_q, &hdev->cmd_q);
spin_unlock_irqrestore(&hdev->cmd_q.lock, flags);

queue_work(hdev->workqueue, &hdev->cmd_work);

return 0;
}

/* Send HCI command */
int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param)
{
Expand Down

0 comments on commit 086bd10

Please sign in to comment.