diff options
Diffstat (limited to 'net/bluetooth/rfcomm/sock.c')
| -rw-r--r-- | net/bluetooth/rfcomm/sock.c | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index 8a20aaf1f231..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> |
| @@ -323,7 +325,8 @@ static struct sock *rfcomm_sock_alloc(struct net *net, struct socket *sock, int | |||
| 323 | return sk; | 325 | return sk; |
| 324 | } | 326 | } |
| 325 | 327 | ||
| 326 | static int rfcomm_sock_create(struct net *net, struct socket *sock, int protocol) | 328 | static int rfcomm_sock_create(struct net *net, struct socket *sock, |
| 329 | int protocol, int kern) | ||
| 327 | { | 330 | { |
| 328 | struct sock *sk; | 331 | struct sock *sk; |
| 329 | 332 | ||
| @@ -394,7 +397,8 @@ static int rfcomm_sock_connect(struct socket *sock, struct sockaddr *addr, int a | |||
| 394 | 397 | ||
| 395 | BT_DBG("sk %p", sk); | 398 | BT_DBG("sk %p", sk); |
| 396 | 399 | ||
| 397 | if (addr->sa_family != AF_BLUETOOTH || alen < sizeof(struct sockaddr_rc)) | 400 | if (alen < sizeof(struct sockaddr_rc) || |
| 401 | addr->sa_family != AF_BLUETOOTH) | ||
| 398 | return -EINVAL; | 402 | return -EINVAL; |
| 399 | 403 | ||
| 400 | lock_sock(sk); | 404 | lock_sock(sk); |
| @@ -703,7 +707,7 @@ static int rfcomm_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
| 703 | copied += chunk; | 707 | copied += chunk; |
| 704 | size -= chunk; | 708 | size -= chunk; |
| 705 | 709 | ||
| 706 | sock_recv_timestamp(msg, sk, skb); | 710 | sock_recv_ts_and_drops(msg, sk, skb); |
| 707 | 711 | ||
| 708 | if (!(flags & MSG_PEEK)) { | 712 | if (!(flags & MSG_PEEK)) { |
| 709 | atomic_sub(chunk, &sk->sk_rmem_alloc); | 713 | atomic_sub(chunk, &sk->sk_rmem_alloc); |
| @@ -1060,26 +1064,38 @@ done: | |||
| 1060 | return result; | 1064 | return result; |
| 1061 | } | 1065 | } |
| 1062 | 1066 | ||
| 1063 | static ssize_t rfcomm_sock_sysfs_show(struct class *dev, char *buf) | 1067 | static int rfcomm_sock_debugfs_show(struct seq_file *f, void *p) |
| 1064 | { | 1068 | { |
| 1065 | struct sock *sk; | 1069 | struct sock *sk; |
| 1066 | struct hlist_node *node; | 1070 | struct hlist_node *node; |
| 1067 | char *str = buf; | ||
| 1068 | 1071 | ||
| 1069 | read_lock_bh(&rfcomm_sk_list.lock); | 1072 | read_lock_bh(&rfcomm_sk_list.lock); |
| 1070 | 1073 | ||
| 1071 | sk_for_each(sk, node, &rfcomm_sk_list.head) { | 1074 | sk_for_each(sk, node, &rfcomm_sk_list.head) { |
| 1072 | str += sprintf(str, "%s %s %d %d\n", | 1075 | seq_printf(f, "%s %s %d %d\n", |
| 1073 | batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), | 1076 | batostr(&bt_sk(sk)->src), |
| 1077 | batostr(&bt_sk(sk)->dst), | ||
| 1074 | sk->sk_state, rfcomm_pi(sk)->channel); | 1078 | sk->sk_state, rfcomm_pi(sk)->channel); |
| 1075 | } | 1079 | } |
| 1076 | 1080 | ||
| 1077 | read_unlock_bh(&rfcomm_sk_list.lock); | 1081 | read_unlock_bh(&rfcomm_sk_list.lock); |
| 1078 | 1082 | ||
| 1079 | return (str - buf); | 1083 | return 0; |
| 1080 | } | 1084 | } |
| 1081 | 1085 | ||
| 1082 | 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; | ||
| 1083 | 1099 | ||
| 1084 | static const struct proto_ops rfcomm_sock_ops = { | 1100 | static const struct proto_ops rfcomm_sock_ops = { |
| 1085 | .family = PF_BLUETOOTH, | 1101 | .family = PF_BLUETOOTH, |
| @@ -1101,7 +1117,7 @@ static const struct proto_ops rfcomm_sock_ops = { | |||
| 1101 | .mmap = sock_no_mmap | 1117 | .mmap = sock_no_mmap |
| 1102 | }; | 1118 | }; |
| 1103 | 1119 | ||
| 1104 | static struct net_proto_family rfcomm_sock_family_ops = { | 1120 | static const struct net_proto_family rfcomm_sock_family_ops = { |
| 1105 | .family = PF_BLUETOOTH, | 1121 | .family = PF_BLUETOOTH, |
| 1106 | .owner = THIS_MODULE, | 1122 | .owner = THIS_MODULE, |
| 1107 | .create = rfcomm_sock_create | 1123 | .create = rfcomm_sock_create |
| @@ -1119,8 +1135,12 @@ int __init rfcomm_init_sockets(void) | |||
| 1119 | if (err < 0) | 1135 | if (err < 0) |
| 1120 | goto error; | 1136 | goto error; |
| 1121 | 1137 | ||
| 1122 | if (class_create_file(bt_class, &class_attr_rfcomm) < 0) | 1138 | if (bt_debugfs) { |
| 1123 | 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 | } | ||
| 1124 | 1144 | ||
| 1125 | BT_INFO("RFCOMM socket layer initialized"); | 1145 | BT_INFO("RFCOMM socket layer initialized"); |
| 1126 | 1146 | ||
| @@ -1134,7 +1154,7 @@ error: | |||
| 1134 | 1154 | ||
| 1135 | void rfcomm_cleanup_sockets(void) | 1155 | void rfcomm_cleanup_sockets(void) |
| 1136 | { | 1156 | { |
| 1137 | class_remove_file(bt_class, &class_attr_rfcomm); | 1157 | debugfs_remove(rfcomm_sock_debugfs); |
| 1138 | 1158 | ||
| 1139 | if (bt_sock_unregister(BTPROTO_RFCOMM) < 0) | 1159 | if (bt_sock_unregister(BTPROTO_RFCOMM) < 0) |
| 1140 | BT_ERR("RFCOMM socket layer unregistration failed"); | 1160 | BT_ERR("RFCOMM socket layer unregistration failed"); |
