aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/hci_sysfs.c3
-rw-r--r--net/bluetooth/l2cap.c51
-rw-r--r--net/bluetooth/rfcomm/core.c41
-rw-r--r--net/bluetooth/rfcomm/sock.c41
-rw-r--r--net/bluetooth/sco.c41
5 files changed, 124 insertions, 53 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 4db7ae2fe07d..99d68c34e4f1 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>
@@ -1000,7 +1002,8 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al
1000 1002
1001 BT_DBG("sk %p", sk); 1003 BT_DBG("sk %p", sk);
1002 1004
1003 if (!addr || addr->sa_family != AF_BLUETOOTH) 1005 if (!addr || alen < sizeof(addr->sa_family) ||
1006 addr->sa_family != AF_BLUETOOTH)
1004 return -EINVAL; 1007 return -EINVAL;
1005 1008
1006 memset(&la, 0, sizeof(la)); 1009 memset(&la, 0, sizeof(la));
@@ -2830,6 +2833,11 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
2830 int len = cmd->len - sizeof(*rsp); 2833 int len = cmd->len - sizeof(*rsp);
2831 char req[64]; 2834 char req[64];
2832 2835
2836 if (len > sizeof(req) - sizeof(struct l2cap_conf_req)) {
2837 l2cap_send_disconn_req(conn, sk);
2838 goto done;
2839 }
2840
2833 /* throw out any old stored conf requests */ 2841 /* throw out any old stored conf requests */
2834 result = L2CAP_CONF_SUCCESS; 2842 result = L2CAP_CONF_SUCCESS;
2835 len = l2cap_parse_conf_rsp(sk, rsp->data, 2843 len = l2cap_parse_conf_rsp(sk, rsp->data,
@@ -3937,31 +3945,42 @@ drop:
3937 return 0; 3945 return 0;
3938} 3946}
3939 3947
3940static ssize_t l2cap_sysfs_show(struct class *dev, 3948static int l2cap_debugfs_show(struct seq_file *f, void *p)
3941 struct class_attribute *attr,
3942 char *buf)
3943{ 3949{
3944 struct sock *sk; 3950 struct sock *sk;
3945 struct hlist_node *node; 3951 struct hlist_node *node;
3946 char *str = buf;
3947 3952
3948 read_lock_bh(&l2cap_sk_list.lock); 3953 read_lock_bh(&l2cap_sk_list.lock);
3949 3954
3950 sk_for_each(sk, node, &l2cap_sk_list.head) { 3955 sk_for_each(sk, node, &l2cap_sk_list.head) {
3951 struct l2cap_pinfo *pi = l2cap_pi(sk); 3956 struct l2cap_pinfo *pi = l2cap_pi(sk);
3952 3957
3953 str += sprintf(str, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d\n", 3958 seq_printf(f, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d\n",
3954 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), 3959 batostr(&bt_sk(sk)->src),
3955 sk->sk_state, __le16_to_cpu(pi->psm), pi->scid, 3960 batostr(&bt_sk(sk)->dst),
3956 pi->dcid, pi->imtu, pi->omtu, pi->sec_level); 3961 sk->sk_state, __le16_to_cpu(pi->psm),
3962 pi->scid, pi->dcid,
3963 pi->imtu, pi->omtu, pi->sec_level);
3957 } 3964 }
3958 3965
3959 read_unlock_bh(&l2cap_sk_list.lock); 3966 read_unlock_bh(&l2cap_sk_list.lock);
3960 3967
3961 return str - buf; 3968 return 0;
3969}
3970
3971static int l2cap_debugfs_open(struct inode *inode, struct file *file)
3972{
3973 return single_open(file, l2cap_debugfs_show, inode->i_private);
3962} 3974}
3963 3975
3964static CLASS_ATTR(l2cap, S_IRUGO, l2cap_sysfs_show, NULL); 3976static const struct file_operations l2cap_debugfs_fops = {
3977 .open = l2cap_debugfs_open,
3978 .read = seq_read,
3979 .llseek = seq_lseek,
3980 .release = single_release,
3981};
3982
3983static struct dentry *l2cap_debugfs;
3965 3984
3966static const struct proto_ops l2cap_sock_ops = { 3985static const struct proto_ops l2cap_sock_ops = {
3967 .family = PF_BLUETOOTH, 3986 .family = PF_BLUETOOTH,
@@ -4021,8 +4040,12 @@ static int __init l2cap_init(void)
4021 goto error; 4040 goto error;
4022 } 4041 }
4023 4042
4024 if (class_create_file(bt_class, &class_attr_l2cap) < 0) 4043 if (bt_debugfs) {
4025 BT_ERR("Failed to create L2CAP info file"); 4044 l2cap_debugfs = debugfs_create_file("l2cap", 0444,
4045 bt_debugfs, NULL, &l2cap_debugfs_fops);
4046 if (!l2cap_debugfs)
4047 BT_ERR("Failed to create L2CAP debug file");
4048 }
4026 4049
4027 BT_INFO("L2CAP ver %s", VERSION); 4050 BT_INFO("L2CAP ver %s", VERSION);
4028 BT_INFO("L2CAP socket layer initialized"); 4051 BT_INFO("L2CAP socket layer initialized");
@@ -4036,7 +4059,7 @@ error:
4036 4059
4037static void __exit l2cap_exit(void) 4060static void __exit l2cap_exit(void)
4038{ 4061{
4039 class_remove_file(bt_class, &class_attr_l2cap); 4062 debugfs_remove(l2cap_debugfs);
4040 4063
4041 if (bt_sock_unregister(BTPROTO_L2CAP) < 0) 4064 if (bt_sock_unregister(BTPROTO_L2CAP) < 0)
4042 BT_ERR("L2CAP socket unregistration failed"); 4065 BT_ERR("L2CAP socket unregistration failed");
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index db8a68e1a5ba..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,13 +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 2107
2109 rfcomm_lock(); 2108 rfcomm_lock();
2110 2109
@@ -2114,18 +2113,32 @@ static ssize_t rfcomm_dlc_sysfs_show(struct class *dev,
2114 struct sock *sk = s->sock->sk; 2113 struct sock *sk = s->sock->sk;
2115 struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list); 2114 struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list);
2116 2115
2117 str += sprintf(str, "%s %s %ld %d %d %d %d\n", 2116 seq_printf(f, "%s %s %ld %d %d %d %d\n",
2118 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), 2117 batostr(&bt_sk(sk)->src),
2119 d->state, d->dlci, d->mtu, d->rx_credits, d->tx_credits); 2118 batostr(&bt_sk(sk)->dst),
2119 d->state, d->dlci, d->mtu,
2120 d->rx_credits, d->tx_credits);
2120 } 2121 }
2121 } 2122 }
2122 2123
2123 rfcomm_unlock(); 2124 rfcomm_unlock();
2124 2125
2125 return (str - buf); 2126 return 0;
2126} 2127}
2127 2128
2128static CLASS_ATTR(rfcomm_dlc, S_IRUGO, rfcomm_dlc_sysfs_show, NULL); 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);
2132}
2133
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;
2129 2142
2130/* ---- Initialization ---- */ 2143/* ---- Initialization ---- */
2131static int __init rfcomm_init(void) 2144static int __init rfcomm_init(void)
@@ -2142,8 +2155,12 @@ static int __init rfcomm_init(void)
2142 goto unregister; 2155 goto unregister;
2143 } 2156 }
2144 2157
2145 if (class_create_file(bt_class, &class_attr_rfcomm_dlc) < 0) 2158 if (bt_debugfs) {
2146 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 }
2147 2164
2148 err = rfcomm_init_ttys(); 2165 err = rfcomm_init_ttys();
2149 if (err < 0) 2166 if (err < 0)
@@ -2171,7 +2188,7 @@ unregister:
2171 2188
2172static void __exit rfcomm_exit(void) 2189static void __exit rfcomm_exit(void)
2173{ 2190{
2174 class_remove_file(bt_class, &class_attr_rfcomm_dlc); 2191 debugfs_remove(rfcomm_dlc_debugfs);
2175 2192
2176 hci_unregister_cb(&rfcomm_cb); 2193 hci_unregister_cb(&rfcomm_cb);
2177 2194
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
1064static ssize_t rfcomm_sock_sysfs_show(struct class *dev, 1067static 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
1085static CLASS_ATTR(rfcomm, S_IRUGO, rfcomm_sock_sysfs_show, NULL); 1086static 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
1091static 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
1098static struct dentry *rfcomm_sock_debugfs;
1086 1099
1087static const struct proto_ops rfcomm_sock_ops = { 1100static 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
1138void rfcomm_cleanup_sockets(void) 1155void 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");
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index f93b939539bc..ca6b2ad1c3fc 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
@@ -497,7 +499,8 @@ static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen
497 499
498 BT_DBG("sk %p", sk); 500 BT_DBG("sk %p", sk);
499 501
500 if (addr->sa_family != AF_BLUETOOTH || alen < sizeof(struct sockaddr_sco)) 502 if (alen < sizeof(struct sockaddr_sco) ||
503 addr->sa_family != AF_BLUETOOTH)
501 return -EINVAL; 504 return -EINVAL;
502 505
503 if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND) 506 if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND)
@@ -953,28 +956,36 @@ drop:
953 return 0; 956 return 0;
954} 957}
955 958
956static ssize_t sco_sysfs_show(struct class *dev, 959static int sco_debugfs_show(struct seq_file *f, void *p)
957 struct class_attribute *attr,
958 char *buf)
959{ 960{
960 struct sock *sk; 961 struct sock *sk;
961 struct hlist_node *node; 962 struct hlist_node *node;
962 char *str = buf;
963 963
964 read_lock_bh(&sco_sk_list.lock); 964 read_lock_bh(&sco_sk_list.lock);
965 965
966 sk_for_each(sk, node, &sco_sk_list.head) { 966 sk_for_each(sk, node, &sco_sk_list.head) {
967 str += sprintf(str, "%s %s %d\n", 967 seq_printf(f, "%s %s %d\n", batostr(&bt_sk(sk)->src),
968 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), 968 batostr(&bt_sk(sk)->dst), sk->sk_state);
969 sk->sk_state);
970 } 969 }
971 970
972 read_unlock_bh(&sco_sk_list.lock); 971 read_unlock_bh(&sco_sk_list.lock);
973 972
974 return (str - buf); 973 return 0;
975} 974}
976 975
977static CLASS_ATTR(sco, S_IRUGO, sco_sysfs_show, NULL); 976static int sco_debugfs_open(struct inode *inode, struct file *file)
977{
978 return single_open(file, sco_debugfs_show, inode->i_private);
979}
980
981static const struct file_operations sco_debugfs_fops = {
982 .open = sco_debugfs_open,
983 .read = seq_read,
984 .llseek = seq_lseek,
985 .release = single_release,
986};
987
988static struct dentry *sco_debugfs;
978 989
979static const struct proto_ops sco_sock_ops = { 990static const struct proto_ops sco_sock_ops = {
980 .family = PF_BLUETOOTH, 991 .family = PF_BLUETOOTH,
@@ -1032,8 +1043,12 @@ static int __init sco_init(void)
1032 goto error; 1043 goto error;
1033 } 1044 }
1034 1045
1035 if (class_create_file(bt_class, &class_attr_sco) < 0) 1046 if (bt_debugfs) {
1036 BT_ERR("Failed to create SCO info file"); 1047 sco_debugfs = debugfs_create_file("sco", 0444,
1048 bt_debugfs, NULL, &sco_debugfs_fops);
1049 if (!sco_debugfs)
1050 BT_ERR("Failed to create SCO debug file");
1051 }
1037 1052
1038 BT_INFO("SCO (Voice Link) ver %s", VERSION); 1053 BT_INFO("SCO (Voice Link) ver %s", VERSION);
1039 BT_INFO("SCO socket layer initialized"); 1054 BT_INFO("SCO socket layer initialized");
@@ -1047,7 +1062,7 @@ error:
1047 1062
1048static void __exit sco_exit(void) 1063static void __exit sco_exit(void)
1049{ 1064{
1050 class_remove_file(bt_class, &class_attr_sco); 1065 debugfs_remove(sco_debugfs);
1051 1066
1052 if (bt_sock_unregister(BTPROTO_SCO) < 0) 1067 if (bt_sock_unregister(BTPROTO_SCO) < 0)
1053 BT_ERR("SCO socket unregistration failed"); 1068 BT_ERR("SCO socket unregistration failed");