aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_core.c
diff options
context:
space:
mode:
authorAndrzej Kaczmarek <andrzej.kaczmarek@tieto.com>2014-05-14 07:43:02 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-05-16 00:48:05 -0400
commit31ad169148df2252a774c73c504aff43bfa4b656 (patch)
tree8ce9716ef7580777342c23c564026dc76c7fe5fd /net/bluetooth/hci_core.c
parent5a134faeef82b46ff4ad244d11d8c6be41679834 (diff)
Bluetooth: Add conn info lifetime parameters to debugfs
This patch adds conn_info_min_age and conn_info_max_age parameters to debugfs which determine lifetime of connection information. Actual lifetime will be random value between min and max age. Default values for min and max age are 1000ms and 3000ms respectively. Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/hci_core.c')
-rw-r--r--net/bluetooth/hci_core.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index d31f144860d1..313bd1c164d6 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -579,6 +579,62 @@ static int sniff_max_interval_get(void *data, u64 *val)
579DEFINE_SIMPLE_ATTRIBUTE(sniff_max_interval_fops, sniff_max_interval_get, 579DEFINE_SIMPLE_ATTRIBUTE(sniff_max_interval_fops, sniff_max_interval_get,
580 sniff_max_interval_set, "%llu\n"); 580 sniff_max_interval_set, "%llu\n");
581 581
582static int conn_info_min_age_set(void *data, u64 val)
583{
584 struct hci_dev *hdev = data;
585
586 if (val == 0 || val > hdev->conn_info_max_age)
587 return -EINVAL;
588
589 hci_dev_lock(hdev);
590 hdev->conn_info_min_age = val;
591 hci_dev_unlock(hdev);
592
593 return 0;
594}
595
596static int conn_info_min_age_get(void *data, u64 *val)
597{
598 struct hci_dev *hdev = data;
599
600 hci_dev_lock(hdev);
601 *val = hdev->conn_info_min_age;
602 hci_dev_unlock(hdev);
603
604 return 0;
605}
606
607DEFINE_SIMPLE_ATTRIBUTE(conn_info_min_age_fops, conn_info_min_age_get,
608 conn_info_min_age_set, "%llu\n");
609
610static int conn_info_max_age_set(void *data, u64 val)
611{
612 struct hci_dev *hdev = data;
613
614 if (val == 0 || val < hdev->conn_info_min_age)
615 return -EINVAL;
616
617 hci_dev_lock(hdev);
618 hdev->conn_info_max_age = val;
619 hci_dev_unlock(hdev);
620
621 return 0;
622}
623
624static int conn_info_max_age_get(void *data, u64 *val)
625{
626 struct hci_dev *hdev = data;
627
628 hci_dev_lock(hdev);
629 *val = hdev->conn_info_max_age;
630 hci_dev_unlock(hdev);
631
632 return 0;
633}
634
635DEFINE_SIMPLE_ATTRIBUTE(conn_info_max_age_fops, conn_info_max_age_get,
636 conn_info_max_age_set, "%llu\n");
637
582static int identity_show(struct seq_file *f, void *p) 638static int identity_show(struct seq_file *f, void *p)
583{ 639{
584 struct hci_dev *hdev = f->private; 640 struct hci_dev *hdev = f->private;
@@ -1754,6 +1810,11 @@ static int __hci_init(struct hci_dev *hdev)
1754 &blacklist_fops); 1810 &blacklist_fops);
1755 debugfs_create_file("uuids", 0444, hdev->debugfs, hdev, &uuids_fops); 1811 debugfs_create_file("uuids", 0444, hdev->debugfs, hdev, &uuids_fops);
1756 1812
1813 debugfs_create_file("conn_info_min_age", 0644, hdev->debugfs, hdev,
1814 &conn_info_min_age_fops);
1815 debugfs_create_file("conn_info_max_age", 0644, hdev->debugfs, hdev,
1816 &conn_info_max_age_fops);
1817
1757 if (lmp_bredr_capable(hdev)) { 1818 if (lmp_bredr_capable(hdev)) {
1758 debugfs_create_file("inquiry_cache", 0444, hdev->debugfs, 1819 debugfs_create_file("inquiry_cache", 0444, hdev->debugfs,
1759 hdev, &inquiry_cache_fops); 1820 hdev, &inquiry_cache_fops);
@@ -3789,6 +3850,8 @@ struct hci_dev *hci_alloc_dev(void)
3789 3850
3790 hdev->rpa_timeout = HCI_DEFAULT_RPA_TIMEOUT; 3851 hdev->rpa_timeout = HCI_DEFAULT_RPA_TIMEOUT;
3791 hdev->discov_interleaved_timeout = DISCOV_INTERLEAVED_TIMEOUT; 3852 hdev->discov_interleaved_timeout = DISCOV_INTERLEAVED_TIMEOUT;
3853 hdev->conn_info_min_age = DEFAULT_CONN_INFO_MIN_AGE;
3854 hdev->conn_info_max_age = DEFAULT_CONN_INFO_MAX_AGE;
3792 3855
3793 mutex_init(&hdev->lock); 3856 mutex_init(&hdev->lock);
3794 mutex_init(&hdev->req_lock); 3857 mutex_init(&hdev->req_lock);