diff options
Diffstat (limited to 'net/bluetooth/rfcomm/sock.c')
-rw-r--r-- | net/bluetooth/rfcomm/sock.c | 90 |
1 files changed, 13 insertions, 77 deletions
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index a2b30f0aedb..6c34261b232 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c | |||
@@ -42,8 +42,7 @@ | |||
42 | #include <linux/socket.h> | 42 | #include <linux/socket.h> |
43 | #include <linux/skbuff.h> | 43 | #include <linux/skbuff.h> |
44 | #include <linux/list.h> | 44 | #include <linux/list.h> |
45 | #include <linux/proc_fs.h> | 45 | #include <linux/device.h> |
46 | #include <linux/seq_file.h> | ||
47 | #include <net/sock.h> | 46 | #include <net/sock.h> |
48 | 47 | ||
49 | #include <asm/system.h> | 48 | #include <asm/system.h> |
@@ -887,89 +886,26 @@ done: | |||
887 | return result; | 886 | return result; |
888 | } | 887 | } |
889 | 888 | ||
890 | /* ---- Proc fs support ---- */ | 889 | static ssize_t rfcomm_sock_sysfs_show(struct class *dev, char *buf) |
891 | #ifdef CONFIG_PROC_FS | ||
892 | static void *rfcomm_seq_start(struct seq_file *seq, loff_t *pos) | ||
893 | { | 890 | { |
894 | struct sock *sk; | 891 | struct sock *sk; |
895 | struct hlist_node *node; | 892 | struct hlist_node *node; |
896 | loff_t l = *pos; | 893 | char *str = buf; |
897 | 894 | ||
898 | read_lock_bh(&rfcomm_sk_list.lock); | 895 | read_lock_bh(&rfcomm_sk_list.lock); |
899 | 896 | ||
900 | sk_for_each(sk, node, &rfcomm_sk_list.head) | 897 | sk_for_each(sk, node, &rfcomm_sk_list.head) { |
901 | if (!l--) | 898 | str += sprintf(str, "%s %s %d %d\n", |
902 | return sk; | 899 | batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), |
903 | return NULL; | 900 | sk->sk_state, rfcomm_pi(sk)->channel); |
904 | } | 901 | } |
905 | |||
906 | static void *rfcomm_seq_next(struct seq_file *seq, void *e, loff_t *pos) | ||
907 | { | ||
908 | struct sock *sk = e; | ||
909 | (*pos)++; | ||
910 | return sk_next(sk); | ||
911 | } | ||
912 | 902 | ||
913 | static void rfcomm_seq_stop(struct seq_file *seq, void *e) | ||
914 | { | ||
915 | read_unlock_bh(&rfcomm_sk_list.lock); | 903 | read_unlock_bh(&rfcomm_sk_list.lock); |
916 | } | ||
917 | 904 | ||
918 | static int rfcomm_seq_show(struct seq_file *seq, void *e) | 905 | return (str - buf); |
919 | { | ||
920 | struct sock *sk = e; | ||
921 | seq_printf(seq, "%s %s %d %d\n", | ||
922 | batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), | ||
923 | sk->sk_state, rfcomm_pi(sk)->channel); | ||
924 | return 0; | ||
925 | } | ||
926 | |||
927 | static struct seq_operations rfcomm_seq_ops = { | ||
928 | .start = rfcomm_seq_start, | ||
929 | .next = rfcomm_seq_next, | ||
930 | .stop = rfcomm_seq_stop, | ||
931 | .show = rfcomm_seq_show | ||
932 | }; | ||
933 | |||
934 | static int rfcomm_seq_open(struct inode *inode, struct file *file) | ||
935 | { | ||
936 | return seq_open(file, &rfcomm_seq_ops); | ||
937 | } | 906 | } |
938 | 907 | ||
939 | static struct file_operations rfcomm_seq_fops = { | 908 | static CLASS_ATTR(rfcomm, S_IRUGO, rfcomm_sock_sysfs_show, NULL); |
940 | .owner = THIS_MODULE, | ||
941 | .open = rfcomm_seq_open, | ||
942 | .read = seq_read, | ||
943 | .llseek = seq_lseek, | ||
944 | .release = seq_release, | ||
945 | }; | ||
946 | |||
947 | static int __init rfcomm_sock_proc_init(void) | ||
948 | { | ||
949 | struct proc_dir_entry *p = create_proc_entry("sock", S_IRUGO, proc_bt_rfcomm); | ||
950 | if (!p) | ||
951 | return -ENOMEM; | ||
952 | p->proc_fops = &rfcomm_seq_fops; | ||
953 | return 0; | ||
954 | } | ||
955 | |||
956 | static void __exit rfcomm_sock_proc_cleanup(void) | ||
957 | { | ||
958 | remove_proc_entry("sock", proc_bt_rfcomm); | ||
959 | } | ||
960 | |||
961 | #else /* CONFIG_PROC_FS */ | ||
962 | |||
963 | static int __init rfcomm_sock_proc_init(void) | ||
964 | { | ||
965 | return 0; | ||
966 | } | ||
967 | |||
968 | static void __exit rfcomm_sock_proc_cleanup(void) | ||
969 | { | ||
970 | return; | ||
971 | } | ||
972 | #endif /* CONFIG_PROC_FS */ | ||
973 | 909 | ||
974 | static struct proto_ops rfcomm_sock_ops = { | 910 | static struct proto_ops rfcomm_sock_ops = { |
975 | .family = PF_BLUETOOTH, | 911 | .family = PF_BLUETOOTH, |
@@ -997,7 +933,7 @@ static struct net_proto_family rfcomm_sock_family_ops = { | |||
997 | .create = rfcomm_sock_create | 933 | .create = rfcomm_sock_create |
998 | }; | 934 | }; |
999 | 935 | ||
1000 | int __init rfcomm_init_sockets(void) | 936 | int __init rfcomm_init_sockets(void) |
1001 | { | 937 | { |
1002 | int err; | 938 | int err; |
1003 | 939 | ||
@@ -1009,7 +945,7 @@ int __init rfcomm_init_sockets(void) | |||
1009 | if (err < 0) | 945 | if (err < 0) |
1010 | goto error; | 946 | goto error; |
1011 | 947 | ||
1012 | rfcomm_sock_proc_init(); | 948 | class_create_file(&bt_class, &class_attr_rfcomm); |
1013 | 949 | ||
1014 | BT_INFO("RFCOMM socket layer initialized"); | 950 | BT_INFO("RFCOMM socket layer initialized"); |
1015 | 951 | ||
@@ -1023,7 +959,7 @@ error: | |||
1023 | 959 | ||
1024 | void __exit rfcomm_cleanup_sockets(void) | 960 | void __exit rfcomm_cleanup_sockets(void) |
1025 | { | 961 | { |
1026 | rfcomm_sock_proc_cleanup(); | 962 | class_remove_file(&bt_class, &class_attr_rfcomm); |
1027 | 963 | ||
1028 | if (bt_sock_unregister(BTPROTO_RFCOMM) < 0) | 964 | if (bt_sock_unregister(BTPROTO_RFCOMM) < 0) |
1029 | BT_ERR("RFCOMM socket layer unregistration failed"); | 965 | BT_ERR("RFCOMM socket layer unregistration failed"); |