diff options
Diffstat (limited to 'net/bluetooth/rfcomm/core.c')
-rw-r--r-- | net/bluetooth/rfcomm/core.c | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index cf164073269d..13f114e8b0f9 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -33,6 +33,8 @@ | |||
33 | #include <linux/init.h> | 33 | #include <linux/init.h> |
34 | #include <linux/wait.h> | 34 | #include <linux/wait.h> |
35 | #include <linux/device.h> | 35 | #include <linux/device.h> |
36 | #include <linux/debugfs.h> | ||
37 | #include <linux/seq_file.h> | ||
36 | #include <linux/net.h> | 38 | #include <linux/net.h> |
37 | #include <linux/mutex.h> | 39 | #include <linux/mutex.h> |
38 | #include <linux/kthread.h> | 40 | #include <linux/kthread.h> |
@@ -2098,14 +2100,10 @@ static struct hci_cb rfcomm_cb = { | |||
2098 | .security_cfm = rfcomm_security_cfm | 2100 | .security_cfm = rfcomm_security_cfm |
2099 | }; | 2101 | }; |
2100 | 2102 | ||
2101 | static ssize_t rfcomm_dlc_sysfs_show(struct class *dev, | 2103 | static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x) |
2102 | struct class_attribute *attr, | ||
2103 | char *buf) | ||
2104 | { | 2104 | { |
2105 | struct rfcomm_session *s; | 2105 | struct rfcomm_session *s; |
2106 | struct list_head *pp, *p; | 2106 | struct list_head *pp, *p; |
2107 | char *str = buf; | ||
2108 | int size = PAGE_SIZE; | ||
2109 | 2107 | ||
2110 | rfcomm_lock(); | 2108 | rfcomm_lock(); |
2111 | 2109 | ||
@@ -2114,29 +2112,33 @@ static ssize_t rfcomm_dlc_sysfs_show(struct class *dev, | |||
2114 | list_for_each(pp, &s->dlcs) { | 2112 | list_for_each(pp, &s->dlcs) { |
2115 | struct sock *sk = s->sock->sk; | 2113 | struct sock *sk = s->sock->sk; |
2116 | struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list); | 2114 | struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list); |
2117 | int len; | ||
2118 | 2115 | ||
2119 | len = snprintf(str, size, "%s %s %ld %d %d %d %d\n", | 2116 | seq_printf(f, "%s %s %ld %d %d %d %d\n", |
2120 | batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), | 2117 | batostr(&bt_sk(sk)->src), |
2121 | d->state, d->dlci, d->mtu, d->rx_credits, d->tx_credits); | 2118 | batostr(&bt_sk(sk)->dst), |
2122 | 2119 | d->state, d->dlci, d->mtu, | |
2123 | size -= len; | 2120 | d->rx_credits, d->tx_credits); |
2124 | if (size <= 0) | ||
2125 | break; | ||
2126 | |||
2127 | str += len; | ||
2128 | } | 2121 | } |
2129 | |||
2130 | if (size <= 0) | ||
2131 | break; | ||
2132 | } | 2122 | } |
2133 | 2123 | ||
2134 | rfcomm_unlock(); | 2124 | rfcomm_unlock(); |
2135 | 2125 | ||
2136 | return (str - buf); | 2126 | return 0; |
2127 | } | ||
2128 | |||
2129 | static int rfcomm_dlc_debugfs_open(struct inode *inode, struct file *file) | ||
2130 | { | ||
2131 | return single_open(file, rfcomm_dlc_debugfs_show, inode->i_private); | ||
2137 | } | 2132 | } |
2138 | 2133 | ||
2139 | static CLASS_ATTR(rfcomm_dlc, S_IRUGO, rfcomm_dlc_sysfs_show, NULL); | 2134 | static const struct file_operations rfcomm_dlc_debugfs_fops = { |
2135 | .open = rfcomm_dlc_debugfs_open, | ||
2136 | .read = seq_read, | ||
2137 | .llseek = seq_lseek, | ||
2138 | .release = single_release, | ||
2139 | }; | ||
2140 | |||
2141 | static struct dentry *rfcomm_dlc_debugfs; | ||
2140 | 2142 | ||
2141 | /* ---- Initialization ---- */ | 2143 | /* ---- Initialization ---- */ |
2142 | static int __init rfcomm_init(void) | 2144 | static int __init rfcomm_init(void) |
@@ -2153,8 +2155,12 @@ static int __init rfcomm_init(void) | |||
2153 | goto unregister; | 2155 | goto unregister; |
2154 | } | 2156 | } |
2155 | 2157 | ||
2156 | if (class_create_file(bt_class, &class_attr_rfcomm_dlc) < 0) | 2158 | if (bt_debugfs) { |
2157 | BT_ERR("Failed to create RFCOMM info file"); | 2159 | rfcomm_dlc_debugfs = debugfs_create_file("rfcomm_dlc", 0444, |
2160 | bt_debugfs, NULL, &rfcomm_dlc_debugfs_fops); | ||
2161 | if (!rfcomm_dlc_debugfs) | ||
2162 | BT_ERR("Failed to create RFCOMM debug file"); | ||
2163 | } | ||
2158 | 2164 | ||
2159 | err = rfcomm_init_ttys(); | 2165 | err = rfcomm_init_ttys(); |
2160 | if (err < 0) | 2166 | if (err < 0) |
@@ -2182,7 +2188,7 @@ unregister: | |||
2182 | 2188 | ||
2183 | static void __exit rfcomm_exit(void) | 2189 | static void __exit rfcomm_exit(void) |
2184 | { | 2190 | { |
2185 | class_remove_file(bt_class, &class_attr_rfcomm_dlc); | 2191 | debugfs_remove(rfcomm_dlc_debugfs); |
2186 | 2192 | ||
2187 | hci_unregister_cb(&rfcomm_cb); | 2193 | hci_unregister_cb(&rfcomm_cb); |
2188 | 2194 | ||