diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-06-09 20:33:28 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-07-14 08:35:25 -0400 |
commit | cfa57c11b0d5a80f7bffa1ab35bc46892127817f (patch) | |
tree | 7b86c2c918e0790fa8623c49874f7b3c11477c25 /fs | |
parent | c3b1a350846a11dd1054cb7832e098aa37025deb (diff) |
debugfs: fold debugfs_create_by_name() into the only caller
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/debugfs/inode.c | 53 |
1 files changed, 20 insertions, 33 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index d423b966bc79..79f53f3ce7c6 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c | |||
@@ -293,13 +293,19 @@ static struct file_system_type debug_fs_type = { | |||
293 | .kill_sb = kill_litter_super, | 293 | .kill_sb = kill_litter_super, |
294 | }; | 294 | }; |
295 | 295 | ||
296 | static int debugfs_create_by_name(const char *name, umode_t mode, | 296 | struct dentry *__create_file(const char *name, umode_t mode, |
297 | struct dentry *parent, | 297 | struct dentry *parent, void *data, |
298 | struct dentry **dentry, | 298 | const struct file_operations *fops) |
299 | void *data, | ||
300 | const struct file_operations *fops) | ||
301 | { | 299 | { |
302 | int error = 0; | 300 | struct dentry *dentry = NULL; |
301 | int error; | ||
302 | |||
303 | pr_debug("debugfs: creating file '%s'\n",name); | ||
304 | |||
305 | error = simple_pin_fs(&debug_fs_type, &debugfs_mount, | ||
306 | &debugfs_mount_count); | ||
307 | if (error) | ||
308 | goto exit; | ||
303 | 309 | ||
304 | /* If the parent is not specified, we create it in the root. | 310 | /* If the parent is not specified, we create it in the root. |
305 | * We need the root dentry to do this, which is in the super | 311 | * We need the root dentry to do this, which is in the super |
@@ -309,48 +315,29 @@ static int debugfs_create_by_name(const char *name, umode_t mode, | |||
309 | if (!parent) | 315 | if (!parent) |
310 | parent = debugfs_mount->mnt_root; | 316 | parent = debugfs_mount->mnt_root; |
311 | 317 | ||
312 | *dentry = NULL; | 318 | dentry = NULL; |
313 | mutex_lock(&parent->d_inode->i_mutex); | 319 | mutex_lock(&parent->d_inode->i_mutex); |
314 | *dentry = lookup_one_len(name, parent, strlen(name)); | 320 | dentry = lookup_one_len(name, parent, strlen(name)); |
315 | if (!IS_ERR(*dentry)) { | 321 | if (!IS_ERR(dentry)) { |
316 | switch (mode & S_IFMT) { | 322 | switch (mode & S_IFMT) { |
317 | case S_IFDIR: | 323 | case S_IFDIR: |
318 | error = debugfs_mkdir(parent->d_inode, *dentry, mode, | 324 | error = debugfs_mkdir(parent->d_inode, dentry, mode, |
319 | data, fops); | 325 | data, fops); |
320 | break; | 326 | break; |
321 | case S_IFLNK: | 327 | case S_IFLNK: |
322 | error = debugfs_link(parent->d_inode, *dentry, mode, | 328 | error = debugfs_link(parent->d_inode, dentry, mode, |
323 | data, fops); | 329 | data, fops); |
324 | break; | 330 | break; |
325 | default: | 331 | default: |
326 | error = debugfs_create(parent->d_inode, *dentry, mode, | 332 | error = debugfs_create(parent->d_inode, dentry, mode, |
327 | data, fops); | 333 | data, fops); |
328 | break; | 334 | break; |
329 | } | 335 | } |
330 | dput(*dentry); | 336 | dput(dentry); |
331 | } else | 337 | } else |
332 | error = PTR_ERR(*dentry); | 338 | error = PTR_ERR(dentry); |
333 | mutex_unlock(&parent->d_inode->i_mutex); | 339 | mutex_unlock(&parent->d_inode->i_mutex); |
334 | 340 | ||
335 | return error; | ||
336 | } | ||
337 | |||
338 | struct dentry *__create_file(const char *name, umode_t mode, | ||
339 | struct dentry *parent, void *data, | ||
340 | const struct file_operations *fops) | ||
341 | { | ||
342 | struct dentry *dentry = NULL; | ||
343 | int error; | ||
344 | |||
345 | pr_debug("debugfs: creating file '%s'\n",name); | ||
346 | |||
347 | error = simple_pin_fs(&debug_fs_type, &debugfs_mount, | ||
348 | &debugfs_mount_count); | ||
349 | if (error) | ||
350 | goto exit; | ||
351 | |||
352 | error = debugfs_create_by_name(name, mode, parent, &dentry, | ||
353 | data, fops); | ||
354 | if (error) { | 341 | if (error) { |
355 | dentry = NULL; | 342 | dentry = NULL; |
356 | simple_release_fs(&debugfs_mount, &debugfs_mount_count); | 343 | simple_release_fs(&debugfs_mount, &debugfs_mount_count); |