mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
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:
parent
9b3ae64be6
commit
234e340582
63 changed files with 176 additions and 572 deletions
|
|
@ -428,18 +428,10 @@ static loff_t default_file_lseek (struct file *file, loff_t offset, int orig)
|
|||
return retval;
|
||||
}
|
||||
|
||||
static int default_open (struct inode *inode, struct file *file)
|
||||
{
|
||||
if (inode->i_private)
|
||||
file->private_data = inode->i_private;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct file_operations default_file_operations = {
|
||||
.read = default_read_file,
|
||||
.write = default_write_file,
|
||||
.open = default_open,
|
||||
.open = simple_open,
|
||||
.llseek = default_file_lseek,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -352,7 +352,6 @@ static int debug_async_open(struct inode *, struct file *);
|
|||
static int debug_periodic_open(struct inode *, struct file *);
|
||||
static int debug_registers_open(struct inode *, struct file *);
|
||||
static int debug_async_open(struct inode *, struct file *);
|
||||
static int debug_lpm_open(struct inode *, struct file *);
|
||||
static ssize_t debug_lpm_read(struct file *file, char __user *user_buf,
|
||||
size_t count, loff_t *ppos);
|
||||
static ssize_t debug_lpm_write(struct file *file, const char __user *buffer,
|
||||
|
|
@ -385,7 +384,7 @@ static const struct file_operations debug_registers_fops = {
|
|||
};
|
||||
static const struct file_operations debug_lpm_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = debug_lpm_open,
|
||||
.open = simple_open,
|
||||
.read = debug_lpm_read,
|
||||
.write = debug_lpm_write,
|
||||
.release = debug_lpm_close,
|
||||
|
|
@ -970,12 +969,6 @@ static int debug_registers_open(struct inode *inode, struct file *file)
|
|||
return file->private_data ? 0 : -ENOMEM;
|
||||
}
|
||||
|
||||
static int debug_lpm_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
file->private_data = inode->i_private;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int debug_lpm_close(struct inode *inode, struct file *file)
|
||||
{
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue