diff options
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/af_bluetooth.c | 1 | ||||
-rw-r--r-- | net/bluetooth/bnep/core.c | 1 | ||||
-rw-r--r-- | net/bluetooth/bnep/netdev.c | 1 | ||||
-rw-r--r-- | net/bluetooth/bnep/sock.c | 2 | ||||
-rw-r--r-- | net/bluetooth/cmtp/sock.c | 2 | ||||
-rw-r--r-- | net/bluetooth/hci_sysfs.c | 45 | ||||
-rw-r--r-- | net/bluetooth/hidp/sock.c | 2 | ||||
-rw-r--r-- | net/bluetooth/l2cap.c | 56 | ||||
-rw-r--r-- | net/bluetooth/rfcomm/core.c | 42 | ||||
-rw-r--r-- | net/bluetooth/rfcomm/sock.c | 41 | ||||
-rw-r--r-- | net/bluetooth/sco.c | 41 |
11 files changed, 155 insertions, 79 deletions
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index 087cc51f5927..404a8500fd03 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <linux/errno.h> | 31 | #include <linux/errno.h> |
32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
33 | #include <linux/sched.h> | 33 | #include <linux/sched.h> |
34 | #include <linux/slab.h> | ||
35 | #include <linux/skbuff.h> | 34 | #include <linux/skbuff.h> |
36 | #include <linux/init.h> | 35 | #include <linux/init.h> |
37 | #include <linux/poll.h> | 36 | #include <linux/poll.h> |
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index ef09c7b3a858..8062dad6d10d 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/freezer.h> | 35 | #include <linux/freezer.h> |
36 | #include <linux/errno.h> | 36 | #include <linux/errno.h> |
37 | #include <linux/net.h> | 37 | #include <linux/net.h> |
38 | #include <linux/slab.h> | ||
38 | #include <net/sock.h> | 39 | #include <net/sock.h> |
39 | 40 | ||
40 | #include <linux/socket.h> | 41 | #include <linux/socket.h> |
diff --git a/net/bluetooth/bnep/netdev.c b/net/bluetooth/bnep/netdev.c index b6234b73c4cf..5643a2391e76 100644 --- a/net/bluetooth/bnep/netdev.c +++ b/net/bluetooth/bnep/netdev.c | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
29 | #include <linux/slab.h> | ||
29 | 30 | ||
30 | #include <linux/socket.h> | 31 | #include <linux/socket.h> |
31 | #include <linux/netdevice.h> | 32 | #include <linux/netdevice.h> |
diff --git a/net/bluetooth/bnep/sock.c b/net/bluetooth/bnep/sock.c index 2ff6ac7b2ed4..2862f53b66b1 100644 --- a/net/bluetooth/bnep/sock.c +++ b/net/bluetooth/bnep/sock.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/capability.h> | 30 | #include <linux/capability.h> |
31 | #include <linux/errno.h> | 31 | #include <linux/errno.h> |
32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
33 | #include <linux/slab.h> | ||
34 | #include <linux/poll.h> | 33 | #include <linux/poll.h> |
35 | #include <linux/fcntl.h> | 34 | #include <linux/fcntl.h> |
36 | #include <linux/skbuff.h> | 35 | #include <linux/skbuff.h> |
@@ -39,6 +38,7 @@ | |||
39 | #include <linux/file.h> | 38 | #include <linux/file.h> |
40 | #include <linux/init.h> | 39 | #include <linux/init.h> |
41 | #include <linux/compat.h> | 40 | #include <linux/compat.h> |
41 | #include <linux/gfp.h> | ||
42 | #include <net/sock.h> | 42 | #include <net/sock.h> |
43 | 43 | ||
44 | #include <asm/system.h> | 44 | #include <asm/system.h> |
diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c index 978cc3a718ad..7ea1979a8e4f 100644 --- a/net/bluetooth/cmtp/sock.c +++ b/net/bluetooth/cmtp/sock.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/capability.h> | 26 | #include <linux/capability.h> |
27 | #include <linux/errno.h> | 27 | #include <linux/errno.h> |
28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
29 | #include <linux/slab.h> | ||
30 | #include <linux/poll.h> | 29 | #include <linux/poll.h> |
31 | #include <linux/fcntl.h> | 30 | #include <linux/fcntl.h> |
32 | #include <linux/skbuff.h> | 31 | #include <linux/skbuff.h> |
@@ -34,6 +33,7 @@ | |||
34 | #include <linux/ioctl.h> | 33 | #include <linux/ioctl.h> |
35 | #include <linux/file.h> | 34 | #include <linux/file.h> |
36 | #include <linux/compat.h> | 35 | #include <linux/compat.h> |
36 | #include <linux/gfp.h> | ||
37 | #include <net/sock.h> | 37 | #include <net/sock.h> |
38 | 38 | ||
39 | #include <linux/isdn/capilli.h> | 39 | #include <linux/isdn/capilli.h> |
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index 1a79a6c7e30e..0e8e1a59856c 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c | |||
@@ -1,14 +1,15 @@ | |||
1 | /* Bluetooth HCI driver model support. */ | 1 | /* Bluetooth HCI driver model support. */ |
2 | 2 | ||
3 | #include <linux/kernel.h> | 3 | #include <linux/kernel.h> |
4 | #include <linux/slab.h> | ||
4 | #include <linux/init.h> | 5 | #include <linux/init.h> |
5 | #include <linux/debugfs.h> | 6 | #include <linux/debugfs.h> |
7 | #include <linux/seq_file.h> | ||
6 | 8 | ||
7 | #include <net/bluetooth/bluetooth.h> | 9 | #include <net/bluetooth/bluetooth.h> |
8 | #include <net/bluetooth/hci_core.h> | 10 | #include <net/bluetooth/hci_core.h> |
9 | 11 | ||
10 | struct class *bt_class = NULL; | 12 | static struct class *bt_class; |
11 | EXPORT_SYMBOL_GPL(bt_class); | ||
12 | 13 | ||
13 | struct dentry *bt_debugfs = NULL; | 14 | struct dentry *bt_debugfs = NULL; |
14 | EXPORT_SYMBOL_GPL(bt_debugfs); | 15 | EXPORT_SYMBOL_GPL(bt_debugfs); |
@@ -405,20 +406,11 @@ static struct device_type bt_host = { | |||
405 | .release = bt_host_release, | 406 | .release = bt_host_release, |
406 | }; | 407 | }; |
407 | 408 | ||
408 | static int inquiry_cache_open(struct inode *inode, struct file *file) | 409 | static int inquiry_cache_show(struct seq_file *f, void *p) |
409 | { | ||
410 | file->private_data = inode->i_private; | ||
411 | return 0; | ||
412 | } | ||
413 | |||
414 | static ssize_t inquiry_cache_read(struct file *file, char __user *userbuf, | ||
415 | size_t count, loff_t *ppos) | ||
416 | { | 410 | { |
417 | struct hci_dev *hdev = file->private_data; | 411 | struct hci_dev *hdev = f->private; |
418 | struct inquiry_cache *cache = &hdev->inq_cache; | 412 | struct inquiry_cache *cache = &hdev->inq_cache; |
419 | struct inquiry_entry *e; | 413 | struct inquiry_entry *e; |
420 | char buf[4096]; | ||
421 | int n = 0; | ||
422 | 414 | ||
423 | hci_dev_lock_bh(hdev); | 415 | hci_dev_lock_bh(hdev); |
424 | 416 | ||
@@ -426,23 +418,30 @@ static ssize_t inquiry_cache_read(struct file *file, char __user *userbuf, | |||
426 | struct inquiry_data *data = &e->data; | 418 | struct inquiry_data *data = &e->data; |
427 | bdaddr_t bdaddr; | 419 | bdaddr_t bdaddr; |
428 | baswap(&bdaddr, &data->bdaddr); | 420 | baswap(&bdaddr, &data->bdaddr); |
429 | n += sprintf(buf + n, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n", | 421 | seq_printf(f, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n", |
430 | batostr(&bdaddr), | 422 | batostr(&bdaddr), |
431 | data->pscan_rep_mode, data->pscan_period_mode, | 423 | data->pscan_rep_mode, data->pscan_period_mode, |
432 | data->pscan_mode, data->dev_class[2], | 424 | data->pscan_mode, data->dev_class[2], |
433 | data->dev_class[1], data->dev_class[0], | 425 | data->dev_class[1], data->dev_class[0], |
434 | __le16_to_cpu(data->clock_offset), | 426 | __le16_to_cpu(data->clock_offset), |
435 | data->rssi, data->ssp_mode, e->timestamp); | 427 | data->rssi, data->ssp_mode, e->timestamp); |
436 | } | 428 | } |
437 | 429 | ||
438 | hci_dev_unlock_bh(hdev); | 430 | hci_dev_unlock_bh(hdev); |
439 | 431 | ||
440 | return simple_read_from_buffer(userbuf, count, ppos, buf, n); | 432 | return 0; |
433 | } | ||
434 | |||
435 | static int inquiry_cache_open(struct inode *inode, struct file *file) | ||
436 | { | ||
437 | return single_open(file, inquiry_cache_show, inode->i_private); | ||
441 | } | 438 | } |
442 | 439 | ||
443 | static const struct file_operations inquiry_cache_fops = { | 440 | static const struct file_operations inquiry_cache_fops = { |
444 | .open = inquiry_cache_open, | 441 | .open = inquiry_cache_open, |
445 | .read = inquiry_cache_read, | 442 | .read = seq_read, |
443 | .llseek = seq_lseek, | ||
444 | .release = single_release, | ||
446 | }; | 445 | }; |
447 | 446 | ||
448 | int hci_register_sysfs(struct hci_dev *hdev) | 447 | int hci_register_sysfs(struct hci_dev *hdev) |
diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c index 9cfef68b9fec..250dfd46237d 100644 --- a/net/bluetooth/hidp/sock.c +++ b/net/bluetooth/hidp/sock.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/capability.h> | 26 | #include <linux/capability.h> |
27 | #include <linux/errno.h> | 27 | #include <linux/errno.h> |
28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
29 | #include <linux/slab.h> | ||
30 | #include <linux/poll.h> | 29 | #include <linux/poll.h> |
31 | #include <linux/fcntl.h> | 30 | #include <linux/fcntl.h> |
32 | #include <linux/skbuff.h> | 31 | #include <linux/skbuff.h> |
@@ -35,6 +34,7 @@ | |||
35 | #include <linux/file.h> | 34 | #include <linux/file.h> |
36 | #include <linux/init.h> | 35 | #include <linux/init.h> |
37 | #include <linux/compat.h> | 36 | #include <linux/compat.h> |
37 | #include <linux/gfp.h> | ||
38 | #include <net/sock.h> | 38 | #include <net/sock.h> |
39 | 39 | ||
40 | #include "hidp.h" | 40 | #include "hidp.h" |
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index 4db7ae2fe07d..9753b690a8b3 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)); |
@@ -1623,7 +1626,10 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms | |||
1623 | /* Connectionless channel */ | 1626 | /* Connectionless channel */ |
1624 | if (sk->sk_type == SOCK_DGRAM) { | 1627 | if (sk->sk_type == SOCK_DGRAM) { |
1625 | skb = l2cap_create_connless_pdu(sk, msg, len); | 1628 | skb = l2cap_create_connless_pdu(sk, msg, len); |
1626 | err = l2cap_do_send(sk, skb); | 1629 | if (IS_ERR(skb)) |
1630 | err = PTR_ERR(skb); | ||
1631 | else | ||
1632 | err = l2cap_do_send(sk, skb); | ||
1627 | goto done; | 1633 | goto done; |
1628 | } | 1634 | } |
1629 | 1635 | ||
@@ -2830,6 +2836,11 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
2830 | int len = cmd->len - sizeof(*rsp); | 2836 | int len = cmd->len - sizeof(*rsp); |
2831 | char req[64]; | 2837 | char req[64]; |
2832 | 2838 | ||
2839 | if (len > sizeof(req) - sizeof(struct l2cap_conf_req)) { | ||
2840 | l2cap_send_disconn_req(conn, sk); | ||
2841 | goto done; | ||
2842 | } | ||
2843 | |||
2833 | /* throw out any old stored conf requests */ | 2844 | /* throw out any old stored conf requests */ |
2834 | result = L2CAP_CONF_SUCCESS; | 2845 | result = L2CAP_CONF_SUCCESS; |
2835 | len = l2cap_parse_conf_rsp(sk, rsp->data, | 2846 | len = l2cap_parse_conf_rsp(sk, rsp->data, |
@@ -3937,31 +3948,42 @@ drop: | |||
3937 | return 0; | 3948 | return 0; |
3938 | } | 3949 | } |
3939 | 3950 | ||
3940 | static ssize_t l2cap_sysfs_show(struct class *dev, | 3951 | static int l2cap_debugfs_show(struct seq_file *f, void *p) |
3941 | struct class_attribute *attr, | ||
3942 | char *buf) | ||
3943 | { | 3952 | { |
3944 | struct sock *sk; | 3953 | struct sock *sk; |
3945 | struct hlist_node *node; | 3954 | struct hlist_node *node; |
3946 | char *str = buf; | ||
3947 | 3955 | ||
3948 | read_lock_bh(&l2cap_sk_list.lock); | 3956 | read_lock_bh(&l2cap_sk_list.lock); |
3949 | 3957 | ||
3950 | sk_for_each(sk, node, &l2cap_sk_list.head) { | 3958 | sk_for_each(sk, node, &l2cap_sk_list.head) { |
3951 | struct l2cap_pinfo *pi = l2cap_pi(sk); | 3959 | struct l2cap_pinfo *pi = l2cap_pi(sk); |
3952 | 3960 | ||
3953 | str += sprintf(str, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d\n", | 3961 | 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), | 3962 | batostr(&bt_sk(sk)->src), |
3955 | sk->sk_state, __le16_to_cpu(pi->psm), pi->scid, | 3963 | batostr(&bt_sk(sk)->dst), |
3956 | pi->dcid, pi->imtu, pi->omtu, pi->sec_level); | 3964 | sk->sk_state, __le16_to_cpu(pi->psm), |
3965 | pi->scid, pi->dcid, | ||
3966 | pi->imtu, pi->omtu, pi->sec_level); | ||
3957 | } | 3967 | } |
3958 | 3968 | ||
3959 | read_unlock_bh(&l2cap_sk_list.lock); | 3969 | read_unlock_bh(&l2cap_sk_list.lock); |
3960 | 3970 | ||
3961 | return str - buf; | 3971 | return 0; |
3962 | } | 3972 | } |
3963 | 3973 | ||
3964 | static CLASS_ATTR(l2cap, S_IRUGO, l2cap_sysfs_show, NULL); | 3974 | static int l2cap_debugfs_open(struct inode *inode, struct file *file) |
3975 | { | ||
3976 | return single_open(file, l2cap_debugfs_show, inode->i_private); | ||
3977 | } | ||
3978 | |||
3979 | static const struct file_operations l2cap_debugfs_fops = { | ||
3980 | .open = l2cap_debugfs_open, | ||
3981 | .read = seq_read, | ||
3982 | .llseek = seq_lseek, | ||
3983 | .release = single_release, | ||
3984 | }; | ||
3985 | |||
3986 | static struct dentry *l2cap_debugfs; | ||
3965 | 3987 | ||
3966 | static const struct proto_ops l2cap_sock_ops = { | 3988 | static const struct proto_ops l2cap_sock_ops = { |
3967 | .family = PF_BLUETOOTH, | 3989 | .family = PF_BLUETOOTH, |
@@ -4021,8 +4043,12 @@ static int __init l2cap_init(void) | |||
4021 | goto error; | 4043 | goto error; |
4022 | } | 4044 | } |
4023 | 4045 | ||
4024 | if (class_create_file(bt_class, &class_attr_l2cap) < 0) | 4046 | if (bt_debugfs) { |
4025 | BT_ERR("Failed to create L2CAP info file"); | 4047 | l2cap_debugfs = debugfs_create_file("l2cap", 0444, |
4048 | bt_debugfs, NULL, &l2cap_debugfs_fops); | ||
4049 | if (!l2cap_debugfs) | ||
4050 | BT_ERR("Failed to create L2CAP debug file"); | ||
4051 | } | ||
4026 | 4052 | ||
4027 | BT_INFO("L2CAP ver %s", VERSION); | 4053 | BT_INFO("L2CAP ver %s", VERSION); |
4028 | BT_INFO("L2CAP socket layer initialized"); | 4054 | BT_INFO("L2CAP socket layer initialized"); |
@@ -4036,7 +4062,7 @@ error: | |||
4036 | 4062 | ||
4037 | static void __exit l2cap_exit(void) | 4063 | static void __exit l2cap_exit(void) |
4038 | { | 4064 | { |
4039 | class_remove_file(bt_class, &class_attr_l2cap); | 4065 | debugfs_remove(l2cap_debugfs); |
4040 | 4066 | ||
4041 | if (bt_sock_unregister(BTPROTO_L2CAP) < 0) | 4067 | if (bt_sock_unregister(BTPROTO_L2CAP) < 0) |
4042 | BT_ERR("L2CAP socket unregistration failed"); | 4068 | BT_ERR("L2CAP socket unregistration failed"); |
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index db8a68e1a5ba..7dca91bb8c57 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -33,9 +33,12 @@ | |||
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> |
41 | #include <linux/slab.h> | ||
39 | 42 | ||
40 | #include <net/sock.h> | 43 | #include <net/sock.h> |
41 | #include <asm/uaccess.h> | 44 | #include <asm/uaccess.h> |
@@ -2098,13 +2101,10 @@ static struct hci_cb rfcomm_cb = { | |||
2098 | .security_cfm = rfcomm_security_cfm | 2101 | .security_cfm = rfcomm_security_cfm |
2099 | }; | 2102 | }; |
2100 | 2103 | ||
2101 | static ssize_t rfcomm_dlc_sysfs_show(struct class *dev, | 2104 | static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x) |
2102 | struct class_attribute *attr, | ||
2103 | char *buf) | ||
2104 | { | 2105 | { |
2105 | struct rfcomm_session *s; | 2106 | struct rfcomm_session *s; |
2106 | struct list_head *pp, *p; | 2107 | struct list_head *pp, *p; |
2107 | char *str = buf; | ||
2108 | 2108 | ||
2109 | rfcomm_lock(); | 2109 | rfcomm_lock(); |
2110 | 2110 | ||
@@ -2114,18 +2114,32 @@ static ssize_t rfcomm_dlc_sysfs_show(struct class *dev, | |||
2114 | struct sock *sk = s->sock->sk; | 2114 | struct sock *sk = s->sock->sk; |
2115 | struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list); | 2115 | struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list); |
2116 | 2116 | ||
2117 | str += sprintf(str, "%s %s %ld %d %d %d %d\n", | 2117 | seq_printf(f, "%s %s %ld %d %d %d %d\n", |
2118 | batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), | 2118 | batostr(&bt_sk(sk)->src), |
2119 | d->state, d->dlci, d->mtu, d->rx_credits, d->tx_credits); | 2119 | batostr(&bt_sk(sk)->dst), |
2120 | d->state, d->dlci, d->mtu, | ||
2121 | d->rx_credits, d->tx_credits); | ||
2120 | } | 2122 | } |
2121 | } | 2123 | } |
2122 | 2124 | ||
2123 | rfcomm_unlock(); | 2125 | rfcomm_unlock(); |
2124 | 2126 | ||
2125 | return (str - buf); | 2127 | return 0; |
2126 | } | 2128 | } |
2127 | 2129 | ||
2128 | static CLASS_ATTR(rfcomm_dlc, S_IRUGO, rfcomm_dlc_sysfs_show, NULL); | 2130 | static int rfcomm_dlc_debugfs_open(struct inode *inode, struct file *file) |
2131 | { | ||
2132 | return single_open(file, rfcomm_dlc_debugfs_show, inode->i_private); | ||
2133 | } | ||
2134 | |||
2135 | static const struct file_operations rfcomm_dlc_debugfs_fops = { | ||
2136 | .open = rfcomm_dlc_debugfs_open, | ||
2137 | .read = seq_read, | ||
2138 | .llseek = seq_lseek, | ||
2139 | .release = single_release, | ||
2140 | }; | ||
2141 | |||
2142 | static struct dentry *rfcomm_dlc_debugfs; | ||
2129 | 2143 | ||
2130 | /* ---- Initialization ---- */ | 2144 | /* ---- Initialization ---- */ |
2131 | static int __init rfcomm_init(void) | 2145 | static int __init rfcomm_init(void) |
@@ -2142,8 +2156,12 @@ static int __init rfcomm_init(void) | |||
2142 | goto unregister; | 2156 | goto unregister; |
2143 | } | 2157 | } |
2144 | 2158 | ||
2145 | if (class_create_file(bt_class, &class_attr_rfcomm_dlc) < 0) | 2159 | if (bt_debugfs) { |
2146 | BT_ERR("Failed to create RFCOMM info file"); | 2160 | rfcomm_dlc_debugfs = debugfs_create_file("rfcomm_dlc", 0444, |
2161 | bt_debugfs, NULL, &rfcomm_dlc_debugfs_fops); | ||
2162 | if (!rfcomm_dlc_debugfs) | ||
2163 | BT_ERR("Failed to create RFCOMM debug file"); | ||
2164 | } | ||
2147 | 2165 | ||
2148 | err = rfcomm_init_ttys(); | 2166 | err = rfcomm_init_ttys(); |
2149 | if (err < 0) | 2167 | if (err < 0) |
@@ -2171,7 +2189,7 @@ unregister: | |||
2171 | 2189 | ||
2172 | static void __exit rfcomm_exit(void) | 2190 | static void __exit rfcomm_exit(void) |
2173 | { | 2191 | { |
2174 | class_remove_file(bt_class, &class_attr_rfcomm_dlc); | 2192 | debugfs_remove(rfcomm_dlc_debugfs); |
2175 | 2193 | ||
2176 | hci_unregister_cb(&rfcomm_cb); | 2194 | hci_unregister_cb(&rfcomm_cb); |
2177 | 2195 | ||
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"); |
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 | ||
956 | static ssize_t sco_sysfs_show(struct class *dev, | 959 | static 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 | ||
977 | static CLASS_ATTR(sco, S_IRUGO, sco_sysfs_show, NULL); | 976 | static int sco_debugfs_open(struct inode *inode, struct file *file) |
977 | { | ||
978 | return single_open(file, sco_debugfs_show, inode->i_private); | ||
979 | } | ||
980 | |||
981 | static 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 | |||
988 | static struct dentry *sco_debugfs; | ||
978 | 989 | ||
979 | static const struct proto_ops sco_sock_ops = { | 990 | static 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 | ||
1048 | static void __exit sco_exit(void) | 1063 | static 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"); |