aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-03-21 00:27:45 -0400
committerMarcel Holtmann <marcel@holtmann.org>2010-03-21 00:49:35 -0400
commitaef7d97cc604309b66f6f45cce02cd734934cd4e (patch)
treeb21aae56f9a5de0bbabe881d597a4dc790ff97c8 /net
parent101545f6fef4a0a3ea8daf0b5b880df2c6a92a69 (diff)
Bluetooth: Convert debug files to actually use debugfs instead of sysfs
Some of the debug files ended up wrongly in sysfs, because at that point of time, debugfs didn't exist. Convert these files to use debugfs and also seq_file. This patch converts all of these files at once and then removes the exported symbol for the Bluetooth sysfs class. Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_sysfs.c3
-rw-r--r--net/bluetooth/l2cap.c51
-rw-r--r--net/bluetooth/rfcomm/core.c52
-rw-r--r--net/bluetooth/rfcomm/sock.c47
-rw-r--r--net/bluetooth/sco.c47
5 files changed, 113 insertions, 87 deletions
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index cafb55b0cea5..05fd125f74fe 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -8,8 +8,7 @@
8#include <net/bluetooth/bluetooth.h> 8#include <net/bluetooth/bluetooth.h>
9#include <net/bluetooth/hci_core.h> 9#include <net/bluetooth/hci_core.h>
10 10
11struct class *bt_class = NULL; 11static struct class *bt_class;
12EXPORT_SYMBOL_GPL(bt_class);
13 12
14struct dentry *bt_debugfs = NULL; 13struct dentry *bt_debugfs = NULL;
15EXPORT_SYMBOL_GPL(bt_debugfs); 14EXPORT_SYMBOL_GPL(bt_debugfs);
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 27551820741e..43e17f7d7ecd 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -40,6 +40,8 @@
40#include <linux/skbuff.h> 40#include <linux/skbuff.h>
41#include <linux/list.h> 41#include <linux/list.h>
42#include <linux/device.h> 42#include <linux/device.h>
43#include <linux/debugfs.h>
44#include <linux/seq_file.h>
43#include <linux/uaccess.h> 45#include <linux/uaccess.h>
44#include <linux/crc16.h> 46#include <linux/crc16.h>
45#include <net/sock.h> 47#include <net/sock.h>
@@ -3937,39 +3939,42 @@ drop:
3937 return 0; 3939 return 0;
3938} 3940}
3939 3941
3940static ssize_t l2cap_sysfs_show(struct class *dev, 3942static int l2cap_debugfs_show(struct seq_file *f, void *p)
3941 struct class_attribute *attr,
3942 char *buf)
3943{ 3943{
3944 struct sock *sk; 3944 struct sock *sk;
3945 struct hlist_node *node; 3945 struct hlist_node *node;
3946 char *str = buf;
3947 int size = PAGE_SIZE;
3948 3946
3949 read_lock_bh(&l2cap_sk_list.lock); 3947 read_lock_bh(&l2cap_sk_list.lock);
3950 3948
3951 sk_for_each(sk, node, &l2cap_sk_list.head) { 3949 sk_for_each(sk, node, &l2cap_sk_list.head) {
3952 struct l2cap_pinfo *pi = l2cap_pi(sk); 3950 struct l2cap_pinfo *pi = l2cap_pi(sk);
3953 int len;
3954
3955 len = snprintf(str, size, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d\n",
3956 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
3957 sk->sk_state, __le16_to_cpu(pi->psm), pi->scid,
3958 pi->dcid, pi->imtu, pi->omtu, pi->sec_level);
3959
3960 size -= len;
3961 if (size <= 0)
3962 break;
3963 3951
3964 str += len; 3952 seq_printf(f, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d\n",
3953 batostr(&bt_sk(sk)->src),
3954 batostr(&bt_sk(sk)->dst),
3955 sk->sk_state, __le16_to_cpu(pi->psm),
3956 pi->scid, pi->dcid,
3957 pi->imtu, pi->omtu, pi->sec_level);
3965 } 3958 }
3966 3959
3967 read_unlock_bh(&l2cap_sk_list.lock); 3960 read_unlock_bh(&l2cap_sk_list.lock);
3968 3961
3969 return str - buf; 3962 return 0;
3970} 3963}
3971 3964
3972static CLASS_ATTR(l2cap, S_IRUGO, l2cap_sysfs_show, NULL); 3965static int l2cap_debugfs_open(struct inode *inode, struct file *file)
3966{
3967 return single_open(file, l2cap_debugfs_show, inode->i_private);
3968}
3969
3970static const struct file_operations l2cap_debugfs_fops = {
3971 .open = l2cap_debugfs_open,
3972 .read = seq_read,
3973 .llseek = seq_lseek,
3974 .release = single_release,
3975};
3976
3977static struct dentry *l2cap_debugfs;
3973 3978
3974static const struct proto_ops l2cap_sock_ops = { 3979static const struct proto_ops l2cap_sock_ops = {
3975 .family = PF_BLUETOOTH, 3980 .family = PF_BLUETOOTH,
@@ -4029,8 +4034,12 @@ static int __init l2cap_init(void)
4029 goto error; 4034 goto error;
4030 } 4035 }
4031 4036
4032 if (class_create_file(bt_class, &class_attr_l2cap) < 0) 4037 if (bt_debugfs) {
4033 BT_ERR("Failed to create L2CAP info file"); 4038 l2cap_debugfs = debugfs_create_file("l2cap", 0444,
4039 bt_debugfs, NULL, &l2cap_debugfs_fops);
4040 if (!l2cap_debugfs)
4041 BT_ERR("Failed to create L2CAP debug file");
4042 }
4034 4043
4035 BT_INFO("L2CAP ver %s", VERSION); 4044 BT_INFO("L2CAP ver %s", VERSION);
4036 BT_INFO("L2CAP socket layer initialized"); 4045 BT_INFO("L2CAP socket layer initialized");
@@ -4044,7 +4053,7 @@ error:
4044 4053
4045static void __exit l2cap_exit(void) 4054static void __exit l2cap_exit(void)
4046{ 4055{
4047 class_remove_file(bt_class, &class_attr_l2cap); 4056 debugfs_remove(l2cap_debugfs);
4048 4057
4049 if (bt_sock_unregister(BTPROTO_L2CAP) < 0) 4058 if (bt_sock_unregister(BTPROTO_L2CAP) < 0)
4050 BT_ERR("L2CAP socket unregistration failed"); 4059 BT_ERR("L2CAP socket unregistration failed");
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index cf164073269d..13f114e8b0f9 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -33,6 +33,8 @@
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/wait.h> 34#include <linux/wait.h>
35#include <linux/device.h> 35#include <linux/device.h>
36#include <linux/debugfs.h>
37#include <linux/seq_file.h>
36#include <linux/net.h> 38#include <linux/net.h>
37#include <linux/mutex.h> 39#include <linux/mutex.h>
38#include <linux/kthread.h> 40#include <linux/kthread.h>
@@ -2098,14 +2100,10 @@ static struct hci_cb rfcomm_cb = {
2098 .security_cfm = rfcomm_security_cfm 2100 .security_cfm = rfcomm_security_cfm
2099}; 2101};
2100 2102
2101static ssize_t rfcomm_dlc_sysfs_show(struct class *dev, 2103static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x)
2102 struct class_attribute *attr,
2103 char *buf)
2104{ 2104{
2105 struct rfcomm_session *s; 2105 struct rfcomm_session *s;
2106 struct list_head *pp, *p; 2106 struct list_head *pp, *p;
2107 char *str = buf;
2108 int size = PAGE_SIZE;
2109 2107
2110 rfcomm_lock(); 2108 rfcomm_lock();
2111 2109
@@ -2114,29 +2112,33 @@ static ssize_t rfcomm_dlc_sysfs_show(struct class *dev,
2114 list_for_each(pp, &s->dlcs) { 2112 list_for_each(pp, &s->dlcs) {
2115 struct sock *sk = s->sock->sk; 2113 struct sock *sk = s->sock->sk;
2116 struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list); 2114 struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list);
2117 int len;
2118 2115
2119 len = snprintf(str, size, "%s %s %ld %d %d %d %d\n", 2116 seq_printf(f, "%s %s %ld %d %d %d %d\n",
2120 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), 2117 batostr(&bt_sk(sk)->src),
2121 d->state, d->dlci, d->mtu, d->rx_credits, d->tx_credits); 2118 batostr(&bt_sk(sk)->dst),
2122 2119 d->state, d->dlci, d->mtu,
2123 size -= len; 2120 d->rx_credits, d->tx_credits);
2124 if (size <= 0)
2125 break;
2126
2127 str += len;
2128 } 2121 }
2129
2130 if (size <= 0)
2131 break;
2132 } 2122 }
2133 2123
2134 rfcomm_unlock(); 2124 rfcomm_unlock();
2135 2125
2136 return (str - buf); 2126 return 0;
2127}
2128
2129static int rfcomm_dlc_debugfs_open(struct inode *inode, struct file *file)
2130{
2131 return single_open(file, rfcomm_dlc_debugfs_show, inode->i_private);
2137} 2132}
2138 2133
2139static CLASS_ATTR(rfcomm_dlc, S_IRUGO, rfcomm_dlc_sysfs_show, NULL); 2134static const struct file_operations rfcomm_dlc_debugfs_fops = {
2135 .open = rfcomm_dlc_debugfs_open,
2136 .read = seq_read,
2137 .llseek = seq_lseek,
2138 .release = single_release,
2139};
2140
2141static struct dentry *rfcomm_dlc_debugfs;
2140 2142
2141/* ---- Initialization ---- */ 2143/* ---- Initialization ---- */
2142static int __init rfcomm_init(void) 2144static int __init rfcomm_init(void)
@@ -2153,8 +2155,12 @@ static int __init rfcomm_init(void)
2153 goto unregister; 2155 goto unregister;
2154 } 2156 }
2155 2157
2156 if (class_create_file(bt_class, &class_attr_rfcomm_dlc) < 0) 2158 if (bt_debugfs) {
2157 BT_ERR("Failed to create RFCOMM info file"); 2159 rfcomm_dlc_debugfs = debugfs_create_file("rfcomm_dlc", 0444,
2160 bt_debugfs, NULL, &rfcomm_dlc_debugfs_fops);
2161 if (!rfcomm_dlc_debugfs)
2162 BT_ERR("Failed to create RFCOMM debug file");
2163 }
2158 2164
2159 err = rfcomm_init_ttys(); 2165 err = rfcomm_init_ttys();
2160 if (err < 0) 2166 if (err < 0)
@@ -2182,7 +2188,7 @@ unregister:
2182 2188
2183static void __exit rfcomm_exit(void) 2189static void __exit rfcomm_exit(void)
2184{ 2190{
2185 class_remove_file(bt_class, &class_attr_rfcomm_dlc); 2191 debugfs_remove(rfcomm_dlc_debugfs);
2186 2192
2187 hci_unregister_cb(&rfcomm_cb); 2193 hci_unregister_cb(&rfcomm_cb);
2188 2194
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 8d0ee0b8a6b6..7f439765403d 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -40,6 +40,8 @@
40#include <linux/skbuff.h> 40#include <linux/skbuff.h>
41#include <linux/list.h> 41#include <linux/list.h>
42#include <linux/device.h> 42#include <linux/device.h>
43#include <linux/debugfs.h>
44#include <linux/seq_file.h>
43#include <net/sock.h> 45#include <net/sock.h>
44 46
45#include <asm/system.h> 47#include <asm/system.h>
@@ -1061,37 +1063,38 @@ done:
1061 return result; 1063 return result;
1062} 1064}
1063 1065
1064static ssize_t rfcomm_sock_sysfs_show(struct class *dev, 1066static int rfcomm_sock_debugfs_show(struct seq_file *f, void *p)
1065 struct class_attribute *attr,
1066 char *buf)
1067{ 1067{
1068 struct sock *sk; 1068 struct sock *sk;
1069 struct hlist_node *node; 1069 struct hlist_node *node;
1070 char *str = buf;
1071 int size = PAGE_SIZE;
1072 1070
1073 read_lock_bh(&rfcomm_sk_list.lock); 1071 read_lock_bh(&rfcomm_sk_list.lock);
1074 1072
1075 sk_for_each(sk, node, &rfcomm_sk_list.head) { 1073 sk_for_each(sk, node, &rfcomm_sk_list.head) {
1076 int len; 1074 seq_printf(f, "%s %s %d %d\n",
1077 1075 batostr(&bt_sk(sk)->src),
1078 len = snprintf(str, size, "%s %s %d %d\n", 1076 batostr(&bt_sk(sk)->dst),
1079 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
1080 sk->sk_state, rfcomm_pi(sk)->channel); 1077 sk->sk_state, rfcomm_pi(sk)->channel);
1081
1082 size -= len;
1083 if (size <= 0)
1084 break;
1085
1086 str += len;
1087 } 1078 }
1088 1079
1089 read_unlock_bh(&rfcomm_sk_list.lock); 1080 read_unlock_bh(&rfcomm_sk_list.lock);
1090 1081
1091 return (str - buf); 1082 return 0;
1092} 1083}
1093 1084
1094static CLASS_ATTR(rfcomm, S_IRUGO, rfcomm_sock_sysfs_show, NULL); 1085static int rfcomm_sock_debugfs_open(struct inode *inode, struct file *file)
1086{
1087 return single_open(file, rfcomm_sock_debugfs_show, inode->i_private);
1088}
1089
1090static const struct file_operations rfcomm_sock_debugfs_fops = {
1091 .open = rfcomm_sock_debugfs_open,
1092 .read = seq_read,
1093 .llseek = seq_lseek,
1094 .release = single_release,
1095};
1096
1097static struct dentry *rfcomm_sock_debugfs;
1095 1098
1096static const struct proto_ops rfcomm_sock_ops = { 1099static const struct proto_ops rfcomm_sock_ops = {
1097 .family = PF_BLUETOOTH, 1100 .family = PF_BLUETOOTH,
@@ -1131,8 +1134,12 @@ int __init rfcomm_init_sockets(void)
1131 if (err < 0) 1134 if (err < 0)
1132 goto error; 1135 goto error;
1133 1136
1134 if (class_create_file(bt_class, &class_attr_rfcomm) < 0) 1137 if (bt_debugfs) {
1135 BT_ERR("Failed to create RFCOMM info file"); 1138 rfcomm_sock_debugfs = debugfs_create_file("rfcomm", 0444,
1139 bt_debugfs, NULL, &rfcomm_sock_debugfs_fops);
1140 if (!rfcomm_sock_debugfs)
1141 BT_ERR("Failed to create RFCOMM debug file");
1142 }
1136 1143
1137 BT_INFO("RFCOMM socket layer initialized"); 1144 BT_INFO("RFCOMM socket layer initialized");
1138 1145
@@ -1146,7 +1153,7 @@ error:
1146 1153
1147void rfcomm_cleanup_sockets(void) 1154void rfcomm_cleanup_sockets(void)
1148{ 1155{
1149 class_remove_file(bt_class, &class_attr_rfcomm); 1156 debugfs_remove(rfcomm_sock_debugfs);
1150 1157
1151 if (bt_sock_unregister(BTPROTO_RFCOMM) < 0) 1158 if (bt_sock_unregister(BTPROTO_RFCOMM) < 0)
1152 BT_ERR("RFCOMM socket layer unregistration failed"); 1159 BT_ERR("RFCOMM socket layer unregistration failed");
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 967a75175c66..e5b16b76b22e 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -38,6 +38,8 @@
38#include <linux/socket.h> 38#include <linux/socket.h>
39#include <linux/skbuff.h> 39#include <linux/skbuff.h>
40#include <linux/device.h> 40#include <linux/device.h>
41#include <linux/debugfs.h>
42#include <linux/seq_file.h>
41#include <linux/list.h> 43#include <linux/list.h>
42#include <net/sock.h> 44#include <net/sock.h>
43 45
@@ -953,37 +955,36 @@ drop:
953 return 0; 955 return 0;
954} 956}
955 957
956static ssize_t sco_sysfs_show(struct class *dev, 958static int sco_debugfs_show(struct seq_file *f, void *p)
957 struct class_attribute *attr,
958 char *buf)
959{ 959{
960 struct sock *sk; 960 struct sock *sk;
961 struct hlist_node *node; 961 struct hlist_node *node;
962 char *str = buf;
963 int size = PAGE_SIZE;
964 962
965 read_lock_bh(&sco_sk_list.lock); 963 read_lock_bh(&sco_sk_list.lock);
966 964
967 sk_for_each(sk, node, &sco_sk_list.head) { 965 sk_for_each(sk, node, &sco_sk_list.head) {
968 int len; 966 seq_printf(f, "%s %s %d\n", batostr(&bt_sk(sk)->src),
969 967 batostr(&bt_sk(sk)->dst), sk->sk_state);
970 len = snprintf(str, size, "%s %s %d\n",
971 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
972 sk->sk_state);
973
974 size -= len;
975 if (size <= 0)
976 break;
977
978 str += len;
979 } 968 }
980 969
981 read_unlock_bh(&sco_sk_list.lock); 970 read_unlock_bh(&sco_sk_list.lock);
982 971
983 return (str - buf); 972 return 0;
984} 973}
985 974
986static CLASS_ATTR(sco, S_IRUGO, sco_sysfs_show, NULL); 975static int sco_debugfs_open(struct inode *inode, struct file *file)
976{
977 return single_open(file, sco_debugfs_show, inode->i_private);
978}
979
980static const struct file_operations sco_debugfs_fops = {
981 .open = sco_debugfs_open,
982 .read = seq_read,
983 .llseek = seq_lseek,
984 .release = single_release,
985};
986
987static struct dentry *sco_debugfs;
987 988
988static const struct proto_ops sco_sock_ops = { 989static const struct proto_ops sco_sock_ops = {
989 .family = PF_BLUETOOTH, 990 .family = PF_BLUETOOTH,
@@ -1041,8 +1042,12 @@ static int __init sco_init(void)
1041 goto error; 1042 goto error;
1042 } 1043 }
1043 1044
1044 if (class_create_file(bt_class, &class_attr_sco) < 0) 1045 if (bt_debugfs) {
1045 BT_ERR("Failed to create SCO info file"); 1046 sco_debugfs = debugfs_create_file("sco", 0444,
1047 bt_debugfs, NULL, &sco_debugfs_fops);
1048 if (!sco_debugfs)
1049 BT_ERR("Failed to create SCO debug file");
1050 }
1046 1051
1047 BT_INFO("SCO (Voice Link) ver %s", VERSION); 1052 BT_INFO("SCO (Voice Link) ver %s", VERSION);
1048 BT_INFO("SCO socket layer initialized"); 1053 BT_INFO("SCO socket layer initialized");
@@ -1056,7 +1061,7 @@ error:
1056 1061
1057static void __exit sco_exit(void) 1062static void __exit sco_exit(void)
1058{ 1063{
1059 class_remove_file(bt_class, &class_attr_sco); 1064 debugfs_remove(sco_debugfs);
1060 1065
1061 if (bt_sock_unregister(BTPROTO_SCO) < 0) 1066 if (bt_sock_unregister(BTPROTO_SCO) < 0)
1062 BT_ERR("SCO socket unregistration failed"); 1067 BT_ERR("SCO socket unregistration failed");