diff options
Diffstat (limited to 'net/bluetooth/rfcomm/sock.c')
-rw-r--r-- | net/bluetooth/rfcomm/sock.c | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index ca87d6ac6a20..8ed3c37684fa 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> |
@@ -395,7 +397,8 @@ static int rfcomm_sock_connect(struct socket *sock, struct sockaddr *addr, int a | |||
395 | 397 | ||
396 | BT_DBG("sk %p", sk); | 398 | BT_DBG("sk %p", sk); |
397 | 399 | ||
398 | if (addr->sa_family != AF_BLUETOOTH || alen < sizeof(struct sockaddr_rc)) | 400 | if (alen < sizeof(struct sockaddr_rc) || |
401 | addr->sa_family != AF_BLUETOOTH) | ||
399 | return -EINVAL; | 402 | return -EINVAL; |
400 | 403 | ||
401 | lock_sock(sk); | 404 | lock_sock(sk); |
@@ -1061,28 +1064,38 @@ done: | |||
1061 | return result; | 1064 | return result; |
1062 | } | 1065 | } |
1063 | 1066 | ||
1064 | static ssize_t rfcomm_sock_sysfs_show(struct class *dev, | 1067 | static int rfcomm_sock_debugfs_show(struct seq_file *f, void *p) |
1065 | struct class_attribute *attr, | ||
1066 | char *buf) | ||
1067 | { | 1068 | { |
1068 | struct sock *sk; | 1069 | struct sock *sk; |
1069 | struct hlist_node *node; | 1070 | struct hlist_node *node; |
1070 | char *str = buf; | ||
1071 | 1071 | ||
1072 | read_lock_bh(&rfcomm_sk_list.lock); | 1072 | read_lock_bh(&rfcomm_sk_list.lock); |
1073 | 1073 | ||
1074 | sk_for_each(sk, node, &rfcomm_sk_list.head) { | 1074 | sk_for_each(sk, node, &rfcomm_sk_list.head) { |
1075 | str += sprintf(str, "%s %s %d %d\n", | 1075 | seq_printf(f, "%s %s %d %d\n", |
1076 | batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), | 1076 | batostr(&bt_sk(sk)->src), |
1077 | batostr(&bt_sk(sk)->dst), | ||
1077 | sk->sk_state, rfcomm_pi(sk)->channel); | 1078 | sk->sk_state, rfcomm_pi(sk)->channel); |
1078 | } | 1079 | } |
1079 | 1080 | ||
1080 | read_unlock_bh(&rfcomm_sk_list.lock); | 1081 | read_unlock_bh(&rfcomm_sk_list.lock); |
1081 | 1082 | ||
1082 | return (str - buf); | 1083 | return 0; |
1083 | } | 1084 | } |
1084 | 1085 | ||
1085 | static CLASS_ATTR(rfcomm, S_IRUGO, rfcomm_sock_sysfs_show, NULL); | 1086 | static int rfcomm_sock_debugfs_open(struct inode *inode, struct file *file) |
1087 | { | ||
1088 | return single_open(file, rfcomm_sock_debugfs_show, inode->i_private); | ||
1089 | } | ||
1090 | |||
1091 | static const struct file_operations rfcomm_sock_debugfs_fops = { | ||
1092 | .open = rfcomm_sock_debugfs_open, | ||
1093 | .read = seq_read, | ||
1094 | .llseek = seq_lseek, | ||
1095 | .release = single_release, | ||
1096 | }; | ||
1097 | |||
1098 | static struct dentry *rfcomm_sock_debugfs; | ||
1086 | 1099 | ||
1087 | static const struct proto_ops rfcomm_sock_ops = { | 1100 | static const struct proto_ops rfcomm_sock_ops = { |
1088 | .family = PF_BLUETOOTH, | 1101 | .family = PF_BLUETOOTH, |
@@ -1122,8 +1135,12 @@ int __init rfcomm_init_sockets(void) | |||
1122 | if (err < 0) | 1135 | if (err < 0) |
1123 | goto error; | 1136 | goto error; |
1124 | 1137 | ||
1125 | if (class_create_file(bt_class, &class_attr_rfcomm) < 0) | 1138 | if (bt_debugfs) { |
1126 | BT_ERR("Failed to create RFCOMM info file"); | 1139 | rfcomm_sock_debugfs = debugfs_create_file("rfcomm", 0444, |
1140 | bt_debugfs, NULL, &rfcomm_sock_debugfs_fops); | ||
1141 | if (!rfcomm_sock_debugfs) | ||
1142 | BT_ERR("Failed to create RFCOMM debug file"); | ||
1143 | } | ||
1127 | 1144 | ||
1128 | BT_INFO("RFCOMM socket layer initialized"); | 1145 | BT_INFO("RFCOMM socket layer initialized"); |
1129 | 1146 | ||
@@ -1137,7 +1154,7 @@ error: | |||
1137 | 1154 | ||
1138 | void rfcomm_cleanup_sockets(void) | 1155 | void rfcomm_cleanup_sockets(void) |
1139 | { | 1156 | { |
1140 | class_remove_file(bt_class, &class_attr_rfcomm); | 1157 | debugfs_remove(rfcomm_sock_debugfs); |
1141 | 1158 | ||
1142 | if (bt_sock_unregister(BTPROTO_RFCOMM) < 0) | 1159 | if (bt_sock_unregister(BTPROTO_RFCOMM) < 0) |
1143 | BT_ERR("RFCOMM socket layer unregistration failed"); | 1160 | BT_ERR("RFCOMM socket layer unregistration failed"); |