diff options
Diffstat (limited to 'net/bluetooth/sco.c')
-rw-r--r-- | net/bluetooth/sco.c | 41 |
1 files changed, 28 insertions, 13 deletions
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"); |