diff options
-rw-r--r-- | include/net/bluetooth/hci_core.h | 6 | ||||
-rw-r--r-- | net/bluetooth/hci_core.c | 35 |
2 files changed, 41 insertions, 0 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 3e70872bffea..7107790817a5 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -126,6 +126,7 @@ struct le_scan_params { | |||
126 | u8 type; | 126 | u8 type; |
127 | u16 interval; | 127 | u16 interval; |
128 | u16 window; | 128 | u16 window; |
129 | int timeout; | ||
129 | }; | 130 | }; |
130 | 131 | ||
131 | #define NUM_REASSEMBLY 4 | 132 | #define NUM_REASSEMBLY 4 |
@@ -269,6 +270,9 @@ struct hci_dev { | |||
269 | 270 | ||
270 | struct delayed_work le_scan_disable; | 271 | struct delayed_work le_scan_disable; |
271 | 272 | ||
273 | struct work_struct le_scan; | ||
274 | struct le_scan_params le_scan_params; | ||
275 | |||
272 | int (*open)(struct hci_dev *hdev); | 276 | int (*open)(struct hci_dev *hdev); |
273 | int (*close)(struct hci_dev *hdev); | 277 | int (*close)(struct hci_dev *hdev); |
274 | int (*flush)(struct hci_dev *hdev); | 278 | int (*flush)(struct hci_dev *hdev); |
@@ -1033,5 +1037,7 @@ void hci_le_ltk_neg_reply(struct hci_conn *conn); | |||
1033 | 1037 | ||
1034 | int hci_do_inquiry(struct hci_dev *hdev, u8 length); | 1038 | int hci_do_inquiry(struct hci_dev *hdev, u8 length); |
1035 | int hci_cancel_inquiry(struct hci_dev *hdev); | 1039 | int hci_cancel_inquiry(struct hci_dev *hdev); |
1040 | int hci_le_scan(struct hci_dev *hdev, u8 type, u16 interval, u16 window, | ||
1041 | int timeout); | ||
1036 | 1042 | ||
1037 | #endif /* __HCI_CORE_H */ | 1043 | #endif /* __HCI_CORE_H */ |
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index ae86cdd80ac0..3d09f4b4ca68 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -735,6 +735,8 @@ static int hci_dev_do_close(struct hci_dev *hdev) | |||
735 | { | 735 | { |
736 | BT_DBG("%s %p", hdev->name, hdev); | 736 | BT_DBG("%s %p", hdev->name, hdev); |
737 | 737 | ||
738 | cancel_work_sync(&hdev->le_scan); | ||
739 | |||
738 | hci_req_cancel(hdev, ENODEV); | 740 | hci_req_cancel(hdev, ENODEV); |
739 | hci_req_lock(hdev); | 741 | hci_req_lock(hdev); |
740 | 742 | ||
@@ -1668,6 +1670,37 @@ static void le_scan_disable_work(struct work_struct *work) | |||
1668 | hci_send_cmd(hdev, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); | 1670 | hci_send_cmd(hdev, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); |
1669 | } | 1671 | } |
1670 | 1672 | ||
1673 | static void le_scan_work(struct work_struct *work) | ||
1674 | { | ||
1675 | struct hci_dev *hdev = container_of(work, struct hci_dev, le_scan); | ||
1676 | struct le_scan_params *param = &hdev->le_scan_params; | ||
1677 | |||
1678 | BT_DBG("%s", hdev->name); | ||
1679 | |||
1680 | hci_do_le_scan(hdev, param->type, param->interval, | ||
1681 | param->window, param->timeout); | ||
1682 | } | ||
1683 | |||
1684 | int hci_le_scan(struct hci_dev *hdev, u8 type, u16 interval, u16 window, | ||
1685 | int timeout) | ||
1686 | { | ||
1687 | struct le_scan_params *param = &hdev->le_scan_params; | ||
1688 | |||
1689 | BT_DBG("%s", hdev->name); | ||
1690 | |||
1691 | if (work_busy(&hdev->le_scan)) | ||
1692 | return -EINPROGRESS; | ||
1693 | |||
1694 | param->type = type; | ||
1695 | param->interval = interval; | ||
1696 | param->window = window; | ||
1697 | param->timeout = timeout; | ||
1698 | |||
1699 | queue_work(system_long_wq, &hdev->le_scan); | ||
1700 | |||
1701 | return 0; | ||
1702 | } | ||
1703 | |||
1671 | /* Register HCI device */ | 1704 | /* Register HCI device */ |
1672 | int hci_register_dev(struct hci_dev *hdev) | 1705 | int hci_register_dev(struct hci_dev *hdev) |
1673 | { | 1706 | { |
@@ -1754,6 +1787,8 @@ int hci_register_dev(struct hci_dev *hdev) | |||
1754 | 1787 | ||
1755 | atomic_set(&hdev->promisc, 0); | 1788 | atomic_set(&hdev->promisc, 0); |
1756 | 1789 | ||
1790 | INIT_WORK(&hdev->le_scan, le_scan_work); | ||
1791 | |||
1757 | INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work); | 1792 | INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work); |
1758 | 1793 | ||
1759 | write_unlock(&hci_dev_list_lock); | 1794 | write_unlock(&hci_dev_list_lock); |