From: Julia Lawall <julia@diku.dk>
To: perex@suse.cz
Cc: paulmck@linux.vnet.ibm.com, linux-kernel@vger.kernel.org
Subject: [PATCH] Use list_for_each_entry instead of list_for_each in sound/oss drivers.
Date: Fri, 2 Nov 2007 22:10:50 +0100 (CET) [thread overview]
Message-ID: <Pine.LNX.4.64.0711022207140.489@ask.diku.dk> (raw)
From: Julia Lawall <julia@diku.dk>
Combine list_for_each and list_entry into list_for_each_entry.
An excerpt of the semantic patch implementing these changes is as follows:
@ra@
type T,T1;
identifier I, x;
expression E, E1, E2;
iterator list_for_each_entry;
@@
<... when != _Y(I)
- list_for_each(_X(I),E1)
+ list_for_each_entry(x,E1,E2)
{
... when != \(_Y(I)\|_X(I)\|x=E\)
when != T1 x;
- x = list_entry(_X(I),T,E2);
... when != \(_Y(I)\|_X(I)\|x=E\)
}
...>
@@
type T;
identifier I;
expression E1, E2;
@@
- struct list_head *I;
+ T *I;
<+... when != _Y(I)
- list_for_each(_X(I),E1)
+ list_for_each_entry(I,E1,E2)
{
<+... when != _Y(I)
- list_entry(_X(I),T,E2)
+ I
...+>
}
...+>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
diff -u -p -b -B a/sound/oss/ac97_codec.c b/sound/oss/ac97_codec.c
--- a/sound/oss/ac97_codec.c 2007-06-02 22:32:47.000000000 +0200
+++ b/sound/oss/ac97_codec.c 2007-11-02 07:27:37.000000000 +0100
@@ -815,7 +815,6 @@ int ac97_probe_codec(struct ac97_codec *
int i;
char cidbuf[CODEC_ID_BUFSZ];
u16 f;
- struct list_head *l;
struct ac97_driver *d;
/* wait for codec-ready state */
@@ -891,8 +890,7 @@ int ac97_probe_codec(struct ac97_codec *
mutex_lock(&codec_mutex);
list_add(&codec->list, &codecs);
- list_for_each(l, &codec_drivers) {
- d = list_entry(l, struct ac97_driver, list);
+ list_for_each_entry(d, &codec_drivers, list) {
if ((codec->model ^ d->codec_id) & d->codec_mask)
continue;
if(d->probe(codec, d) == 0)
@@ -1400,14 +1398,12 @@ EXPORT_SYMBOL(ac97_set_adc_rate);
static int swap_headphone(int remove_master)
{
- struct list_head *l;
struct ac97_codec *c;
if (remove_master) {
mutex_lock(&codec_mutex);
- list_for_each(l, &codecs)
+ list_for_each_entry(c, &codecs, list)
{
- c = list_entry(l, struct ac97_codec, list);
if (supported_mixer(c, SOUND_MIXER_PHONEOUT))
c->supported_mixers &= ~SOUND_MASK_PHONEOUT;
}
diff -u -p -b -B a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
--- a/sound/oss/swarm_cs4297a.c 2007-06-02 22:32:47.000000000 +0200
+++ b/sound/oss/swarm_cs4297a.c 2007-11-02 07:27:46.000000000 +0100
@@ -1532,14 +1532,12 @@ static int cs4297a_open_mixdev(struct in
{
int minor = iminor(inode);
struct cs4297a_state *s=NULL;
- struct list_head *entry;
CS_DBGOUT(CS_FUNCTION | CS_OPEN, 4,
printk(KERN_INFO "cs4297a: cs4297a_open_mixdev()+\n"));
- list_for_each(entry, &cs4297a_devs)
+ list_for_each_entry(s, &cs4297a_devs, list)
{
- s = list_entry(entry, struct cs4297a_state, list);
if(s->dev_mixer == minor)
break;
}
reply other threads:[~2007-11-02 22:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=Pine.LNX.4.64.0711022207140.489@ask.diku.dk \
--to=julia@diku.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=perex@suse.cz \
/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®