diff options
Diffstat (limited to 'net/bluetooth/l2cap.c')
| -rw-r--r-- | net/bluetooth/l2cap.c | 51 |
1 files changed, 30 insertions, 21 deletions
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 | ||
| 3940 | static ssize_t l2cap_sysfs_show(struct class *dev, | 3942 | static 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 | ||
| 3972 | static CLASS_ATTR(l2cap, S_IRUGO, l2cap_sysfs_show, NULL); | 3965 | static int l2cap_debugfs_open(struct inode *inode, struct file *file) |
| 3966 | { | ||
| 3967 | return single_open(file, l2cap_debugfs_show, inode->i_private); | ||
| 3968 | } | ||
| 3969 | |||
| 3970 | static 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 | |||
| 3977 | static struct dentry *l2cap_debugfs; | ||
| 3973 | 3978 | ||
| 3974 | static const struct proto_ops l2cap_sock_ops = { | 3979 | static 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 | ||
| 4045 | static void __exit l2cap_exit(void) | 4054 | static 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"); |
