simple_open: automatically convert to simple_open()

Many users of debugfs copy the implementation of default_open() when
they want to support a custom read/write function op.  This leads to a
proliferation of the default_open() implementation across the entire
tree.

Now that the common implementation has been consolidated into libfs we
can replace all the users of this function with simple_open().

This replacement was done with the following semantic patch:

<smpl>
@ open @
identifier open_f != simple_open;
identifier i, f;
@@
-int open_f(struct inode *i, struct file *f)
-{
(
-if (i->i_private)
-f->private_data = i->i_private;
|
-f->private_data = i->i_private;
)
-return 0;
-}

@ has_open depends on open @
identifier fops;
identifier open.open_f;
@@
struct file_operations fops = {
...
-.open = open_f,
+.open = simple_open,
...
};
</smpl>

[[email protected]: checkpatch fixes]
Signed-off-by: Stephen Boyd <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Julia Lawall <[email protected]>
Acked-by: Ingo Molnar <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
Stephen Boyd 2012-04-05 14:25:11 -07:00 • committed by Linus Torvalds
commit 234e340582
63 changed files with 176 additions and 572 deletions

View file

@ -516,12 +516,6 @@ static struct notifier_block i7300_idle_nb = {
MODULE_DEVICE_TABLE(pci, pci_tbl);
int stats_open_generic(struct inode *inode, struct file *fp)
{
fp->private_data = inode->i_private;
return 0;
}
static ssize_t stats_read_ul(struct file *fp, char __user *ubuf, size_t count,
loff_t *off)
{
@ -534,7 +528,7 @@ static ssize_t stats_read_ul(struct file *fp, char __user *ubuf, size_t count,
}
static const struct file_operations idle_fops = {
.open = stats_open_generic,
.open = simple_open,
.read = stats_read_ul,
.llseek = default_llseek,
};