diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2013-10-17 22:16:02 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2013-10-18 03:50:37 -0400 |
commit | 2bfa3531f654d82db01d3121ae2de7a8696a4555 (patch) | |
tree | dc194f9c516017f6fd530dc06cd98f0404a00bec | |
parent | b25f07854791539ef1c1aff3a968cfe36cb31adf (diff) |
Bluetooth: Move idle_timeout and sniff_{min,max}_interval to hci_core.c
Move the debugfs configuration directly into hci_core.c and only expose
it when the controller actually support BR/EDR sniff power saving mode.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r-- | net/bluetooth/hci_core.c | 93 | ||||
-rw-r--r-- | net/bluetooth/hci_sysfs.c | 91 |
2 files changed, 93 insertions, 91 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index a4047d626b78..e8058c3c9576 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -195,6 +195,90 @@ static int auto_accept_delay_get(void *data, u64 *val) | |||
195 | DEFINE_SIMPLE_ATTRIBUTE(auto_accept_delay_fops, auto_accept_delay_get, | 195 | DEFINE_SIMPLE_ATTRIBUTE(auto_accept_delay_fops, auto_accept_delay_get, |
196 | auto_accept_delay_set, "%llu\n"); | 196 | auto_accept_delay_set, "%llu\n"); |
197 | 197 | ||
198 | static int idle_timeout_set(void *data, u64 val) | ||
199 | { | ||
200 | struct hci_dev *hdev = data; | ||
201 | |||
202 | if (val != 0 && (val < 500 || val > 3600000)) | ||
203 | return -EINVAL; | ||
204 | |||
205 | hci_dev_lock(hdev); | ||
206 | hdev->idle_timeout= val; | ||
207 | hci_dev_unlock(hdev); | ||
208 | |||
209 | return 0; | ||
210 | } | ||
211 | |||
212 | static int idle_timeout_get(void *data, u64 *val) | ||
213 | { | ||
214 | struct hci_dev *hdev = data; | ||
215 | |||
216 | hci_dev_lock(hdev); | ||
217 | *val = hdev->idle_timeout; | ||
218 | hci_dev_unlock(hdev); | ||
219 | |||
220 | return 0; | ||
221 | } | ||
222 | |||
223 | DEFINE_SIMPLE_ATTRIBUTE(idle_timeout_fops, idle_timeout_get, | ||
224 | idle_timeout_set, "%llu\n"); | ||
225 | |||
226 | static int sniff_min_interval_set(void *data, u64 val) | ||
227 | { | ||
228 | struct hci_dev *hdev = data; | ||
229 | |||
230 | if (val == 0 || val % 2 || val > hdev->sniff_max_interval) | ||
231 | return -EINVAL; | ||
232 | |||
233 | hci_dev_lock(hdev); | ||
234 | hdev->sniff_min_interval= val; | ||
235 | hci_dev_unlock(hdev); | ||
236 | |||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static int sniff_min_interval_get(void *data, u64 *val) | ||
241 | { | ||
242 | struct hci_dev *hdev = data; | ||
243 | |||
244 | hci_dev_lock(hdev); | ||
245 | *val = hdev->sniff_min_interval; | ||
246 | hci_dev_unlock(hdev); | ||
247 | |||
248 | return 0; | ||
249 | } | ||
250 | |||
251 | DEFINE_SIMPLE_ATTRIBUTE(sniff_min_interval_fops, sniff_min_interval_get, | ||
252 | sniff_min_interval_set, "%llu\n"); | ||
253 | |||
254 | static int sniff_max_interval_set(void *data, u64 val) | ||
255 | { | ||
256 | struct hci_dev *hdev = data; | ||
257 | |||
258 | if (val == 0 || val % 2 || val < hdev->sniff_min_interval) | ||
259 | return -EINVAL; | ||
260 | |||
261 | hci_dev_lock(hdev); | ||
262 | hdev->sniff_max_interval= val; | ||
263 | hci_dev_unlock(hdev); | ||
264 | |||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | static int sniff_max_interval_get(void *data, u64 *val) | ||
269 | { | ||
270 | struct hci_dev *hdev = data; | ||
271 | |||
272 | hci_dev_lock(hdev); | ||
273 | *val = hdev->sniff_max_interval; | ||
274 | hci_dev_unlock(hdev); | ||
275 | |||
276 | return 0; | ||
277 | } | ||
278 | |||
279 | DEFINE_SIMPLE_ATTRIBUTE(sniff_max_interval_fops, sniff_max_interval_get, | ||
280 | sniff_max_interval_set, "%llu\n"); | ||
281 | |||
198 | static int static_address_show(struct seq_file *f, void *p) | 282 | static int static_address_show(struct seq_file *f, void *p) |
199 | { | 283 | { |
200 | struct hci_dev *hdev = f->private; | 284 | struct hci_dev *hdev = f->private; |
@@ -923,6 +1007,15 @@ static int __hci_init(struct hci_dev *hdev) | |||
923 | debugfs_create_file("auto_accept_delay", 0644, hdev->debugfs, | 1007 | debugfs_create_file("auto_accept_delay", 0644, hdev->debugfs, |
924 | hdev, &auto_accept_delay_fops); | 1008 | hdev, &auto_accept_delay_fops); |
925 | 1009 | ||
1010 | if (lmp_sniff_capable(hdev)) { | ||
1011 | debugfs_create_file("idle_timeout", 0644, hdev->debugfs, | ||
1012 | hdev, &idle_timeout_fops); | ||
1013 | debugfs_create_file("sniff_min_interval", 0644, hdev->debugfs, | ||
1014 | hdev, &sniff_min_interval_fops); | ||
1015 | debugfs_create_file("sniff_max_interval", 0644, hdev->debugfs, | ||
1016 | hdev, &sniff_max_interval_fops); | ||
1017 | } | ||
1018 | |||
926 | if (lmp_le_capable(hdev)) | 1019 | if (lmp_le_capable(hdev)) |
927 | debugfs_create_file("static_address", 0444, hdev->debugfs, | 1020 | debugfs_create_file("static_address", 0444, hdev->debugfs, |
928 | hdev, &static_address_fops); | 1021 | hdev, &static_address_fops); |
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index 9cbf8fefb044..4fac57c5ddb7 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c | |||
@@ -255,87 +255,6 @@ static ssize_t show_hci_revision(struct device *dev, | |||
255 | return sprintf(buf, "%d\n", hdev->hci_rev); | 255 | return sprintf(buf, "%d\n", hdev->hci_rev); |
256 | } | 256 | } |
257 | 257 | ||
258 | static ssize_t show_idle_timeout(struct device *dev, | ||
259 | struct device_attribute *attr, char *buf) | ||
260 | { | ||
261 | struct hci_dev *hdev = to_hci_dev(dev); | ||
262 | return sprintf(buf, "%d\n", hdev->idle_timeout); | ||
263 | } | ||
264 | |||
265 | static ssize_t store_idle_timeout(struct device *dev, | ||
266 | struct device_attribute *attr, | ||
267 | const char *buf, size_t count) | ||
268 | { | ||
269 | struct hci_dev *hdev = to_hci_dev(dev); | ||
270 | unsigned int val; | ||
271 | int rv; | ||
272 | |||
273 | rv = kstrtouint(buf, 0, &val); | ||
274 | if (rv < 0) | ||
275 | return rv; | ||
276 | |||
277 | if (val != 0 && (val < 500 || val > 3600000)) | ||
278 | return -EINVAL; | ||
279 | |||
280 | hdev->idle_timeout = val; | ||
281 | |||
282 | return count; | ||
283 | } | ||
284 | |||
285 | static ssize_t show_sniff_max_interval(struct device *dev, | ||
286 | struct device_attribute *attr, char *buf) | ||
287 | { | ||
288 | struct hci_dev *hdev = to_hci_dev(dev); | ||
289 | return sprintf(buf, "%d\n", hdev->sniff_max_interval); | ||
290 | } | ||
291 | |||
292 | static ssize_t store_sniff_max_interval(struct device *dev, | ||
293 | struct device_attribute *attr, | ||
294 | const char *buf, size_t count) | ||
295 | { | ||
296 | struct hci_dev *hdev = to_hci_dev(dev); | ||
297 | u16 val; | ||
298 | int rv; | ||
299 | |||
300 | rv = kstrtou16(buf, 0, &val); | ||
301 | if (rv < 0) | ||
302 | return rv; | ||
303 | |||
304 | if (val == 0 || val % 2 || val < hdev->sniff_min_interval) | ||
305 | return -EINVAL; | ||
306 | |||
307 | hdev->sniff_max_interval = val; | ||
308 | |||
309 | return count; | ||
310 | } | ||
311 | |||
312 | static ssize_t show_sniff_min_interval(struct device *dev, | ||
313 | struct device_attribute *attr, char *buf) | ||
314 | { | ||
315 | struct hci_dev *hdev = to_hci_dev(dev); | ||
316 | return sprintf(buf, "%d\n", hdev->sniff_min_interval); | ||
317 | } | ||
318 | |||
319 | static ssize_t store_sniff_min_interval(struct device *dev, | ||
320 | struct device_attribute *attr, | ||
321 | const char *buf, size_t count) | ||
322 | { | ||
323 | struct hci_dev *hdev = to_hci_dev(dev); | ||
324 | u16 val; | ||
325 | int rv; | ||
326 | |||
327 | rv = kstrtou16(buf, 0, &val); | ||
328 | if (rv < 0) | ||
329 | return rv; | ||
330 | |||
331 | if (val == 0 || val % 2 || val > hdev->sniff_max_interval) | ||
332 | return -EINVAL; | ||
333 | |||
334 | hdev->sniff_min_interval = val; | ||
335 | |||
336 | return count; | ||
337 | } | ||
338 | |||
339 | static DEVICE_ATTR(bus, S_IRUGO, show_bus, NULL); | 258 | static DEVICE_ATTR(bus, S_IRUGO, show_bus, NULL); |
340 | static DEVICE_ATTR(type, S_IRUGO, show_type, NULL); | 259 | static DEVICE_ATTR(type, S_IRUGO, show_type, NULL); |
341 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | 260 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); |
@@ -346,13 +265,6 @@ static DEVICE_ATTR(manufacturer, S_IRUGO, show_manufacturer, NULL); | |||
346 | static DEVICE_ATTR(hci_version, S_IRUGO, show_hci_version, NULL); | 265 | static DEVICE_ATTR(hci_version, S_IRUGO, show_hci_version, NULL); |
347 | static DEVICE_ATTR(hci_revision, S_IRUGO, show_hci_revision, NULL); | 266 | static DEVICE_ATTR(hci_revision, S_IRUGO, show_hci_revision, NULL); |
348 | 267 | ||
349 | static DEVICE_ATTR(idle_timeout, S_IRUGO | S_IWUSR, | ||
350 | show_idle_timeout, store_idle_timeout); | ||
351 | static DEVICE_ATTR(sniff_max_interval, S_IRUGO | S_IWUSR, | ||
352 | show_sniff_max_interval, store_sniff_max_interval); | ||
353 | static DEVICE_ATTR(sniff_min_interval, S_IRUGO | S_IWUSR, | ||
354 | show_sniff_min_interval, store_sniff_min_interval); | ||
355 | |||
356 | static struct attribute *bt_host_attrs[] = { | 268 | static struct attribute *bt_host_attrs[] = { |
357 | &dev_attr_bus.attr, | 269 | &dev_attr_bus.attr, |
358 | &dev_attr_type.attr, | 270 | &dev_attr_type.attr, |
@@ -363,9 +275,6 @@ static struct attribute *bt_host_attrs[] = { | |||
363 | &dev_attr_manufacturer.attr, | 275 | &dev_attr_manufacturer.attr, |
364 | &dev_attr_hci_version.attr, | 276 | &dev_attr_hci_version.attr, |
365 | &dev_attr_hci_revision.attr, | 277 | &dev_attr_hci_revision.attr, |
366 | &dev_attr_idle_timeout.attr, | ||
367 | &dev_attr_sniff_max_interval.attr, | ||
368 | &dev_attr_sniff_min_interval.attr, | ||
369 | NULL | 278 | NULL |
370 | }; | 279 | }; |
371 | 280 | ||