summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
authorFlorian Grandel <fgrandel@gmail.com>2015-06-18 03:16:35 +0200
committerMarcel Holtmann <marcel@holtmann.org>2015-06-18 18:11:51 +0200
commit5d900e4601391576a3c0644d7fcad1ebf41a516e (patch)
tree8eb7d818696d6fadb24512cb882b3bc5d22517ce /net/bluetooth/mgmt.c
parentBluetooth: hci_core/mgmt: Introduce multi-adv list (diff)
downloadlinux-5d900e4601391576a3c0644d7fcad1ebf41a516e.tar.xz
linux-5d900e4601391576a3c0644d7fcad1ebf41a516e.zip
Bluetooth: hci_core/mgmt: move adv timeout to hdev
Currently the delayed work managing advertising duration and timeout is part of the advertising instance structure. This is not correct as only a single instance can be advertised at any given time. To implement round robin advertising a single delayed work structure is needed. To fix this the delayed work structure is being moved to the hci_dev structure. The instance specific variable is renamed to "remaining_time" to make it clear that this is the remaining lifetime of the instance and not the current advertising timeout. Signed-off-by: Florian Grandel <fgrandel@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 92c50a17fdf9..a8319f6cfa65 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1466,8 +1466,8 @@ static void clear_adv_instance(struct hci_dev *hdev)
if (!hci_dev_test_flag(hdev, HCI_ADVERTISING_INSTANCE))
return;
- if (hdev->adv_instance.timeout)
- cancel_delayed_work(&hdev->adv_instance.timeout_exp);
+ if (hdev->adv_instance_timeout)
+ cancel_delayed_work(&hdev->adv_instance_expire);
memset(&hdev->adv_instance, 0, sizeof(hdev->adv_instance));
advertising_removed(NULL, hdev, 1);
@@ -1497,7 +1497,7 @@ static int clean_up_hci_state(struct hci_dev *hdev)
hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
}
- if (hdev->adv_instance.timeout)
+ if (hdev->adv_instance_timeout)
clear_adv_instance(hdev);
if (hci_dev_test_flag(hdev, HCI_LE_ADV))
@@ -6914,12 +6914,9 @@ unlock:
hci_dev_unlock(hdev);
}
-static void adv_timeout_expired(struct work_struct *work)
+void mgmt_adv_timeout_expired(struct hci_dev *hdev)
{
- struct hci_dev *hdev = container_of(work, struct hci_dev,
- adv_instance.timeout_exp.work);
-
- hdev->adv_instance.timeout = 0;
+ hdev->adv_instance_timeout = 0;
hci_dev_lock(hdev);
clear_adv_instance(hdev);
@@ -6981,8 +6978,6 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev,
goto unlock;
}
- INIT_DELAYED_WORK(&hdev->adv_instance.timeout_exp, adv_timeout_expired);
-
hdev->adv_instance.flags = flags;
hdev->adv_instance.adv_data_len = cp->adv_data_len;
hdev->adv_instance.scan_rsp_len = cp->scan_rsp_len;
@@ -6994,14 +6989,14 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev,
memcpy(hdev->adv_instance.scan_rsp_data,
cp->data + cp->adv_data_len, cp->scan_rsp_len);
- if (hdev->adv_instance.timeout)
- cancel_delayed_work(&hdev->adv_instance.timeout_exp);
+ if (hdev->adv_instance_timeout)
+ cancel_delayed_work(&hdev->adv_instance_expire);
- hdev->adv_instance.timeout = timeout;
+ hdev->adv_instance_timeout = timeout;
if (timeout)
queue_delayed_work(hdev->workqueue,
- &hdev->adv_instance.timeout_exp,
+ &hdev->adv_instance_expire,
msecs_to_jiffies(timeout * 1000));
if (!hci_dev_test_and_set_flag(hdev, HCI_ADVERTISING_INSTANCE))
@@ -7106,8 +7101,8 @@ static int remove_advertising(struct sock *sk, struct hci_dev *hdev,
goto unlock;
}
- if (hdev->adv_instance.timeout)
- cancel_delayed_work(&hdev->adv_instance.timeout_exp);
+ if (hdev->adv_instance_timeout)
+ cancel_delayed_work(&hdev->adv_instance_expire);
memset(&hdev->adv_instance, 0, sizeof(hdev->adv_instance));