aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/sco.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-03-21 00:27:45 -0400
committerMarcel Holtmann <marcel@holtmann.org>2010-03-21 00:49:35 -0400
commitaef7d97cc604309b66f6f45cce02cd734934cd4e (patch)
treeb21aae56f9a5de0bbabe881d597a4dc790ff97c8 /net/bluetooth/sco.c
parent101545f6fef4a0a3ea8daf0b5b880df2c6a92a69 (diff)
Bluetooth: Convert debug files to actually use debugfs instead of sysfs
Some of the debug files ended up wrongly in sysfs, because at that point of time, debugfs didn't exist. Convert these files to use debugfs and also seq_file. This patch converts all of these files at once and then removes the exported symbol for the Bluetooth sysfs class. Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/sco.c')
-rw-r--r--net/bluetooth/sco.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 967a75175c66..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,37 +955,36 @@ drop:
953 return 0; 955 return 0;
954} 956}
955 957
956static ssize_t sco_sysfs_show(struct class *dev, 958static 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 int size = PAGE_SIZE;
964 962
965 read_lock_bh(&sco_sk_list.lock); 963 read_lock_bh(&sco_sk_list.lock);
966 964
967 sk_for_each(sk, node, &sco_sk_list.head) { 965 sk_for_each(sk, node, &sco_sk_list.head) {
968 int len; 966 seq_printf(f, "%s %s %d\n", batostr(&bt_sk(sk)->src),
969 967 batostr(&bt_sk(sk)->dst), sk->sk_state);
970 len = snprintf(str, size, "%s %s %d\n",
971 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
972 sk->sk_state);
973
974 size -= len;
975 if (size <= 0)
976 break;
977
978 str += len;
979 } 968 }
980 969
981 read_unlock_bh(&sco_sk_list.lock); 970 read_unlock_bh(&sco_sk_list.lock);
982 971
983 return (str - buf); 972 return 0;
984} 973}
985 974
986static CLASS_ATTR(sco, S_IRUGO, sco_sysfs_show, NULL); 975static int sco_debugfs_open(struct inode *inode, struct file *file)
976{
977 return single_open(file, sco_debugfs_show, inode->i_private);
978}
979
980static 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
987static struct dentry *sco_debugfs;
987 988
988static const struct proto_ops sco_sock_ops = { 989static const struct proto_ops sco_sock_ops = {
989 .family = PF_BLUETOOTH, 990 .family = PF_BLUETOOTH,
@@ -1041,8 +1042,12 @@ static int __init sco_init(void)
1041 goto error; 1042 goto error;
1042 } 1043 }
1043 1044
1044 if (class_create_file(bt_class, &class_attr_sco) < 0) 1045 if (bt_debugfs) {
1045 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 }
1046 1051
1047 BT_INFO("SCO (Voice Link) ver %s", VERSION); 1052 BT_INFO("SCO (Voice Link) ver %s", VERSION);
1048 BT_INFO("SCO socket layer initialized"); 1053 BT_INFO("SCO socket layer initialized");
@@ -1056,7 +1061,7 @@ error:
1056 1061
1057static void __exit sco_exit(void) 1062static void __exit sco_exit(void)
1058{ 1063{
1059 class_remove_file(bt_class, &class_attr_sco); 1064 debugfs_remove(sco_debugfs);
1060 1065
1061 if (bt_sock_unregister(BTPROTO_SCO) < 0) 1066 if (bt_sock_unregister(BTPROTO_SCO) < 0)
1062 BT_ERR("SCO socket unregistration failed"); 1067 BT_ERR("SCO socket unregistration failed");