From: Harsha Sharma <harshasharmaiitr@gmail.com>
To: tomi.valkeinen@ti.com, airlied@linux.ie
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
outreachy-kernel@googlegroups.com,
Harsha Sharma <harshasharmaiitr@gmail.com>
Subject: [PATCH] drm/omap: Replace list_for_each with list_for_each_entry
Date: Sun, 15 Oct 2017 01:39:42 +0530 [thread overview]
Message-ID: <20171014200942.27388-1-harshasharmaiitr@gmail.com> (raw)
Replace use of list_for_each with list_for_each_entry to simplify the
code and remove variables that are used only in list_for_each.
Done with following coccinelle patch:
@r@
identifier fn,i,f,p;
expression e;
iterator name list_for_each, list_for_each_entry;
type T;
@@
fn(...) {
++ T *i;
<+...
- list_for_each(p,e)
+ list_for_each_entry(i,e,f)
{
...
- T *i = list_entry(p,T,f);
...
}
...+>
}
@@
identifier r.fn,r.p;
@@
fn(...) {
...
- struct list_head *p;
... when != p
}
@@
identifier r.fn,r.i,r.f;
expression r.e;
statement S;
@@
fn(...) {
<...
list_for_each_entry(i,e,f)
- {
S
- }
...>
}
@s@
identifier i,f,p;
expression e;
type T;
@@
- list_for_each(p,e)
+ list_for_each_entry(i,e,f)
{
... when != T *i;
- i = list_entry(p,T,f);
...
}
@@
identifier s.p;
@@
- struct list_head *p;
... when != p
@@
identifier s.i,s.f;
expression s.e;
statement S;
@@
list_for_each_entry(i,e,f)
- {
S
- }
Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
---
drivers/gpu/drm/omapdrm/dss/display.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c
index 42279933790e..e6f86026dd93 100644
--- a/drivers/gpu/drm/omapdrm/dss/display.c
+++ b/drivers/gpu/drm/omapdrm/dss/display.c
@@ -43,6 +43,7 @@ static int disp_num_counter;
int omapdss_register_display(struct omap_dss_device *dssdev)
{
+ struct omp_dss_device *ldev;
struct omap_dss_driver *drv = dssdev->driver;
struct list_head *cur;
int id;
@@ -67,13 +68,9 @@ int omapdss_register_display(struct omap_dss_device *dssdev)
drv->get_timings = omapdss_default_get_timings;
mutex_lock(&panel_list_mutex);
- list_for_each(cur, &panel_list) {
- struct omap_dss_device *ldev = list_entry(cur,
- struct omap_dss_device,
- panel_list);
+ list_for_each_entry(ldev, &panel_list, panel_list)
if (strcmp(ldev->alias, dssdev->alias) > 0)
break;
- }
list_add_tail(&dssdev->panel_list, cur);
mutex_unlock(&panel_list_mutex);
return 0;
@@ -94,12 +91,11 @@ bool omapdss_component_is_display(struct device_node *node)
bool found = false;
mutex_lock(&panel_list_mutex);
- list_for_each_entry(dssdev, &panel_list, panel_list) {
+ list_for_each_entry(dssdev, &panel_list, panel_list)
if (dssdev->dev->of_node == node) {
found = true;
goto out;
}
- }
out:
mutex_unlock(&panel_list_mutex);
return found;
@@ -152,8 +148,7 @@ struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from)
omap_dss_put_device(from);
- list_for_each(l, &panel_list) {
- dssdev = list_entry(l, struct omap_dss_device, panel_list);
+ list_for_each_entry(dssdev, &panel_list, panel_list)
if (dssdev == from) {
if (list_is_last(l, &panel_list)) {
dssdev = NULL;
@@ -165,7 +160,6 @@ struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from)
omap_dss_get_device(dssdev);
goto out;
}
- }
WARN(1, "'from' dssdev not found\n");
--
2.11.0
next reply other threads:[~2017-10-14 20:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-14 20:09 Harsha Sharma [this message]
2017-10-16 21:06 ` kbuild test robot
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=20171014200942.27388-1-harshasharmaiitr@gmail.com \
--to=harshasharmaiitr@gmail.com \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=outreachy-kernel@googlegroups.com \
--cc=tomi.valkeinen@ti.com \
/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
all inboxes | Powered by JetHome®