diff options
author | Roland Dreier <roland@topspin.com> | 2005-04-16 18:26:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:26:07 -0400 |
commit | 9adec1a808603698bd7ff47f3883bd7cd1383f90 (patch) | |
tree | 93f41cfab8daa84afd5d387074bf1493ada1a210 /drivers/infiniband/ulp/ipoib | |
parent | e6ded99cbbbfef2cef537d717ad61d2f77f4dfd6 (diff) |
[PATCH] IPoIB: convert to debugfs
Convert IPoIB to use debugfs instead of its own custom debugging filesystem.
Signed-off-by: Roland Dreier <roland@topspin.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/infiniband/ulp/ipoib')
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_fs.c | 140 | ||||
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_main.c | 8 |
2 files changed, 18 insertions, 130 deletions
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_fs.c b/drivers/infiniband/ulp/ipoib/ipoib_fs.c index 044f2c78ef15..a84e5fe0f193 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_fs.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_fs.c | |||
@@ -32,19 +32,16 @@ | |||
32 | * $Id: ipoib_fs.c 1389 2004-12-27 22:56:47Z roland $ | 32 | * $Id: ipoib_fs.c 1389 2004-12-27 22:56:47Z roland $ |
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include <linux/pagemap.h> | 35 | #include <linux/err.h> |
36 | #include <linux/seq_file.h> | 36 | #include <linux/seq_file.h> |
37 | 37 | ||
38 | #include "ipoib.h" | 38 | struct file_operations; |
39 | 39 | ||
40 | enum { | 40 | #include <linux/debugfs.h> |
41 | IPOIB_MAGIC = 0x49504942 /* "IPIB" */ | 41 | |
42 | }; | 42 | #include "ipoib.h" |
43 | 43 | ||
44 | static DECLARE_MUTEX(ipoib_fs_mutex); | ||
45 | static struct dentry *ipoib_root; | 44 | static struct dentry *ipoib_root; |
46 | static struct super_block *ipoib_sb; | ||
47 | static LIST_HEAD(ipoib_device_list); | ||
48 | 45 | ||
49 | static void *ipoib_mcg_seq_start(struct seq_file *file, loff_t *pos) | 46 | static void *ipoib_mcg_seq_start(struct seq_file *file, loff_t *pos) |
50 | { | 47 | { |
@@ -145,143 +142,34 @@ static struct file_operations ipoib_fops = { | |||
145 | .release = seq_release | 142 | .release = seq_release |
146 | }; | 143 | }; |
147 | 144 | ||
148 | static struct inode *ipoib_get_inode(void) | 145 | int ipoib_create_debug_file(struct net_device *dev) |
149 | { | ||
150 | struct inode *inode = new_inode(ipoib_sb); | ||
151 | |||
152 | if (inode) { | ||
153 | inode->i_mode = S_IFREG | S_IRUGO; | ||
154 | inode->i_uid = 0; | ||
155 | inode->i_gid = 0; | ||
156 | inode->i_blksize = PAGE_CACHE_SIZE; | ||
157 | inode->i_blocks = 0; | ||
158 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | ||
159 | inode->i_fop = &ipoib_fops; | ||
160 | } | ||
161 | |||
162 | return inode; | ||
163 | } | ||
164 | |||
165 | static int __ipoib_create_debug_file(struct net_device *dev) | ||
166 | { | 146 | { |
167 | struct ipoib_dev_priv *priv = netdev_priv(dev); | 147 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
168 | struct dentry *dentry; | ||
169 | struct inode *inode; | ||
170 | char name[IFNAMSIZ + sizeof "_mcg"]; | 148 | char name[IFNAMSIZ + sizeof "_mcg"]; |
171 | 149 | ||
172 | snprintf(name, sizeof name, "%s_mcg", dev->name); | 150 | snprintf(name, sizeof name, "%s_mcg", dev->name); |
173 | 151 | ||
174 | dentry = d_alloc_name(ipoib_root, name); | 152 | priv->mcg_dentry = debugfs_create_file(name, S_IFREG | S_IRUGO, |
175 | if (!dentry) | 153 | ipoib_root, dev, &ipoib_fops); |
176 | return -ENOMEM; | ||
177 | |||
178 | inode = ipoib_get_inode(); | ||
179 | if (!inode) { | ||
180 | dput(dentry); | ||
181 | return -ENOMEM; | ||
182 | } | ||
183 | |||
184 | inode->u.generic_ip = dev; | ||
185 | priv->mcg_dentry = dentry; | ||
186 | |||
187 | d_add(dentry, inode); | ||
188 | |||
189 | return 0; | ||
190 | } | ||
191 | |||
192 | int ipoib_create_debug_file(struct net_device *dev) | ||
193 | { | ||
194 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
195 | |||
196 | down(&ipoib_fs_mutex); | ||
197 | |||
198 | list_add_tail(&priv->fs_list, &ipoib_device_list); | ||
199 | |||
200 | if (!ipoib_sb) { | ||
201 | up(&ipoib_fs_mutex); | ||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | up(&ipoib_fs_mutex); | ||
206 | 154 | ||
207 | return __ipoib_create_debug_file(dev); | 155 | return priv->mcg_dentry ? 0 : -ENOMEM; |
208 | } | 156 | } |
209 | 157 | ||
210 | void ipoib_delete_debug_file(struct net_device *dev) | 158 | void ipoib_delete_debug_file(struct net_device *dev) |
211 | { | 159 | { |
212 | struct ipoib_dev_priv *priv = netdev_priv(dev); | 160 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
213 | 161 | ||
214 | down(&ipoib_fs_mutex); | 162 | if (priv->mcg_dentry) |
215 | list_del(&priv->fs_list); | 163 | debugfs_remove(priv->mcg_dentry); |
216 | if (!ipoib_sb) { | ||
217 | up(&ipoib_fs_mutex); | ||
218 | return; | ||
219 | } | ||
220 | up(&ipoib_fs_mutex); | ||
221 | |||
222 | if (priv->mcg_dentry) { | ||
223 | d_drop(priv->mcg_dentry); | ||
224 | simple_unlink(ipoib_root->d_inode, priv->mcg_dentry); | ||
225 | } | ||
226 | } | ||
227 | |||
228 | static int ipoib_fill_super(struct super_block *sb, void *data, int silent) | ||
229 | { | ||
230 | static struct tree_descr ipoib_files[] = { | ||
231 | { "" } | ||
232 | }; | ||
233 | struct ipoib_dev_priv *priv; | ||
234 | int ret; | ||
235 | |||
236 | ret = simple_fill_super(sb, IPOIB_MAGIC, ipoib_files); | ||
237 | if (ret) | ||
238 | return ret; | ||
239 | |||
240 | ipoib_root = sb->s_root; | ||
241 | |||
242 | down(&ipoib_fs_mutex); | ||
243 | |||
244 | ipoib_sb = sb; | ||
245 | |||
246 | list_for_each_entry(priv, &ipoib_device_list, fs_list) { | ||
247 | ret = __ipoib_create_debug_file(priv->dev); | ||
248 | if (ret) | ||
249 | break; | ||
250 | } | ||
251 | |||
252 | up(&ipoib_fs_mutex); | ||
253 | |||
254 | return ret; | ||
255 | } | ||
256 | |||
257 | static struct super_block *ipoib_get_sb(struct file_system_type *fs_type, | ||
258 | int flags, const char *dev_name, void *data) | ||
259 | { | ||
260 | return get_sb_single(fs_type, flags, data, ipoib_fill_super); | ||
261 | } | 164 | } |
262 | 165 | ||
263 | static void ipoib_kill_sb(struct super_block *sb) | ||
264 | { | ||
265 | down(&ipoib_fs_mutex); | ||
266 | ipoib_sb = NULL; | ||
267 | up(&ipoib_fs_mutex); | ||
268 | |||
269 | kill_litter_super(sb); | ||
270 | } | ||
271 | |||
272 | static struct file_system_type ipoib_fs_type = { | ||
273 | .owner = THIS_MODULE, | ||
274 | .name = "ipoib_debugfs", | ||
275 | .get_sb = ipoib_get_sb, | ||
276 | .kill_sb = ipoib_kill_sb, | ||
277 | }; | ||
278 | |||
279 | int ipoib_register_debugfs(void) | 166 | int ipoib_register_debugfs(void) |
280 | { | 167 | { |
281 | return register_filesystem(&ipoib_fs_type); | 168 | ipoib_root = debugfs_create_dir("ipoib", NULL); |
169 | return ipoib_root ? 0 : -ENOMEM; | ||
282 | } | 170 | } |
283 | 171 | ||
284 | void ipoib_unregister_debugfs(void) | 172 | void ipoib_unregister_debugfs(void) |
285 | { | 173 | { |
286 | unregister_filesystem(&ipoib_fs_type); | 174 | debugfs_remove(ipoib_root); |
287 | } | 175 | } |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 8d35475a1d56..6f60abbaebd5 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c | |||
@@ -1082,19 +1082,19 @@ static int __init ipoib_init_module(void) | |||
1082 | 1082 | ||
1083 | return 0; | 1083 | return 0; |
1084 | 1084 | ||
1085 | err_fs: | ||
1086 | ipoib_unregister_debugfs(); | ||
1087 | |||
1088 | err_wq: | 1085 | err_wq: |
1089 | destroy_workqueue(ipoib_workqueue); | 1086 | destroy_workqueue(ipoib_workqueue); |
1090 | 1087 | ||
1088 | err_fs: | ||
1089 | ipoib_unregister_debugfs(); | ||
1090 | |||
1091 | return ret; | 1091 | return ret; |
1092 | } | 1092 | } |
1093 | 1093 | ||
1094 | static void __exit ipoib_cleanup_module(void) | 1094 | static void __exit ipoib_cleanup_module(void) |
1095 | { | 1095 | { |
1096 | ipoib_unregister_debugfs(); | ||
1097 | ib_unregister_client(&ipoib_client); | 1096 | ib_unregister_client(&ipoib_client); |
1097 | ipoib_unregister_debugfs(); | ||
1098 | destroy_workqueue(ipoib_workqueue); | 1098 | destroy_workqueue(ipoib_workqueue); |
1099 | } | 1099 | } |
1100 | 1100 | ||