Commit 20955e891d828b2027281fe3295dae6af8e0423b

Authored by Stephen Boyd
Committed by Linus Torvalds
1 parent 7563ec4c21

libfs: add simple_open()

debugfs and a few other drivers use an open-coded version of
simple_open() to pass a pointer from the file to the read/write file
ops.  Add support for this simple case to libfs so that we can remove
the many duplicate copies of this simple function.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 2 changed files with 9 additions and 0 deletions Side-by-side Diff

... ... @@ -264,6 +264,13 @@
264 264 return ERR_PTR(-ENOMEM);
265 265 }
266 266  
  267 +int simple_open(struct inode *inode, struct file *file)
  268 +{
  269 + if (inode->i_private)
  270 + file->private_data = inode->i_private;
  271 + return 0;
  272 +}
  273 +
267 274 int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
268 275 {
269 276 struct inode *inode = old_dentry->d_inode;
... ... @@ -984,6 +991,7 @@
984 991 EXPORT_SYMBOL(simple_empty);
985 992 EXPORT_SYMBOL(simple_fill_super);
986 993 EXPORT_SYMBOL(simple_getattr);
  994 +EXPORT_SYMBOL(simple_open);
987 995 EXPORT_SYMBOL(simple_link);
988 996 EXPORT_SYMBOL(simple_lookup);
989 997 EXPORT_SYMBOL(simple_pin_fs);
... ... @@ -2502,6 +2502,7 @@
2502 2502 extern int simple_setattr(struct dentry *, struct iattr *);
2503 2503 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
2504 2504 extern int simple_statfs(struct dentry *, struct kstatfs *);
  2505 +extern int simple_open(struct inode *inode, struct file *file);
2505 2506 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
2506 2507 extern int simple_unlink(struct inode *, struct dentry *);
2507 2508 extern int simple_rmdir(struct inode *, struct dentry *);