Skip to content

Commit 729a105

Browse files
ge0rgholtmann
authored andcommitted
Bluetooth: Expose default LE advertising interval via debugfs
Expose the default values for minimum and maximum LE advertising interval via debugfs for testing purposes. Signed-off-by: Georg Lukas <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 628531c commit 729a105

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

net/bluetooth/hci_core.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,62 @@ static int adv_channel_map_get(void *data, u64 *val)
970970
DEFINE_SIMPLE_ATTRIBUTE(adv_channel_map_fops, adv_channel_map_get,
971971
adv_channel_map_set, "%llu\n");
972972

973+
static int adv_min_interval_set(void *data, u64 val)
974+
{
975+
struct hci_dev *hdev = data;
976+
977+
if (val < 0x0020 || val > 0x4000 || val > hdev->le_adv_max_interval)
978+
return -EINVAL;
979+
980+
hci_dev_lock(hdev);
981+
hdev->le_adv_min_interval = val;
982+
hci_dev_unlock(hdev);
983+
984+
return 0;
985+
}
986+
987+
static int adv_min_interval_get(void *data, u64 *val)
988+
{
989+
struct hci_dev *hdev = data;
990+
991+
hci_dev_lock(hdev);
992+
*val = hdev->le_adv_min_interval;
993+
hci_dev_unlock(hdev);
994+
995+
return 0;
996+
}
997+
998+
DEFINE_SIMPLE_ATTRIBUTE(adv_min_interval_fops, adv_min_interval_get,
999+
adv_min_interval_set, "%llu\n");
1000+
1001+
static int adv_max_interval_set(void *data, u64 val)
1002+
{
1003+
struct hci_dev *hdev = data;
1004+
1005+
if (val < 0x0020 || val > 0x4000 || val < hdev->le_adv_min_interval)
1006+
return -EINVAL;
1007+
1008+
hci_dev_lock(hdev);
1009+
hdev->le_adv_max_interval = val;
1010+
hci_dev_unlock(hdev);
1011+
1012+
return 0;
1013+
}
1014+
1015+
static int adv_max_interval_get(void *data, u64 *val)
1016+
{
1017+
struct hci_dev *hdev = data;
1018+
1019+
hci_dev_lock(hdev);
1020+
*val = hdev->le_adv_max_interval;
1021+
hci_dev_unlock(hdev);
1022+
1023+
return 0;
1024+
}
1025+
1026+
DEFINE_SIMPLE_ATTRIBUTE(adv_max_interval_fops, adv_max_interval_get,
1027+
adv_max_interval_set, "%llu\n");
1028+
9731029
static int device_list_show(struct seq_file *f, void *ptr)
9741030
{
9751031
struct hci_dev *hdev = f->private;
@@ -1833,6 +1889,10 @@ static int __hci_init(struct hci_dev *hdev)
18331889
hdev, &supervision_timeout_fops);
18341890
debugfs_create_file("adv_channel_map", 0644, hdev->debugfs,
18351891
hdev, &adv_channel_map_fops);
1892+
debugfs_create_file("adv_min_interval", 0644, hdev->debugfs,
1893+
hdev, &adv_min_interval_fops);
1894+
debugfs_create_file("adv_max_interval", 0644, hdev->debugfs,
1895+
hdev, &adv_max_interval_fops);
18361896
debugfs_create_file("device_list", 0444, hdev->debugfs, hdev,
18371897
&device_list_fops);
18381898
debugfs_create_u16("discov_interleaved_timeout", 0644,

0 commit comments

Comments
 (0)