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/core.c | |
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/core.c')
-rw-r--r-- | net/bluetooth/rfcomm/core.c | 124 |
1 files changed, 17 insertions, 107 deletions
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index c3d56ead840..0d89d643413 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); |