2007-09-11 21:06:39

by Matthias Kaehlcke

[permalink] [raw]
Subject: [PATCH 0/4] Several sound drivers: Use list_for_each_entry(_safe)

Use list_for_each_entry(_safe) instead of list_for_each(_safe) in the
following sound drivers/code:

Generic AC97 mixer/modem module (OSS)
ESS Maestro 1/2/2E Sound Card
Intel HD Audio
Routines for effect processor FX8010

--
Matthias Kaehlcke
Linux Application Developer
Barcelona

La libertad es como la ma?ana. Hay quienes esperan dormidos a que
llegue, pero hay quienes desvelan y caminan la noche para alcanzarla
(Subcomandante Marcos)
.''`.
using free software / Debian GNU/Linux | http://debian.org : :' :
`. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `-


2007-09-11 21:05:41

by Matthias Kaehlcke

[permalink] [raw]
Subject: [PATCH 1/4] Generic AC97 mixer/modem (OSS): Use list_for_each_entry

Generic AC97 mixer/modem (OSS): Use list_for_each_entry instead of
list_for_each

Signed-off-by: Matthias Kaehlcke <[email protected]>

--

diff --git a/sound/oss/ac97_codec.c b/sound/oss/ac97_codec.c
index fef56ca..0a3033b 100644
--- a/sound/oss/ac97_codec.c
+++ b/sound/oss/ac97_codec.c
@@ -815,7 +815,6 @@ int ac97_probe_codec(struct ac97_codec *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 *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;
}

--
Matthias Kaehlcke
Linux Application Developer
Barcelona

We build too many walls and not enough bridges
(Isaac Newton)
.''`.
using free software / Debian GNU/Linux | http://debian.org : :' :
`. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `-

2007-09-11 21:08:25

by Matthias Kaehlcke

[permalink] [raw]
Subject: [PATCH 2/4] ESS Maestro 1/2/2E Sound Card: Use list_for_each_entry

ESS Maestro 1/2/2E Sound Card: Use list_for_each_entry instead of
list_for_each

Signed-off-by: Matthias Kaehlcke <[email protected]>

--

diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 2faf009..d69b11d 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -843,10 +843,9 @@ static void snd_es1968_bob_dec(struct es1968 *chip)
snd_es1968_bob_stop(chip);
else if (chip->bob_freq > ESM_BOB_FREQ) {
/* check reduction of timer frequency */
- struct list_head *p;
int max_freq = ESM_BOB_FREQ;
- list_for_each(p, &chip->substream_list) {
- struct esschan *es = list_entry(p, struct esschan, list);
+ struct esschan *es;
+ list_for_each_entry(es, &chip->substream_list, list) {
if (max_freq < es->bob_freq)
max_freq = es->bob_freq;
}
@@ -1316,12 +1315,11 @@ static struct snd_pcm_hardware snd_es1968_capture = {

static int calc_available_memory_size(struct es1968 *chip)
{
- struct list_head *p;
int max_size = 0;
-
+ struct esm_memory *buf;
+
mutex_lock(&chip->memory_mutex);
- list_for_each(p, &chip->buf_list) {
- struct esm_memory *buf = list_entry(p, struct esm_memory, list);
+ list_for_each_entry(buf, &chip->buf_list, list) {
if (buf->empty && buf->buf.bytes > max_size)
max_size = buf->buf.bytes;
}
@@ -1335,12 +1333,10 @@ static int calc_available_memory_size(struct es1968 *chip)
static struct esm_memory *snd_es1968_new_memory(struct es1968 *chip, int size)
{
struct esm_memory *buf;
- struct list_head *p;
-
+
size = ALIGN(size, ESM_MEM_ALIGN);
mutex_lock(&chip->memory_mutex);
- list_for_each(p, &chip->buf_list) {
- buf = list_entry(p, struct esm_memory, list);
+ list_for_each_entry(buf, &chip->buf_list, list) {
if (buf->empty && buf->buf.bytes >= size)
goto __found;
}
@@ -1938,10 +1934,9 @@ static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id)
}

if (event & ESM_SOUND_IRQ) {
- struct list_head *p;
+ struct esschan *es;
spin_lock(&chip->substream_lock);
- list_for_each(p, &chip->substream_list) {
- struct esschan *es = list_entry(p, struct esschan, list);
+ list_for_each_entry(es, &chip->substream_list, list) {
if (es->running)
snd_es1968_update_pcm(chip, es);
}
@@ -2345,7 +2340,7 @@ static int es1968_resume(struct pci_dev *pci)
{
struct snd_card *card = pci_get_drvdata(pci);
struct es1968 *chip = card->private_data;
- struct list_head *p;
+ struct esschan *es;

if (! chip->do_pm)
return 0;
@@ -2374,8 +2369,7 @@ static int es1968_resume(struct pci_dev *pci)
/* restore ac97 state */
snd_ac97_resume(chip->ac97);

- list_for_each(p, &chip->substream_list) {
- struct esschan *es = list_entry(p, struct esschan, list);
+ list_for_each_entry(es, &chip->substream_list, list) {
switch (es->mode) {
case ESM_MODE_PLAY:
snd_es1968_playback_setup(chip, es, es->substream->runtime);


--
Matthias Kaehlcke
Linux Application Developer
Barcelona

Insanity: doing the same thing over and over
again and expecting different results
(Albert Einstein)
.''`.
using free software / Debian GNU/Linux | http://debian.org : :' :
`. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `-

2007-09-11 21:10:40

by Matthias Kaehlcke

[permalink] [raw]
Subject: [PATCH 3/4] Intel HD Audio: Use list_for_each_entry(_safe)

Intel HD Audio: Use list_for_each_entry(_safe) instead of
list_for_each(_safe)

Signed-off-by: Matthias Kaehlcke <[email protected]>

--

diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 000287f..5a96a8a 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -88,13 +88,12 @@ struct hda_gspec {
static void snd_hda_generic_free(struct hda_codec *codec)
{
struct hda_gspec *spec = codec->spec;
- struct list_head *p, *n;
+ struct hda_gnode *node, *n;

if (! spec)
return;
/* free all widgets */
- list_for_each_safe(p, n, &spec->nid_list) {
- struct hda_gnode *node = list_entry(p, struct hda_gnode, list);
+ list_for_each_entry_safe(node, n, &spec->nid_list, list) {
if (node->conn_list != node->slist)
kfree(node->conn_list);
kfree(node);
@@ -196,11 +195,9 @@ static int build_afg_tree(struct hda_codec *codec)
/* FIXME: should avoid the braindead linear search */
static struct hda_gnode *hda_get_node(struct hda_gspec *spec, hda_nid_t nid)
{
- struct list_head *p;
struct hda_gnode *node;

- list_for_each(p, &spec->nid_list) {
- node = list_entry(p, struct hda_gnode, list);
+ list_for_each_entry(node, &spec->nid_list, list) {
if (node->nid == nid)
return node;
}
@@ -256,11 +253,9 @@ static int select_input_connection(struct hda_codec *codec, struct hda_gnode *no
*/
static void clear_check_flags(struct hda_gspec *spec)
{
- struct list_head *p;
struct hda_gnode *node;

- list_for_each(p, &spec->nid_list) {
- node = list_entry(p, struct hda_gnode, list);
+ list_for_each_entry(node, &spec->nid_list, list) {
node->checked = 0;
}
}
@@ -343,12 +338,10 @@ static struct hda_gnode *parse_output_jack(struct hda_codec *codec,
struct hda_gspec *spec,
int jack_type)
{
- struct list_head *p;
struct hda_gnode *node;
int err;

- list_for_each(p, &spec->nid_list) {
- node = list_entry(p, struct hda_gnode, list);
+ list_for_each_entry(node, &spec->nid_list, list) {
if (node->type != AC_WID_PIN)
continue;
/* output capable? */
@@ -659,7 +652,6 @@ static int parse_input_path(struct hda_codec *codec, struct hda_gnode *adc_node)
static int parse_input(struct hda_codec *codec)
{
struct hda_gspec *spec = codec->spec;
- struct list_head *p;
struct hda_gnode *node;
int err;

@@ -668,8 +660,7 @@ static int parse_input(struct hda_codec *codec)
* If it reaches to certain input PINs, we take it as the
* input path.
*/
- list_for_each(p, &spec->nid_list) {
- node = list_entry(p, struct hda_gnode, list);
+ list_for_each_entry(node, &spec->nid_list, list) {
if (node->wid_caps & AC_WCAP_DIGITAL)
continue; /* skip SPDIF */
if (node->type == AC_WID_AUD_IN) {
@@ -911,7 +902,6 @@ static int parse_loopback_path(struct hda_codec *codec, struct hda_gspec *spec,
static int build_loopback_controls(struct hda_codec *codec)
{
struct hda_gspec *spec = codec->spec;
- struct list_head *p;
struct hda_gnode *node;
int err;
const char *type;
@@ -919,8 +909,7 @@ static int build_loopback_controls(struct hda_codec *codec)
if (! spec->out_pin_node[0])
return 0;

- list_for_each(p, &spec->nid_list) {
- node = list_entry(p, struct hda_gnode, list);
+ list_for_each_entry(node, &spec->nid_list, list) {
if (node->type != AC_WID_PIN)
continue;
/* input capable? */
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 92bc8b3..f3ce158 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1322,7 +1322,6 @@ static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec,

static int __devinit azx_pcm_create(struct azx *chip)
{
- struct list_head *p;
struct hda_codec *codec;
int c, err;
int pcm_dev;
@@ -1332,8 +1331,7 @@ static int __devinit azx_pcm_create(struct azx *chip)

/* create audio PCMs */
pcm_dev = 0;
- list_for_each(p, &chip->bus->codec_list) {
- codec = list_entry(p, struct hda_codec, list);
+ list_for_each_entry(codec, &chip->bus->codec_list, list) {
for (c = 0; c < codec->num_pcms; c++) {
if (codec->pcm_info[c].is_modem)
continue; /* create later */
@@ -1350,8 +1348,7 @@ static int __devinit azx_pcm_create(struct azx *chip)

/* create modem PCMs */
pcm_dev = AZX_MAX_AUDIO_PCMS;
- list_for_each(p, &chip->bus->codec_list) {
- codec = list_entry(p, struct hda_codec, list);
+ list_for_each_entry(codec, &chip->bus->codec_list, list) {
for (c = 0; c < codec->num_pcms; c++) {
if (! codec->pcm_info[c].is_modem)
continue; /* already created */


--
Matthias Kaehlcke
Linux Application Developer
Barcelona

C treats you like a consenting adult. Pascal treats you like a
naughty child. Ada treats you like a criminal
(Bruce Powel Douglass)
.''`.
using free software / Debian GNU/Linux | http://debian.org : :' :
`. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `-

2007-09-11 21:12:44

by Matthias Kaehlcke

[permalink] [raw]
Subject: [PATCH 4/4] Routines for effect processor FX8010: Use list_for_each_entry

Routines for effect processor FX8010: Use list_for_each_entry instead
of list_for_each

Signed-off-by: Matthias Kaehlcke <[email protected]>

--

diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h
index 529d0a5..24399a0 100644
--- a/include/sound/emu10k1.h
+++ b/include/sound/emu10k1.h
@@ -1408,8 +1408,6 @@ struct snd_emu10k1_fx8010 {
struct snd_emu10k1_fx8010_irq *irq_handlers;
};

-#define emu10k1_gpr_ctl(n) list_entry(n, struct snd_emu10k1_fx8010_ctl, list)
-
struct snd_emu10k1_midi {
struct snd_emu10k1 *emu;
struct snd_rawmidi *rmidi;
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 7206c0f..bf23c3a 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -642,10 +642,8 @@ snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, struct snd_ctl_elem_id *id)
{
struct snd_emu10k1_fx8010_ctl *ctl;
struct snd_kcontrol *kcontrol;
- struct list_head *list;
-
- list_for_each(list, &emu->fx8010.gpr_ctl) {
- ctl = emu10k1_gpr_ctl(list);
+
+ list_for_each_entry(ctl, &emu->fx8010.gpr_ctl, list) {
kcontrol = ctl->kcontrol;
if (kcontrol->id.iface == id->iface &&
!strcmp(kcontrol->id.name, id->name) &&
@@ -895,14 +893,12 @@ static int snd_emu10k1_list_controls(struct snd_emu10k1 *emu,
struct snd_emu10k1_fx8010_control_gpr *gctl;
struct snd_emu10k1_fx8010_ctl *ctl;
struct snd_ctl_elem_id *id;
- struct list_head *list;

gctl = kmalloc(sizeof(*gctl), GFP_KERNEL);
if (! gctl)
return -ENOMEM;

- list_for_each(list, &emu->fx8010.gpr_ctl) {
- ctl = emu10k1_gpr_ctl(list);
+ list_for_each_entry(ctl, &emu->fx8010.gpr_ctl, list) {
total++;
if (icode->gpr_list_controls &&
i < icode->gpr_list_control_count) {


--
Matthias Kaehlcke
Linux Application Developer
Barcelona

El trabajo es el refugio de los que no tienen nada que hacer
(Oscar Wilde)
.''`.
using free software / Debian GNU/Linux | http://debian.org : :' :
`. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `-