diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2015-11-23 08:43:06 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2015-12-09 18:51:48 -0500 |
commit | c366f555b8df67633b849a5088bb897d6c63aaa5 (patch) | |
tree | 4c07c7724649b050ddbdd93d677c92dd0ca79bdb /net/bluetooth | |
parent | aed1a8851db022c3bd22af41a343068b8c6e40c1 (diff) |
Bluetooth: Move discoverable timeout behind hdev->req_workqueue
Since the other discoverable changes are behind req_workqueue now it
only makes sense to move the discoverable timeout there as well.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hci_core.c | 13 | ||||
-rw-r--r-- | net/bluetooth/hci_request.c | 26 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 41 |
3 files changed, 28 insertions, 52 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index bab8958bf46e..484c75f3332c 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -1537,7 +1537,6 @@ int hci_dev_do_close(struct hci_dev *hdev) | |||
1537 | flush_work(&hdev->rx_work); | 1537 | flush_work(&hdev->rx_work); |
1538 | 1538 | ||
1539 | if (hdev->discov_timeout > 0) { | 1539 | if (hdev->discov_timeout > 0) { |
1540 | cancel_delayed_work(&hdev->discov_off); | ||
1541 | hdev->discov_timeout = 0; | 1540 | hdev->discov_timeout = 0; |
1542 | hci_dev_clear_flag(hdev, HCI_DISCOVERABLE); | 1541 | hci_dev_clear_flag(hdev, HCI_DISCOVERABLE); |
1543 | hci_dev_clear_flag(hdev, HCI_LIMITED_DISCOVERABLE); | 1542 | hci_dev_clear_flag(hdev, HCI_LIMITED_DISCOVERABLE); |
@@ -2096,17 +2095,6 @@ static void hci_error_reset(struct work_struct *work) | |||
2096 | hci_dev_do_open(hdev); | 2095 | hci_dev_do_open(hdev); |
2097 | } | 2096 | } |
2098 | 2097 | ||
2099 | static void hci_discov_off(struct work_struct *work) | ||
2100 | { | ||
2101 | struct hci_dev *hdev; | ||
2102 | |||
2103 | hdev = container_of(work, struct hci_dev, discov_off.work); | ||
2104 | |||
2105 | BT_DBG("%s", hdev->name); | ||
2106 | |||
2107 | mgmt_discoverable_timeout(hdev); | ||
2108 | } | ||
2109 | |||
2110 | void hci_uuids_clear(struct hci_dev *hdev) | 2098 | void hci_uuids_clear(struct hci_dev *hdev) |
2111 | { | 2099 | { |
2112 | struct bt_uuid *uuid, *tmp; | 2100 | struct bt_uuid *uuid, *tmp; |
@@ -2986,7 +2974,6 @@ struct hci_dev *hci_alloc_dev(void) | |||
2986 | INIT_WORK(&hdev->error_reset, hci_error_reset); | 2974 | INIT_WORK(&hdev->error_reset, hci_error_reset); |
2987 | 2975 | ||
2988 | INIT_DELAYED_WORK(&hdev->power_off, hci_power_off); | 2976 | INIT_DELAYED_WORK(&hdev->power_off, hci_power_off); |
2989 | INIT_DELAYED_WORK(&hdev->discov_off, hci_discov_off); | ||
2990 | 2977 | ||
2991 | skb_queue_head_init(&hdev->rx_q); | 2978 | skb_queue_head_init(&hdev->rx_q); |
2992 | skb_queue_head_init(&hdev->cmd_q); | 2979 | skb_queue_head_init(&hdev->cmd_q); |
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 8f72218ed805..fe14fd121d36 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c | |||
@@ -1923,6 +1923,30 @@ static void discov_update(struct work_struct *work) | |||
1923 | } | 1923 | } |
1924 | } | 1924 | } |
1925 | 1925 | ||
1926 | static void discov_off(struct work_struct *work) | ||
1927 | { | ||
1928 | struct hci_dev *hdev = container_of(work, struct hci_dev, | ||
1929 | discov_off.work); | ||
1930 | |||
1931 | BT_DBG("%s", hdev->name); | ||
1932 | |||
1933 | hci_dev_lock(hdev); | ||
1934 | |||
1935 | /* When discoverable timeout triggers, then just make sure | ||
1936 | * the limited discoverable flag is cleared. Even in the case | ||
1937 | * of a timeout triggered from general discoverable, it is | ||
1938 | * safe to unconditionally clear the flag. | ||
1939 | */ | ||
1940 | hci_dev_clear_flag(hdev, HCI_LIMITED_DISCOVERABLE); | ||
1941 | hci_dev_clear_flag(hdev, HCI_DISCOVERABLE); | ||
1942 | hdev->discov_timeout = 0; | ||
1943 | |||
1944 | hci_dev_unlock(hdev); | ||
1945 | |||
1946 | hci_req_sync(hdev, discoverable_update, 0, HCI_CMD_TIMEOUT, NULL); | ||
1947 | mgmt_new_settings(hdev); | ||
1948 | } | ||
1949 | |||
1926 | void hci_request_setup(struct hci_dev *hdev) | 1950 | void hci_request_setup(struct hci_dev *hdev) |
1927 | { | 1951 | { |
1928 | INIT_WORK(&hdev->discov_update, discov_update); | 1952 | INIT_WORK(&hdev->discov_update, discov_update); |
@@ -1930,6 +1954,7 @@ void hci_request_setup(struct hci_dev *hdev) | |||
1930 | INIT_WORK(&hdev->scan_update, scan_update_work); | 1954 | INIT_WORK(&hdev->scan_update, scan_update_work); |
1931 | INIT_WORK(&hdev->connectable_update, connectable_update_work); | 1955 | INIT_WORK(&hdev->connectable_update, connectable_update_work); |
1932 | INIT_WORK(&hdev->discoverable_update, discoverable_update_work); | 1956 | INIT_WORK(&hdev->discoverable_update, discoverable_update_work); |
1957 | INIT_DELAYED_WORK(&hdev->discov_off, discov_off); | ||
1933 | INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work); | 1958 | INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work); |
1934 | INIT_DELAYED_WORK(&hdev->le_scan_restart, le_scan_restart_work); | 1959 | INIT_DELAYED_WORK(&hdev->le_scan_restart, le_scan_restart_work); |
1935 | INIT_DELAYED_WORK(&hdev->adv_instance_expire, adv_timeout_expire); | 1960 | INIT_DELAYED_WORK(&hdev->adv_instance_expire, adv_timeout_expire); |
@@ -1944,6 +1969,7 @@ void hci_request_cancel_all(struct hci_dev *hdev) | |||
1944 | cancel_work_sync(&hdev->scan_update); | 1969 | cancel_work_sync(&hdev->scan_update); |
1945 | cancel_work_sync(&hdev->connectable_update); | 1970 | cancel_work_sync(&hdev->connectable_update); |
1946 | cancel_work_sync(&hdev->discoverable_update); | 1971 | cancel_work_sync(&hdev->discoverable_update); |
1972 | cancel_delayed_work_sync(&hdev->discov_off); | ||
1947 | cancel_delayed_work_sync(&hdev->le_scan_disable); | 1973 | cancel_delayed_work_sync(&hdev->le_scan_disable); |
1948 | cancel_delayed_work_sync(&hdev->le_scan_restart); | 1974 | cancel_delayed_work_sync(&hdev->le_scan_restart); |
1949 | 1975 | ||
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 8846cb3b0aaa..29b3bb70ae9f 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -1401,8 +1401,8 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data, | |||
1401 | 1401 | ||
1402 | if (cp->val && hdev->discov_timeout > 0) { | 1402 | if (cp->val && hdev->discov_timeout > 0) { |
1403 | int to = msecs_to_jiffies(hdev->discov_timeout * 1000); | 1403 | int to = msecs_to_jiffies(hdev->discov_timeout * 1000); |
1404 | queue_delayed_work(hdev->workqueue, &hdev->discov_off, | 1404 | queue_delayed_work(hdev->req_workqueue, |
1405 | to); | 1405 | &hdev->discov_off, to); |
1406 | } | 1406 | } |
1407 | 1407 | ||
1408 | err = send_settings_rsp(sk, MGMT_OP_SET_DISCOVERABLE, hdev); | 1408 | err = send_settings_rsp(sk, MGMT_OP_SET_DISCOVERABLE, hdev); |
@@ -6848,43 +6848,6 @@ void mgmt_set_powered_failed(struct hci_dev *hdev, int err) | |||
6848 | mgmt_pending_remove(cmd); | 6848 | mgmt_pending_remove(cmd); |
6849 | } | 6849 | } |
6850 | 6850 | ||
6851 | void mgmt_discoverable_timeout(struct hci_dev *hdev) | ||
6852 | { | ||
6853 | struct hci_request req; | ||
6854 | |||
6855 | hci_dev_lock(hdev); | ||
6856 | |||
6857 | /* When discoverable timeout triggers, then just make sure | ||
6858 | * the limited discoverable flag is cleared. Even in the case | ||
6859 | * of a timeout triggered from general discoverable, it is | ||
6860 | * safe to unconditionally clear the flag. | ||
6861 | */ | ||
6862 | hci_dev_clear_flag(hdev, HCI_LIMITED_DISCOVERABLE); | ||
6863 | hci_dev_clear_flag(hdev, HCI_DISCOVERABLE); | ||
6864 | |||
6865 | hci_req_init(&req, hdev); | ||
6866 | if (hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) { | ||
6867 | u8 scan = SCAN_PAGE; | ||
6868 | hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, | ||
6869 | sizeof(scan), &scan); | ||
6870 | } | ||
6871 | __hci_req_update_class(&req); | ||
6872 | |||
6873 | /* Advertising instances don't use the global discoverable setting, so | ||
6874 | * only update AD if advertising was enabled using Set Advertising. | ||
6875 | */ | ||
6876 | if (hci_dev_test_flag(hdev, HCI_ADVERTISING)) | ||
6877 | __hci_req_update_adv_data(&req, HCI_ADV_CURRENT); | ||
6878 | |||
6879 | hci_req_run(&req, NULL); | ||
6880 | |||
6881 | hdev->discov_timeout = 0; | ||
6882 | |||
6883 | new_settings(hdev, NULL); | ||
6884 | |||
6885 | hci_dev_unlock(hdev); | ||
6886 | } | ||
6887 | |||
6888 | void mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, | 6851 | void mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, |
6889 | bool persistent) | 6852 | bool persistent) |
6890 | { | 6853 | { |