aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2013-10-17 20:24:15 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2013-10-18 03:44:35 -0400
commit47219839b43dec0520ef1ec72122186b3aa3de97 (patch)
tree591123aa251541bb682850cf2051bb8600953cda
parent70afe0b8566769567d2eac6395c1cf68ed62bed3 (diff)
Bluetooth: Move uuids debugfs entry creation into hci_core.c
The uuids debugfs should only be created together with the other entries after the setup procedure has been finished. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r--net/bluetooth/hci_core.c40
-rw-r--r--net/bluetooth/hci_sysfs.c46
2 files changed, 40 insertions, 46 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index de59bb17f8cd..0fb9f6d1f60f 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -29,6 +29,7 @@
29#include <linux/idr.h> 29#include <linux/idr.h>
30#include <linux/rfkill.h> 30#include <linux/rfkill.h>
31#include <linux/debugfs.h> 31#include <linux/debugfs.h>
32#include <asm/unaligned.h>
32 33
33#include <net/bluetooth/bluetooth.h> 34#include <net/bluetooth/bluetooth.h>
34#include <net/bluetooth/hci_core.h> 35#include <net/bluetooth/hci_core.h>
@@ -82,6 +83,43 @@ static const struct file_operations blacklist_fops = {
82 .release = single_release, 83 .release = single_release,
83}; 84};
84 85
86static int uuids_show(struct seq_file *f, void *p)
87{
88 struct hci_dev *hdev = f->private;
89 struct bt_uuid *uuid;
90
91 hci_dev_lock(hdev);
92 list_for_each_entry(uuid, &hdev->uuids, list) {
93 u32 data0, data5;
94 u16 data1, data2, data3, data4;
95
96 data5 = get_unaligned_le32(uuid);
97 data4 = get_unaligned_le16(uuid + 4);
98 data3 = get_unaligned_le16(uuid + 6);
99 data2 = get_unaligned_le16(uuid + 8);
100 data1 = get_unaligned_le16(uuid + 10);
101 data0 = get_unaligned_le32(uuid + 12);
102
103 seq_printf(f, "%.8x-%.4x-%.4x-%.4x-%.4x%.8x\n",
104 data0, data1, data2, data3, data4, data5);
105 }
106 hci_dev_unlock(hdev);
107
108 return 0;
109}
110
111static int uuids_open(struct inode *inode, struct file *file)
112{
113 return single_open(file, uuids_show, inode->i_private);
114}
115
116static const struct file_operations uuids_fops = {
117 .open = uuids_open,
118 .read = seq_read,
119 .llseek = seq_lseek,
120 .release = single_release,
121};
122
85static int inquiry_cache_show(struct seq_file *f, void *p) 123static int inquiry_cache_show(struct seq_file *f, void *p)
86{ 124{
87 struct hci_dev *hdev = f->private; 125 struct hci_dev *hdev = f->private;
@@ -872,6 +910,8 @@ static int __hci_init(struct hci_dev *hdev)
872 debugfs_create_file("blacklist", 0444, hdev->debugfs, hdev, 910 debugfs_create_file("blacklist", 0444, hdev->debugfs, hdev,
873 &blacklist_fops); 911 &blacklist_fops);
874 912
913 debugfs_create_file("uuids", 0444, hdev->debugfs, hdev, &uuids_fops);
914
875 if (lmp_bredr_capable(hdev)) { 915 if (lmp_bredr_capable(hdev)) {
876 debugfs_create_file("inquiry_cache", 0444, hdev->debugfs, 916 debugfs_create_file("inquiry_cache", 0444, hdev->debugfs,
877 hdev, &inquiry_cache_fops); 917 hdev, &inquiry_cache_fops);
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 863e313d1fc9..077037e7f912 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -2,7 +2,6 @@
2 2
3#include <linux/debugfs.h> 3#include <linux/debugfs.h>
4#include <linux/module.h> 4#include <linux/module.h>
5#include <asm/unaligned.h>
6 5
7#include <net/bluetooth/bluetooth.h> 6#include <net/bluetooth/bluetooth.h>
8#include <net/bluetooth/hci_core.h> 7#include <net/bluetooth/hci_core.h>
@@ -396,49 +395,6 @@ static struct device_type bt_host = {
396 .release = bt_host_release, 395 .release = bt_host_release,
397}; 396};
398 397
399static void print_bt_uuid(struct seq_file *f, u8 *uuid)
400{
401 u32 data0, data5;
402 u16 data1, data2, data3, data4;
403
404 data5 = get_unaligned_le32(uuid);
405 data4 = get_unaligned_le16(uuid + 4);
406 data3 = get_unaligned_le16(uuid + 6);
407 data2 = get_unaligned_le16(uuid + 8);
408 data1 = get_unaligned_le16(uuid + 10);
409 data0 = get_unaligned_le32(uuid + 12);
410
411 seq_printf(f, "%.8x-%.4x-%.4x-%.4x-%.4x%.8x\n",
412 data0, data1, data2, data3, data4, data5);
413}
414
415static int uuids_show(struct seq_file *f, void *p)
416{
417 struct hci_dev *hdev = f->private;
418 struct bt_uuid *uuid;
419
420 hci_dev_lock(hdev);
421
422 list_for_each_entry(uuid, &hdev->uuids, list)
423 print_bt_uuid(f, uuid->uuid);
424
425 hci_dev_unlock(hdev);
426
427 return 0;
428}
429
430static int uuids_open(struct inode *inode, struct file *file)
431{
432 return single_open(file, uuids_show, inode->i_private);
433}
434
435static const struct file_operations uuids_fops = {
436 .open = uuids_open,
437 .read = seq_read,
438 .llseek = seq_lseek,
439 .release = single_release,
440};
441
442void hci_init_sysfs(struct hci_dev *hdev) 398void hci_init_sysfs(struct hci_dev *hdev)
443{ 399{
444 struct device *dev = &hdev->dev; 400 struct device *dev = &hdev->dev;
@@ -470,8 +426,6 @@ int hci_add_sysfs(struct hci_dev *hdev)
470 if (!hdev->debugfs) 426 if (!hdev->debugfs)
471 return 0; 427 return 0;
472 428
473 debugfs_create_file("uuids", 0444, hdev->debugfs, hdev, &uuids_fops);
474
475 return 0; 429 return 0;
476} 430}
477 431