Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 290930
b: refs/heads/master
c: 28b75a8
h: refs/heads/master
v: v3
  • Loading branch information
Andre Guedes authored and Johan Hedberg committed Feb 13, 2012
1 parent f22d61a commit b2f9cb2
Show file tree
Hide file tree
Showing 3 changed files with 42 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: 7ba8b4be38e7c83b2b13333a82a0ecde921a7390
refs/heads/master: 28b75a89480df99a17c8facd5c33985847d06bb6
6 changes: 6 additions & 0 deletions trunk/include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ struct le_scan_params {
u8 type;
u16 interval;
u16 window;
int timeout;
};

#define NUM_REASSEMBLY 4
Expand Down Expand Up @@ -269,6 +270,9 @@ struct hci_dev {

struct delayed_work le_scan_disable;

struct work_struct le_scan;
struct le_scan_params le_scan_params;

int (*open)(struct hci_dev *hdev);
int (*close)(struct hci_dev *hdev);
int (*flush)(struct hci_dev *hdev);
Expand Down Expand Up @@ -1033,5 +1037,7 @@ void hci_le_ltk_neg_reply(struct hci_conn *conn);

int hci_do_inquiry(struct hci_dev *hdev, u8 length);
int hci_cancel_inquiry(struct hci_dev *hdev);
int hci_le_scan(struct hci_dev *hdev, u8 type, u16 interval, u16 window,
int timeout);

#endif /* __HCI_CORE_H */
35 changes: 35 additions & 0 deletions trunk/net/bluetooth/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,8 @@ static int hci_dev_do_close(struct hci_dev *hdev)
{
BT_DBG("%s %p", hdev->name, hdev);

cancel_work_sync(&hdev->le_scan);

hci_req_cancel(hdev, ENODEV);
hci_req_lock(hdev);

Expand Down Expand Up @@ -1668,6 +1670,37 @@ static void le_scan_disable_work(struct work_struct *work)
hci_send_cmd(hdev, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp);
}

static void le_scan_work(struct work_struct *work)
{
struct hci_dev *hdev = container_of(work, struct hci_dev, le_scan);
struct le_scan_params *param = &hdev->le_scan_params;

BT_DBG("%s", hdev->name);

hci_do_le_scan(hdev, param->type, param->interval,
param->window, param->timeout);
}

int hci_le_scan(struct hci_dev *hdev, u8 type, u16 interval, u16 window,
int timeout)
{
struct le_scan_params *param = &hdev->le_scan_params;

BT_DBG("%s", hdev->name);

if (work_busy(&hdev->le_scan))
return -EINPROGRESS;

param->type = type;
param->interval = interval;
param->window = window;
param->timeout = timeout;

queue_work(system_long_wq, &hdev->le_scan);

return 0;
}

/* Register HCI device */
int hci_register_dev(struct hci_dev *hdev)
{
Expand Down Expand Up @@ -1754,6 +1787,8 @@ int hci_register_dev(struct hci_dev *hdev)

atomic_set(&hdev->promisc, 0);

INIT_WORK(&hdev->le_scan, le_scan_work);

INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work);

write_unlock(&hci_dev_list_lock);
Expand Down

0 comments on commit b2f9cb2

Please sign in to comment.