aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2013-10-16 06:28:55 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2013-10-16 12:53:18 -0400
commitbaf27f6e0e13b9b7e81fd4c758ac87f165c1a422 (patch)
tree27c735f616d3a1fb55e79f2da20cc7b812c0d3e8 /net/bluetooth
parent7f59ddada192583aee81ebf0de4cdc5a94642915 (diff)
Bluetooth: Expose inquiry_cache debugfs only on BR/EDR controllers
The inquiry_cache debugfs entry is only valid for BR/EDR capable controllers. In case of single mode LE-only controllers that entry is not valid. Move the creating of the debugfs entries to the end of controller init and only create the inquiry_cache entry if BR/EDR is actually supported. At the same time this avoids creating any debugfs entries for AMP controllers since none of the entries are valid there. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/hci_core.c57
-rw-r--r--net/bluetooth/hci_sysfs.c39
2 files changed, 55 insertions, 41 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 2af0baca6dc1..73c8def0c327 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -27,8 +27,8 @@
27 27
28#include <linux/export.h> 28#include <linux/export.h>
29#include <linux/idr.h> 29#include <linux/idr.h>
30
31#include <linux/rfkill.h> 30#include <linux/rfkill.h>
31#include <linux/debugfs.h>
32 32
33#include <net/bluetooth/bluetooth.h> 33#include <net/bluetooth/bluetooth.h>
34#include <net/bluetooth/hci_core.h> 34#include <net/bluetooth/hci_core.h>
@@ -55,6 +55,44 @@ static void hci_notify(struct hci_dev *hdev, int event)
55 hci_sock_dev_event(hdev, event); 55 hci_sock_dev_event(hdev, event);
56} 56}
57 57
58/* ---- HCI debugfs entries ---- */
59
60static int inquiry_cache_show(struct seq_file *f, void *p)
61{
62 struct hci_dev *hdev = f->private;
63 struct discovery_state *cache = &hdev->discovery;
64 struct inquiry_entry *e;
65
66 hci_dev_lock(hdev);
67
68 list_for_each_entry(e, &cache->all, all) {
69 struct inquiry_data *data = &e->data;
70 seq_printf(f, "%pMR %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n",
71 &data->bdaddr,
72 data->pscan_rep_mode, data->pscan_period_mode,
73 data->pscan_mode, data->dev_class[2],
74 data->dev_class[1], data->dev_class[0],
75 __le16_to_cpu(data->clock_offset),
76 data->rssi, data->ssp_mode, e->timestamp);
77 }
78
79 hci_dev_unlock(hdev);
80
81 return 0;
82}
83
84static int inquiry_cache_open(struct inode *inode, struct file *file)
85{
86 return single_open(file, inquiry_cache_show, inode->i_private);
87}
88
89static const struct file_operations inquiry_cache_fops = {
90 .open = inquiry_cache_open,
91 .read = seq_read,
92 .llseek = seq_lseek,
93 .release = single_release,
94};
95
58/* ---- HCI requests ---- */ 96/* ---- HCI requests ---- */
59 97
60static void hci_req_sync_complete(struct hci_dev *hdev, u8 result) 98static void hci_req_sync_complete(struct hci_dev *hdev, u8 result)
@@ -734,7 +772,22 @@ static int __hci_init(struct hci_dev *hdev)
734 if (err < 0) 772 if (err < 0)
735 return err; 773 return err;
736 774
737 return __hci_req_sync(hdev, hci_init4_req, 0, HCI_INIT_TIMEOUT); 775 err = __hci_req_sync(hdev, hci_init4_req, 0, HCI_INIT_TIMEOUT);
776 if (err < 0)
777 return err;
778
779 /* Only create debugfs entries during the initial setup
780 * phase and not every time the controller gets powered on.
781 */
782 if (!test_bit(HCI_SETUP, &hdev->dev_flags))
783 return 0;
784
785 if (lmp_bredr_capable(hdev)) {
786 debugfs_create_file("inquiry_cache", 0444, hdev->debugfs,
787 hdev, &inquiry_cache_fops);
788 }
789
790 return 0;
738} 791}
739 792
740static void hci_scan_req(struct hci_request *req, unsigned long opt) 793static void hci_scan_req(struct hci_request *req, unsigned long opt)
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index edf623a29043..65ecb9e6fdb7 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -396,42 +396,6 @@ static struct device_type bt_host = {
396 .release = bt_host_release, 396 .release = bt_host_release,
397}; 397};
398 398
399static int inquiry_cache_show(struct seq_file *f, void *p)
400{
401 struct hci_dev *hdev = f->private;
402 struct discovery_state *cache = &hdev->discovery;
403 struct inquiry_entry *e;
404
405 hci_dev_lock(hdev);
406
407 list_for_each_entry(e, &cache->all, all) {
408 struct inquiry_data *data = &e->data;
409 seq_printf(f, "%pMR %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n",
410 &data->bdaddr,
411 data->pscan_rep_mode, data->pscan_period_mode,
412 data->pscan_mode, data->dev_class[2],
413 data->dev_class[1], data->dev_class[0],
414 __le16_to_cpu(data->clock_offset),
415 data->rssi, data->ssp_mode, e->timestamp);
416 }
417
418 hci_dev_unlock(hdev);
419
420 return 0;
421}
422
423static int inquiry_cache_open(struct inode *inode, struct file *file)
424{
425 return single_open(file, inquiry_cache_show, inode->i_private);
426}
427
428static const struct file_operations inquiry_cache_fops = {
429 .open = inquiry_cache_open,
430 .read = seq_read,
431 .llseek = seq_lseek,
432 .release = single_release,
433};
434
435static int blacklist_show(struct seq_file *f, void *p) 399static int blacklist_show(struct seq_file *f, void *p)
436{ 400{
437 struct hci_dev *hdev = f->private; 401 struct hci_dev *hdev = f->private;
@@ -562,9 +526,6 @@ int hci_add_sysfs(struct hci_dev *hdev)
562 if (!hdev->debugfs) 526 if (!hdev->debugfs)
563 return 0; 527 return 0;
564 528
565 debugfs_create_file("inquiry_cache", 0444, hdev->debugfs,
566 hdev, &inquiry_cache_fops);
567
568 debugfs_create_file("blacklist", 0444, hdev->debugfs, 529 debugfs_create_file("blacklist", 0444, hdev->debugfs,
569 hdev, &blacklist_fops); 530 hdev, &blacklist_fops);
570 531