diff options
author | Stephen Boyd <sboyd@codeaurora.org> | 2012-04-05 17:25:11 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-04-05 18:25:50 -0400 |
commit | 234e340582901211f40d8c732afc49f0630ecf05 (patch) | |
tree | 753076500dfd883b3db56d4f5410af31d8945623 /drivers/tty | |
parent | 9b3ae64be658a573b33d05a8dc73b08d3345fa44 (diff) |
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>
[akpm@linux-foundation.org: checkpatch fixes]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/serial/mfd.c | 9 | ||||
-rw-r--r-- | drivers/tty/serial/pch_uart.c | 8 |
2 files changed, 4 insertions, 13 deletions
diff --git a/drivers/tty/serial/mfd.c b/drivers/tty/serial/mfd.c index a9234ba8f8d5..c4b50af46c44 100644 --- a/drivers/tty/serial/mfd.c +++ b/drivers/tty/serial/mfd.c | |||
@@ -127,11 +127,6 @@ static inline void serial_out(struct uart_hsu_port *up, int offset, int value) | |||
127 | 127 | ||
128 | #define HSU_REGS_BUFSIZE 1024 | 128 | #define HSU_REGS_BUFSIZE 1024 |
129 | 129 | ||
130 | static int hsu_show_regs_open(struct inode *inode, struct file *file) | ||
131 | { | ||
132 | file->private_data = inode->i_private; | ||
133 | return 0; | ||
134 | } | ||
135 | 130 | ||
136 | static ssize_t port_show_regs(struct file *file, char __user *user_buf, | 131 | static ssize_t port_show_regs(struct file *file, char __user *user_buf, |
137 | size_t count, loff_t *ppos) | 132 | size_t count, loff_t *ppos) |
@@ -231,14 +226,14 @@ static ssize_t dma_show_regs(struct file *file, char __user *user_buf, | |||
231 | 226 | ||
232 | static const struct file_operations port_regs_ops = { | 227 | static const struct file_operations port_regs_ops = { |
233 | .owner = THIS_MODULE, | 228 | .owner = THIS_MODULE, |
234 | .open = hsu_show_regs_open, | 229 | .open = simple_open, |
235 | .read = port_show_regs, | 230 | .read = port_show_regs, |
236 | .llseek = default_llseek, | 231 | .llseek = default_llseek, |
237 | }; | 232 | }; |
238 | 233 | ||
239 | static const struct file_operations dma_regs_ops = { | 234 | static const struct file_operations dma_regs_ops = { |
240 | .owner = THIS_MODULE, | 235 | .owner = THIS_MODULE, |
241 | .open = hsu_show_regs_open, | 236 | .open = simple_open, |
242 | .read = dma_show_regs, | 237 | .read = dma_show_regs, |
243 | .llseek = default_llseek, | 238 | .llseek = default_llseek, |
244 | }; | 239 | }; |
diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c index 332f2eb8abbc..46ec722b4406 100644 --- a/drivers/tty/serial/pch_uart.c +++ b/drivers/tty/serial/pch_uart.c | |||
@@ -304,11 +304,7 @@ static const int trigger_level_1[4] = { 1, 1, 1, 1 }; | |||
304 | #ifdef CONFIG_DEBUG_FS | 304 | #ifdef CONFIG_DEBUG_FS |
305 | 305 | ||
306 | #define PCH_REGS_BUFSIZE 1024 | 306 | #define PCH_REGS_BUFSIZE 1024 |
307 | static int pch_show_regs_open(struct inode *inode, struct file *file) | 307 | |
308 | { | ||
309 | file->private_data = inode->i_private; | ||
310 | return 0; | ||
311 | } | ||
312 | 308 | ||
313 | static ssize_t port_show_regs(struct file *file, char __user *user_buf, | 309 | static ssize_t port_show_regs(struct file *file, char __user *user_buf, |
314 | size_t count, loff_t *ppos) | 310 | size_t count, loff_t *ppos) |
@@ -362,7 +358,7 @@ static ssize_t port_show_regs(struct file *file, char __user *user_buf, | |||
362 | 358 | ||
363 | static const struct file_operations port_regs_ops = { | 359 | static const struct file_operations port_regs_ops = { |
364 | .owner = THIS_MODULE, | 360 | .owner = THIS_MODULE, |
365 | .open = pch_show_regs_open, | 361 | .open = simple_open, |
366 | .read = port_show_regs, | 362 | .read = port_show_regs, |
367 | .llseek = default_llseek, | 363 | .llseek = default_llseek, |
368 | }; | 364 | }; |