diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2005-11-08 12:57:38 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-11-08 12:57:38 -0500 |
commit | be9d122730c878baafe11e70d1436faac229f2fc (patch) | |
tree | d6644129b56d7cff9fb9781154eebf97746f296b /net/bluetooth/rfcomm | |
parent | 1ebb92521d0bc2d4ef772730d29333c06b807191 (diff) |
[Bluetooth]: Remove the usage of /proc completely
This patch removes all relics of the /proc usage from the Bluetooth
subsystem core and its upper layers. All the previous information are
now available via /sys/class/bluetooth through appropriate functions.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bluetooth/rfcomm')
-rw-r--r-- | net/bluetooth/rfcomm/core.c | 124 | ||||
-rw-r--r-- | net/bluetooth/rfcomm/sock.c | 90 |
2 files changed, 30 insertions, 184 deletions
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index c3d56ead840c..0d89d6434136 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -35,9 +35,8 @@ | |||
35 | #include <linux/signal.h> | 35 | #include <linux/signal.h> |
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/wait.h> | 37 | #include <linux/wait.h> |
38 | #include <linux/device.h> | ||
38 | #include <linux/net.h> | 39 | #include <linux/net.h> |
39 | #include <linux/proc_fs.h> | ||
40 | #include <linux/seq_file.h> | ||
41 | #include <net/sock.h> | 40 | #include <net/sock.h> |
42 | #include <asm/uaccess.h> | 41 | #include <asm/uaccess.h> |
43 | #include <asm/unaligned.h> | 42 | #include <asm/unaligned.h> |
@@ -47,17 +46,13 @@ | |||
47 | #include <net/bluetooth/l2cap.h> | 46 | #include <net/bluetooth/l2cap.h> |
48 | #include <net/bluetooth/rfcomm.h> | 47 | #include <net/bluetooth/rfcomm.h> |
49 | 48 | ||
50 | #define VERSION "1.5" | 49 | #define VERSION "1.6" |
51 | 50 | ||
52 | #ifndef CONFIG_BT_RFCOMM_DEBUG | 51 | #ifndef CONFIG_BT_RFCOMM_DEBUG |
53 | #undef BT_DBG | 52 | #undef BT_DBG |
54 | #define BT_DBG(D...) | 53 | #define BT_DBG(D...) |
55 | #endif | 54 | #endif |
56 | 55 | ||
57 | #ifdef CONFIG_PROC_FS | ||
58 | struct proc_dir_entry *proc_bt_rfcomm; | ||
59 | #endif | ||
60 | |||
61 | static struct task_struct *rfcomm_thread; | 56 | static struct task_struct *rfcomm_thread; |
62 | 57 | ||
63 | static DECLARE_MUTEX(rfcomm_sem); | 58 | static DECLARE_MUTEX(rfcomm_sem); |
@@ -2001,117 +1996,32 @@ static struct hci_cb rfcomm_cb = { | |||
2001 | .encrypt_cfm = rfcomm_encrypt_cfm | 1996 | .encrypt_cfm = rfcomm_encrypt_cfm |
2002 | }; | 1997 | }; |
2003 | 1998 | ||
2004 | /* ---- Proc fs support ---- */ | 1999 | static ssize_t rfcomm_dlc_sysfs_show(struct class *dev, char *buf) |
2005 | #ifdef CONFIG_PROC_FS | ||
2006 | static void *rfcomm_seq_start(struct seq_file *seq, loff_t *pos) | ||
2007 | { | 2000 | { |
2008 | struct rfcomm_session *s; | 2001 | struct rfcomm_session *s; |
2009 | struct list_head *pp, *p; | 2002 | struct list_head *pp, *p; |
2010 | loff_t l = *pos; | 2003 | char *str = buf; |
2011 | 2004 | ||
2012 | rfcomm_lock(); | 2005 | rfcomm_lock(); |
2013 | 2006 | ||
2014 | list_for_each(p, &session_list) { | 2007 | list_for_each(p, &session_list) { |
2015 | s = list_entry(p, struct rfcomm_session, list); | 2008 | s = list_entry(p, struct rfcomm_session, list); |
2016 | list_for_each(pp, &s->dlcs) | 2009 | list_for_each(pp, &s->dlcs) { |
2017 | if (!l--) { | 2010 | struct sock *sk = s->sock->sk; |
2018 | seq->private = s; | 2011 | struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list); |
2019 | return pp; | ||
2020 | } | ||
2021 | } | ||
2022 | return NULL; | ||
2023 | } | ||
2024 | 2012 | ||
2025 | static void *rfcomm_seq_next(struct seq_file *seq, void *e, loff_t *pos) | 2013 | str += sprintf(str, "%s %s %ld %d %d %d %d\n", |
2026 | { | 2014 | batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), |
2027 | struct rfcomm_session *s = seq->private; | 2015 | d->state, d->dlci, d->mtu, d->rx_credits, d->tx_credits); |
2028 | struct list_head *pp, *p = e; | ||
2029 | (*pos)++; | ||
2030 | |||
2031 | if (p->next != &s->dlcs) | ||
2032 | return p->next; | ||
2033 | |||
2034 | list_for_each(p, &session_list) { | ||
2035 | s = list_entry(p, struct rfcomm_session, list); | ||
2036 | __list_for_each(pp, &s->dlcs) { | ||
2037 | seq->private = s; | ||
2038 | return pp; | ||
2039 | } | 2016 | } |
2040 | } | 2017 | } |
2041 | return NULL; | ||
2042 | } | ||
2043 | 2018 | ||
2044 | static void rfcomm_seq_stop(struct seq_file *seq, void *e) | ||
2045 | { | ||
2046 | rfcomm_unlock(); | 2019 | rfcomm_unlock(); |
2047 | } | ||
2048 | |||
2049 | static int rfcomm_seq_show(struct seq_file *seq, void *e) | ||
2050 | { | ||
2051 | struct rfcomm_session *s = seq->private; | ||
2052 | struct sock *sk = s->sock->sk; | ||
2053 | struct rfcomm_dlc *d = list_entry(e, struct rfcomm_dlc, list); | ||
2054 | |||
2055 | seq_printf(seq, "%s %s %ld %d %d %d %d\n", | ||
2056 | batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), | ||
2057 | d->state, d->dlci, d->mtu, d->rx_credits, d->tx_credits); | ||
2058 | return 0; | ||
2059 | } | ||
2060 | |||
2061 | static struct seq_operations rfcomm_seq_ops = { | ||
2062 | .start = rfcomm_seq_start, | ||
2063 | .next = rfcomm_seq_next, | ||
2064 | .stop = rfcomm_seq_stop, | ||
2065 | .show = rfcomm_seq_show | ||
2066 | }; | ||
2067 | |||
2068 | static int rfcomm_seq_open(struct inode *inode, struct file *file) | ||
2069 | { | ||
2070 | return seq_open(file, &rfcomm_seq_ops); | ||
2071 | } | ||
2072 | |||
2073 | static struct file_operations rfcomm_seq_fops = { | ||
2074 | .owner = THIS_MODULE, | ||
2075 | .open = rfcomm_seq_open, | ||
2076 | .read = seq_read, | ||
2077 | .llseek = seq_lseek, | ||
2078 | .release = seq_release, | ||
2079 | }; | ||
2080 | |||
2081 | static int __init rfcomm_proc_init(void) | ||
2082 | { | ||
2083 | struct proc_dir_entry *p; | ||
2084 | |||
2085 | proc_bt_rfcomm = proc_mkdir("rfcomm", proc_bt); | ||
2086 | if (proc_bt_rfcomm) { | ||
2087 | proc_bt_rfcomm->owner = THIS_MODULE; | ||
2088 | |||
2089 | p = create_proc_entry("dlc", S_IRUGO, proc_bt_rfcomm); | ||
2090 | if (p) | ||
2091 | p->proc_fops = &rfcomm_seq_fops; | ||
2092 | } | ||
2093 | return 0; | ||
2094 | } | ||
2095 | |||
2096 | static void __exit rfcomm_proc_cleanup(void) | ||
2097 | { | ||
2098 | remove_proc_entry("dlc", proc_bt_rfcomm); | ||
2099 | 2020 | ||
2100 | remove_proc_entry("rfcomm", proc_bt); | 2021 | return (str - buf); |
2101 | } | 2022 | } |
2102 | 2023 | ||
2103 | #else /* CONFIG_PROC_FS */ | 2024 | static CLASS_ATTR(rfcomm_dlc, S_IRUGO, rfcomm_dlc_sysfs_show, NULL); |
2104 | |||
2105 | static int __init rfcomm_proc_init(void) | ||
2106 | { | ||
2107 | return 0; | ||
2108 | } | ||
2109 | |||
2110 | static void __exit rfcomm_proc_cleanup(void) | ||
2111 | { | ||
2112 | return; | ||
2113 | } | ||
2114 | #endif /* CONFIG_PROC_FS */ | ||
2115 | 2025 | ||
2116 | /* ---- Initialization ---- */ | 2026 | /* ---- Initialization ---- */ |
2117 | static int __init rfcomm_init(void) | 2027 | static int __init rfcomm_init(void) |
@@ -2122,9 +2032,7 @@ static int __init rfcomm_init(void) | |||
2122 | 2032 | ||
2123 | kernel_thread(rfcomm_run, NULL, CLONE_KERNEL); | 2033 | kernel_thread(rfcomm_run, NULL, CLONE_KERNEL); |
2124 | 2034 | ||
2125 | BT_INFO("RFCOMM ver %s", VERSION); | 2035 | class_create_file(&bt_class, &class_attr_rfcomm_dlc); |
2126 | |||
2127 | rfcomm_proc_init(); | ||
2128 | 2036 | ||
2129 | rfcomm_init_sockets(); | 2037 | rfcomm_init_sockets(); |
2130 | 2038 | ||
@@ -2132,11 +2040,15 @@ static int __init rfcomm_init(void) | |||
2132 | rfcomm_init_ttys(); | 2040 | rfcomm_init_ttys(); |
2133 | #endif | 2041 | #endif |
2134 | 2042 | ||
2043 | BT_INFO("RFCOMM ver %s", VERSION); | ||
2044 | |||
2135 | return 0; | 2045 | return 0; |
2136 | } | 2046 | } |
2137 | 2047 | ||
2138 | static void __exit rfcomm_exit(void) | 2048 | static void __exit rfcomm_exit(void) |
2139 | { | 2049 | { |
2050 | class_remove_file(&bt_class, &class_attr_rfcomm_dlc); | ||
2051 | |||
2140 | hci_unregister_cb(&rfcomm_cb); | 2052 | hci_unregister_cb(&rfcomm_cb); |
2141 | 2053 | ||
2142 | /* Terminate working thread. | 2054 | /* Terminate working thread. |
@@ -2153,8 +2065,6 @@ static void __exit rfcomm_exit(void) | |||
2153 | #endif | 2065 | #endif |
2154 | 2066 | ||
2155 | rfcomm_cleanup_sockets(); | 2067 | rfcomm_cleanup_sockets(); |
2156 | |||
2157 | rfcomm_proc_cleanup(); | ||
2158 | } | 2068 | } |
2159 | 2069 | ||
2160 | module_init(rfcomm_init); | 2070 | module_init(rfcomm_init); |
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index a2b30f0aedb7..6c34261b232e 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"); |