mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Use list_for_each_entry instead of list_for_each in sound/oss drivers.
@ 2007-11-02 21:10 Julia Lawall
  0 siblings, 0 replies; only message in thread
From: Julia Lawall @ 2007-11-02 21:10 UTC (permalink / raw)
  To: perex; +Cc: paulmck, linux-kernel

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;
  	}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-11-02 22:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-02 21:10 [PATCH] Use list_for_each_entry instead of list_for_each in sound/oss drivers Julia Lawall

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®