aboutsummaryrefslogtreecommitdiffstats
path: root/bluetooth-class-fun.patch
blob: ebbc1c03d386b789e26786b793475dc142730a8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
Subject: bluetooth class fun

---
 include/net/bluetooth/bluetooth.h |    2 ++
 net/bluetooth/hci_sysfs.c         |   10 ++++++++++
 net/bluetooth/sco.c               |   35 +++++++++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+)

--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -177,4 +177,6 @@ extern void bt_sysfs_cleanup(void);
 
 extern struct class *bt_class;
 
+extern struct dentry *bt_debug;
+
 #endif /* __BLUETOOTH_H */
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -2,6 +2,7 @@
 
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/debugfs.h>
 
 #include <linux/platform_device.h>
 
@@ -264,6 +265,9 @@ static struct device_attribute *conn_att
 struct class *bt_class = NULL;
 EXPORT_SYMBOL_GPL(bt_class);
 
+struct dentry *bt_debug;
+EXPORT_SYMBOL_GPL(bt_debug);
+
 static struct bus_type bt_bus = {
 	.name	= "bluetooth",
 };
@@ -423,6 +427,10 @@ int __init bt_sysfs_init(void)
 	if (err < 0)
 		goto out_bus;
 
+	bt_debug = debugfs_create_dir("bluetooth", NULL);
+	if (!bt_debug)
+		goto out_class;
+
 	bt_class = class_create(THIS_MODULE, "bluetooth");
 	if (IS_ERR(bt_class)) {
 		err = PTR_ERR(bt_class);
@@ -451,6 +459,8 @@ void bt_sysfs_cleanup(void)
 
 	class_destroy(bt_class);
 
+	debugfs_remove(bt_debug);
+
 	bus_unregister(&bt_bus);
 
 	platform_device_unregister(bt_platform);
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -909,6 +909,38 @@ static ssize_t sco_sysfs_show(struct cla
 
 static CLASS_ATTR(sco, S_IRUGO, sco_sysfs_show, NULL);
 
+static int sco_open(struct inode *inode, struct file *file)
+{
+	return 0;
+}
+
+static int sco_release(struct inode *inode, struct file *file)
+{
+	return 0;
+}
+
+static ssize_t sco_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
+{
+	read_lock_bh(&sco_sk_list.lock);
+
+	sk_for_each(sk, node, &sco_sk_list.head) {
+		str += sprintf(str, "%s %s %d\n",
+				batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
+				sk->sk_state);
+	}
+
+	read_unlock_bh(&sco_sk_list.lock);
+}
+
+static const struct file_operations sco_file_ops = {
+	.owner		= THIS_MODULE,
+	.open		= sco_open,
+	.llseek		= no_llseek,
+	.read		= sco_read,
+	.release	= sco_close,
+};
+
+
 static const struct proto_ops sco_sock_ops = {
 	.family		= PF_BLUETOOTH,
 	.owner		= THIS_MODULE,
@@ -965,6 +997,9 @@ static int __init sco_init(void)
 		goto error;
 	}
 
+	sco_debug = debugfs_create_file("sco", S_IRUGO, bt_debug, NULL,
+					&sco_fops);
+
 	if (class_create_file(bt_class, &class_attr_sco) < 0)
 		BT_ERR("Failed to create SCO info file");