aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth/hci_sysfs.c')
-rw-r--r--net/bluetooth/hci_sysfs.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 19b234c86f33..89918d2f1fdc 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -61,18 +61,106 @@ static ssize_t show_inquiry_cache(struct class_device *cdev, char *buf)
61 return n; 61 return n;
62} 62}
63 63
64static ssize_t show_idle_timeout(struct class_device *cdev, char *buf)
65{
66 struct hci_dev *hdev = class_get_devdata(cdev);
67 return sprintf(buf, "%d\n", hdev->idle_timeout);
68}
69
70static ssize_t store_idle_timeout(struct class_device *cdev, const char *buf, size_t count)
71{
72 struct hci_dev *hdev = class_get_devdata(cdev);
73 char *ptr;
74 __u32 val;
75
76 val = simple_strtoul(buf, &ptr, 10);
77 if (ptr == buf)
78 return -EINVAL;
79
80 if (val != 0 && (val < 500 || val > 3600000))
81 return -EINVAL;
82
83 hdev->idle_timeout = val;
84
85 return count;
86}
87
88static ssize_t show_sniff_max_interval(struct class_device *cdev, char *buf)
89{
90 struct hci_dev *hdev = class_get_devdata(cdev);
91 return sprintf(buf, "%d\n", hdev->sniff_max_interval);
92}
93
94static ssize_t store_sniff_max_interval(struct class_device *cdev, const char *buf, size_t count)
95{
96 struct hci_dev *hdev = class_get_devdata(cdev);
97 char *ptr;
98 __u16 val;
99
100 val = simple_strtoul(buf, &ptr, 10);
101 if (ptr == buf)
102 return -EINVAL;
103
104 if (val < 0x0002 || val > 0xFFFE || val % 2)
105 return -EINVAL;
106
107 if (val < hdev->sniff_min_interval)
108 return -EINVAL;
109
110 hdev->sniff_max_interval = val;
111
112 return count;
113}
114
115static ssize_t show_sniff_min_interval(struct class_device *cdev, char *buf)
116{
117 struct hci_dev *hdev = class_get_devdata(cdev);
118 return sprintf(buf, "%d\n", hdev->sniff_min_interval);
119}
120
121static ssize_t store_sniff_min_interval(struct class_device *cdev, const char *buf, size_t count)
122{
123 struct hci_dev *hdev = class_get_devdata(cdev);
124 char *ptr;
125 __u16 val;
126
127 val = simple_strtoul(buf, &ptr, 10);
128 if (ptr == buf)
129 return -EINVAL;
130
131 if (val < 0x0002 || val > 0xFFFE || val % 2)
132 return -EINVAL;
133
134 if (val > hdev->sniff_max_interval)
135 return -EINVAL;
136
137 hdev->sniff_min_interval = val;
138
139 return count;
140}
141
64static CLASS_DEVICE_ATTR(name, S_IRUGO, show_name, NULL); 142static CLASS_DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
65static CLASS_DEVICE_ATTR(type, S_IRUGO, show_type, NULL); 143static CLASS_DEVICE_ATTR(type, S_IRUGO, show_type, NULL);
66static CLASS_DEVICE_ATTR(address, S_IRUGO, show_address, NULL); 144static CLASS_DEVICE_ATTR(address, S_IRUGO, show_address, NULL);
67static CLASS_DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL); 145static CLASS_DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL);
68static CLASS_DEVICE_ATTR(inquiry_cache, S_IRUGO, show_inquiry_cache, NULL); 146static CLASS_DEVICE_ATTR(inquiry_cache, S_IRUGO, show_inquiry_cache, NULL);
69 147
148static CLASS_DEVICE_ATTR(idle_timeout, S_IRUGO | S_IWUSR,
149 show_idle_timeout, store_idle_timeout);
150static CLASS_DEVICE_ATTR(sniff_max_interval, S_IRUGO | S_IWUSR,
151 show_sniff_max_interval, store_sniff_max_interval);
152static CLASS_DEVICE_ATTR(sniff_min_interval, S_IRUGO | S_IWUSR,
153 show_sniff_min_interval, store_sniff_min_interval);
154
70static struct class_device_attribute *bt_attrs[] = { 155static struct class_device_attribute *bt_attrs[] = {
71 &class_device_attr_name, 156 &class_device_attr_name,
72 &class_device_attr_type, 157 &class_device_attr_type,
73 &class_device_attr_address, 158 &class_device_attr_address,
74 &class_device_attr_flags, 159 &class_device_attr_flags,
75 &class_device_attr_inquiry_cache, 160 &class_device_attr_inquiry_cache,
161 &class_device_attr_idle_timeout,
162 &class_device_attr_sniff_max_interval,
163 &class_device_attr_sniff_min_interval,
76 NULL 164 NULL
77}; 165};
78 166