From: Stephen Boyd <sboyd@codeaurora.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Julia Lawall <Julia.Lawall@lip6.fr>
Subject: [PATCH 2/2] coccinelle: semantic patch for simple_open()
Date: Sat, 3 Mar 2012 02:06:20 -0800 [thread overview]
Message-ID: <1330769180-22354-3-git-send-email-sboyd@codeaurora.org> (raw)
In-Reply-To: <1330769180-22354-1-git-send-email-sboyd@codeaurora.org>
Find instances of an open-coded simple_open() and replace them
with calls to simple_open().
Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
This seems to eat the definition of simple_open() as well. Is there
a way to say only remove both the function and the reference to
the function so that libfs survives?
scripts/coccinelle/api/simple_open.cocci | 34 ++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
create mode 100644 scripts/coccinelle/api/simple_open.cocci
diff --git a/scripts/coccinelle/api/simple_open.cocci b/scripts/coccinelle/api/simple_open.cocci
new file mode 100644
index 0000000..956d04d
--- /dev/null
+++ b/scripts/coccinelle/api/simple_open.cocci
@@ -0,0 +1,34 @@
+// This removes an open coded simple_open() function
+// and replaces file operations references to the function
+// with simple_open() instead.
+//
+
+virtual patch
+virtual context
+
+@ open @
+identifier open_f;
+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,
+...
+};
+
--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
next prev parent reply other threads:[~2012-03-03 10:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-03 10:06 [PATCH 0/2] Introduce simple_open() Stephen Boyd
2012-03-03 10:06 ` [PATCH 1/2] libfs: Add simple_open() Stephen Boyd
2012-03-03 10:06 ` Stephen Boyd [this message]
2012-03-03 12:10 ` [PATCH 2/2] coccinelle: semantic patch for simple_open() Julia Lawall
2012-03-06 8:43 ` Stephen Boyd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1330769180-22354-3-git-send-email-sboyd@codeaurora.org \
--to=sboyd@codeaurora.org \
--cc=Julia.Lawall@lip6.fr \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox