diff options
Diffstat (limited to 'net/bluetooth/sco.c')
-rw-r--r-- | net/bluetooth/sco.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index f93b939539bc..e5b16b76b22e 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 | ||
@@ -953,28 +955,36 @@ drop: | |||
953 | return 0; | 955 | return 0; |
954 | } | 956 | } |
955 | 957 | ||
956 | static ssize_t sco_sysfs_show(struct class *dev, | 958 | static int sco_debugfs_show(struct seq_file *f, void *p) |
957 | struct class_attribute *attr, | ||
958 | char *buf) | ||
959 | { | 959 | { |
960 | struct sock *sk; | 960 | struct sock *sk; |
961 | struct hlist_node *node; | 961 | struct hlist_node *node; |
962 | char *str = buf; | ||
963 | 962 | ||
964 | read_lock_bh(&sco_sk_list.lock); | 963 | read_lock_bh(&sco_sk_list.lock); |
965 | 964 | ||
966 | sk_for_each(sk, node, &sco_sk_list.head) { | 965 | sk_for_each(sk, node, &sco_sk_list.head) { |
967 | str += sprintf(str, "%s %s %d\n", | 966 | seq_printf(f, "%s %s %d\n", batostr(&bt_sk(sk)->src), |
968 | batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), | 967 | batostr(&bt_sk(sk)->dst), sk->sk_state); |
969 | sk->sk_state); | ||
970 | } | 968 | } |
971 | 969 | ||
972 | read_unlock_bh(&sco_sk_list.lock); | 970 | read_unlock_bh(&sco_sk_list.lock); |
973 | 971 | ||
974 | return (str - buf); | 972 | return 0; |
975 | } | 973 | } |
976 | 974 | ||
977 | static CLASS_ATTR(sco, S_IRUGO, sco_sysfs_show, NULL); | 975 | static int sco_debugfs_open(struct inode *inode, struct file *file) |
976 | { | ||
977 | return single_open(file, sco_debugfs_show, inode->i_private); | ||
978 | } | ||
979 | |||
980 | static const struct file_operations sco_debugfs_fops = { | ||
981 | .open = sco_debugfs_open, | ||
982 | .read = seq_read, | ||
983 | .llseek = seq_lseek, | ||
984 | .release = single_release, | ||
985 | }; | ||
986 | |||
987 | static struct dentry *sco_debugfs; | ||
978 | 988 | ||
979 | static const struct proto_ops sco_sock_ops = { | 989 | static const struct proto_ops sco_sock_ops = { |
980 | .family = PF_BLUETOOTH, | 990 | .family = PF_BLUETOOTH, |
@@ -1032,8 +1042,12 @@ static int __init sco_init(void) | |||
1032 | goto error; | 1042 | goto error; |
1033 | } | 1043 | } |
1034 | 1044 | ||
1035 | if (class_create_file(bt_class, &class_attr_sco) < 0) | 1045 | if (bt_debugfs) { |
1036 | BT_ERR("Failed to create SCO info file"); | 1046 | sco_debugfs = debugfs_create_file("sco", 0444, |
1047 | bt_debugfs, NULL, &sco_debugfs_fops); | ||
1048 | if (!sco_debugfs) | ||
1049 | BT_ERR("Failed to create SCO debug file"); | ||
1050 | } | ||
1037 | 1051 | ||
1038 | BT_INFO("SCO (Voice Link) ver %s", VERSION); | 1052 | BT_INFO("SCO (Voice Link) ver %s", VERSION); |
1039 | BT_INFO("SCO socket layer initialized"); | 1053 | BT_INFO("SCO socket layer initialized"); |
@@ -1047,7 +1061,7 @@ error: | |||
1047 | 1061 | ||
1048 | static void __exit sco_exit(void) | 1062 | static void __exit sco_exit(void) |
1049 | { | 1063 | { |
1050 | class_remove_file(bt_class, &class_attr_sco); | 1064 | debugfs_remove(sco_debugfs); |
1051 | 1065 | ||
1052 | if (bt_sock_unregister(BTPROTO_SCO) < 0) | 1066 | if (bt_sock_unregister(BTPROTO_SCO) < 0) |
1053 | BT_ERR("SCO socket unregistration failed"); | 1067 | BT_ERR("SCO socket unregistration failed"); |