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 /kernel | |
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 'kernel')
-rw-r--r-- | kernel/trace/blktrace.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index cdea7b56b0c9..c0bd0308741c 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c | |||
@@ -311,13 +311,6 @@ int blk_trace_remove(struct request_queue *q) | |||
311 | } | 311 | } |
312 | EXPORT_SYMBOL_GPL(blk_trace_remove); | 312 | EXPORT_SYMBOL_GPL(blk_trace_remove); |
313 | 313 | ||
314 | static int blk_dropped_open(struct inode *inode, struct file *filp) | ||
315 | { | ||
316 | filp->private_data = inode->i_private; | ||
317 | |||
318 | return 0; | ||
319 | } | ||
320 | |||
321 | static ssize_t blk_dropped_read(struct file *filp, char __user *buffer, | 314 | static ssize_t blk_dropped_read(struct file *filp, char __user *buffer, |
322 | size_t count, loff_t *ppos) | 315 | size_t count, loff_t *ppos) |
323 | { | 316 | { |
@@ -331,18 +324,11 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer, | |||
331 | 324 | ||
332 | static const struct file_operations blk_dropped_fops = { | 325 | static const struct file_operations blk_dropped_fops = { |
333 | .owner = THIS_MODULE, | 326 | .owner = THIS_MODULE, |
334 | .open = blk_dropped_open, | 327 | .open = simple_open, |
335 | .read = blk_dropped_read, | 328 | .read = blk_dropped_read, |
336 | .llseek = default_llseek, | 329 | .llseek = default_llseek, |
337 | }; | 330 | }; |
338 | 331 | ||
339 | static int blk_msg_open(struct inode *inode, struct file *filp) | ||
340 | { | ||
341 | filp->private_data = inode->i_private; | ||
342 | |||
343 | return 0; | ||
344 | } | ||
345 | |||
346 | static ssize_t blk_msg_write(struct file *filp, const char __user *buffer, | 332 | static ssize_t blk_msg_write(struct file *filp, const char __user *buffer, |
347 | size_t count, loff_t *ppos) | 333 | size_t count, loff_t *ppos) |
348 | { | 334 | { |
@@ -371,7 +357,7 @@ static ssize_t blk_msg_write(struct file *filp, const char __user *buffer, | |||
371 | 357 | ||
372 | static const struct file_operations blk_msg_fops = { | 358 | static const struct file_operations blk_msg_fops = { |
373 | .owner = THIS_MODULE, | 359 | .owner = THIS_MODULE, |
374 | .open = blk_msg_open, | 360 | .open = simple_open, |
375 | .write = blk_msg_write, | 361 | .write = blk_msg_write, |
376 | .llseek = noop_llseek, | 362 | .llseek = noop_llseek, |
377 | }; | 363 | }; |