]> err.no Git - linux-2.6/commitdiff
[ALSA] Add snd_pcm_group_for_each_entry() for code cleanup
authorTakashi Iwai <tiwai@suse.de>
Thu, 22 Feb 2007 11:52:53 +0000 (12:52 +0100)
committerJaroslav Kysela <perex@suse.cz>
Fri, 11 May 2007 14:55:42 +0000 (16:55 +0200)
Added a new macro snd_pcm_group_for_each_entry() just for code cleanup.
Old macros, snd_pcm_group_for_each() and snd_pcm_group_substream_entry(),
are removed.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
18 files changed:
include/sound/pcm.h
sound/core/pcm_native.c
sound/isa/cs423x/cs4231_lib.c
sound/isa/opti9xx/opti92x-ad1848.c
sound/pci/ali5451/ali5451.c
sound/pci/ca0106/ca0106_main.c
sound/pci/echoaudio/echoaudio.c
sound/pci/emu10k1/p16v.c
sound/pci/ens1370.c
sound/pci/ice1712/ice1712.c
sound/pci/ice1712/ice1724.c
sound/pci/pcxhr/pcxhr.c
sound/pci/rme32.c
sound/pci/rme9652/hdsp.c
sound/pci/rme9652/hdspm.c
sound/pci/rme9652/rme9652.c
sound/pci/trident/trident_main.c
sound/sparc/cs4231.c

index deff5a92efa6886ecd1d227b534e53fe98c04095..73334e0f823f57d88ae4bbb5eade93b2b008acfa 100644 (file)
@@ -603,11 +603,8 @@ do { \
        read_unlock_irqrestore(&snd_pcm_link_rwlock, (flags)); \
 } while (0)
 
-#define snd_pcm_group_for_each(pos, substream) \
-       list_for_each(pos, &substream->group->substreams)
-
-#define snd_pcm_group_substream_entry(pos) \
-       list_entry(pos, struct snd_pcm_substream, link_list)
+#define snd_pcm_group_for_each_entry(s, substream) \
+       list_for_each_entry(s, &substream->group->substreams, link_list)
 
 static inline int snd_pcm_running(struct snd_pcm_substream *substream)
 {
index 905234817c891d8c2cb0f2446416386aafac1fcc..42a039cc50a85fbd637ff668512680931d3b4ef6 100644 (file)
@@ -712,26 +712,22 @@ static int snd_pcm_action_group(struct action_ops *ops,
                                struct snd_pcm_substream *substream,
                                int state, int do_lock)
 {
-       struct list_head *pos;
        struct snd_pcm_substream *s = NULL;
        struct snd_pcm_substream *s1;
        int res = 0;
 
-       snd_pcm_group_for_each(pos, substream) {
-               s = snd_pcm_group_substream_entry(pos);
+       snd_pcm_group_for_each_entry(s, substream) {
                if (do_lock && s != substream)
                        spin_lock(&s->self_group.lock);
                res = ops->pre_action(s, state);
                if (res < 0)
                        goto _unlock;
        }
-       snd_pcm_group_for_each(pos, substream) {
-               s = snd_pcm_group_substream_entry(pos);
+       snd_pcm_group_for_each_entry(s, substream) {
                res = ops->do_action(s, state);
                if (res < 0) {
                        if (ops->undo_action) {
-                               snd_pcm_group_for_each(pos, substream) {
-                                       s1 = snd_pcm_group_substream_entry(pos);
+                               snd_pcm_group_for_each_entry(s1, substream) {
                                        if (s1 == s) /* failed stream */
                                                break;
                                        ops->undo_action(s1, state);
@@ -741,15 +737,13 @@ static int snd_pcm_action_group(struct action_ops *ops,
                        goto _unlock;
                }
        }
-       snd_pcm_group_for_each(pos, substream) {
-               s = snd_pcm_group_substream_entry(pos);
+       snd_pcm_group_for_each_entry(s, substream) {
                ops->post_action(s, state);
        }
  _unlock:
        if (do_lock) {
                /* unlock streams */
-               snd_pcm_group_for_each(pos, substream) {
-                       s1 = snd_pcm_group_substream_entry(pos);
+               snd_pcm_group_for_each_entry(s1, substream) {
                        if (s1 != substream)
                                spin_unlock(&s1->self_group.lock);
                        if (s1 == s)    /* end */
@@ -1438,7 +1432,7 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream)
 {
        struct snd_card *card;
        struct snd_pcm_runtime *runtime;
-       struct list_head *pos;
+       struct snd_pcm_substream *s;
        int result = 0;
        int i, num_drecs;
        struct drain_rec *drec, drec_tmp, *d;
@@ -1473,8 +1467,7 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream)
 
        /* count only playback streams */
        num_drecs = 0;
-       snd_pcm_group_for_each(pos, substream) {
-               struct snd_pcm_substream *s = snd_pcm_group_substream_entry(pos);
+       snd_pcm_group_for_each_entry(s, substream) {
                runtime = s->runtime;
                if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
                        d = &drec[num_drecs++];
@@ -1674,7 +1667,7 @@ static void relink_to_local(struct snd_pcm_substream *substream)
 
 static int snd_pcm_unlink(struct snd_pcm_substream *substream)
 {
-       struct list_head *pos;
+       struct snd_pcm_substream *s;
        int res = 0;
 
        down_write(&snd_pcm_link_rwsem);
@@ -1686,8 +1679,8 @@ static int snd_pcm_unlink(struct snd_pcm_substream *substream)
        list_del(&substream->link_list);
        substream->group->count--;
        if (substream->group->count == 1) {     /* detach the last stream, too */
-               snd_pcm_group_for_each(pos, substream) {
-                       relink_to_local(snd_pcm_group_substream_entry(pos));
+               snd_pcm_group_for_each_entry(s, substream) {
+                       relink_to_local(s);
                        break;
                }
                kfree(substream->group);
index 75c7c5f01989a478dd664aa58a7b503e22b0c478..914d77b61b0c042d865b22cb7b78fa09e44f3b20 100644 (file)
@@ -405,7 +405,6 @@ static int snd_cs4231_trigger(struct snd_pcm_substream *substream,
        struct snd_cs4231 *chip = snd_pcm_substream_chip(substream);
        int result = 0;
        unsigned int what;
-       struct list_head *pos;
        struct snd_pcm_substream *s;
        int do_start;
 
@@ -425,8 +424,7 @@ static int snd_cs4231_trigger(struct snd_pcm_substream *substream,
        }
 
        what = 0;
-       snd_pcm_group_for_each(pos, substream) {
-               s = snd_pcm_group_substream_entry(pos);
+       snd_pcm_group_for_each_entry(s, substream) {
                if (s == chip->playback_substream) {
                        what |= CS4231_PLAYBACK_ENABLE;
                        snd_pcm_trigger_done(s, substream);
index 1c390580bd50dd987d139e30236955bb8382a07f..95d0ab124d5b76374bb5b472fbee15b957164156 100644 (file)
@@ -934,10 +934,8 @@ static int snd_opti93x_trigger(struct snd_pcm_substream *substream,
        case SNDRV_PCM_TRIGGER_STOP:
        {
                unsigned int what = 0;
-               struct list_head *pos;
                struct snd_pcm_substream *s;
-               snd_pcm_group_for_each(pos, substream) {
-                       s = snd_pcm_group_substream_entry(pos);
+               snd_pcm_group_for_each_entry(s, substream) {
                        if (s == chip->playback_substream) {
                                what |= OPTi93X_PLAYBACK_ENABLE;
                                snd_pcm_trigger_done(s, substream);
index ba7fa22b285dd837c881f61d1856205dba58fb13..cd2fe374744c20b65730df3d427012e43ce1a1dd 100644 (file)
@@ -1224,7 +1224,6 @@ static int snd_ali_trigger(struct snd_pcm_substream *substream,
                                    
 {
        struct snd_ali *codec = snd_pcm_substream_chip(substream);
-       struct list_head *pos;
        struct snd_pcm_substream *s;
        unsigned int what, whati, capture_flag;
        struct snd_ali_voice *pvoice = NULL, *evoice = NULL;
@@ -1243,8 +1242,7 @@ static int snd_ali_trigger(struct snd_pcm_substream *substream,
        }
 
        what = whati = capture_flag = 0;
-       snd_pcm_group_for_each(pos, substream) {
-               s = snd_pcm_group_substream_entry(pos);
+       snd_pcm_group_for_each_entry(s, substream) {
                if ((struct snd_ali *) snd_pcm_substream_chip(s) == codec) {
                        pvoice = s->runtime->private_data;
                        evoice = pvoice->extra;
index ea6712b63c9f7a268eba7b72ef989d58fbda1056..48f3f17c5170283a4e18b7df9ec44f3570a58520 100644 (file)
@@ -775,7 +775,6 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
        struct snd_ca0106_pcm *epcm;
        int channel;
        int result = 0;
-       struct list_head *pos;
         struct snd_pcm_substream *s;
        u32 basic = 0;
        u32 extended = 0;
@@ -790,8 +789,7 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
                running=0;
                break;
        }
-        snd_pcm_group_for_each(pos, substream) {
-                s = snd_pcm_group_substream_entry(pos);
+        snd_pcm_group_for_each_entry(s, substream) {
                runtime = s->runtime;
                epcm = runtime->private_data;
                channel = epcm->channel_id;
index e413da00759bcbe3cc2e67086b41866d12e4bc4a..f27b6a733b96a50d1a51a1ca5653601a58f0a554 100644 (file)
@@ -705,11 +705,9 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
        struct audiopipe *pipe = runtime->private_data;
        int i, err;
        u32 channelmask = 0;
-       struct list_head *pos;
        struct snd_pcm_substream *s;
 
-       snd_pcm_group_for_each(pos, substream) {
-               s = snd_pcm_group_substream_entry(pos);
+       snd_pcm_group_for_each_entry(s, substream) {
                for (i = 0; i < DSP_MAXPIPES; i++) {
                        if (s == chip->substream[i]) {
                                channelmask |= 1 << i;
index 465f8d505329b40f48d0d0c219e189df810532c2..7ee19c63c2c8a2114f6d099bacd6051b3ce8482d 100644 (file)
@@ -433,7 +433,6 @@ static int snd_p16v_pcm_trigger_playback(struct snd_pcm_substream *substream,
        struct snd_emu10k1_pcm *epcm;
        int channel;
        int result = 0;
-       struct list_head *pos;
         struct snd_pcm_substream *s;
        u32 basic = 0;
        u32 inte = 0;
@@ -448,8 +447,7 @@ static int snd_p16v_pcm_trigger_playback(struct snd_pcm_substream *substream,
                running = 0;
                break;
        }
-        snd_pcm_group_for_each(pos, substream) {
-                s = snd_pcm_group_substream_entry(pos);
+        snd_pcm_group_for_each_entry(s, substream) {
                runtime = s->runtime;
                epcm = runtime->private_data;
                channel = substream->pcm->device-emu->p16v_device_offset;
index 425b167522d56a087279c18797b5be87df2a5061..6a0ddcf008848422197f2c7dd23eb1e6d66f104f 100644 (file)
@@ -798,10 +798,8 @@ static int snd_ensoniq_trigger(struct snd_pcm_substream *substream, int cmd)
        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
        {
                unsigned int what = 0;
-               struct list_head *pos;
                struct snd_pcm_substream *s;
-               snd_pcm_group_for_each(pos, substream) {
-                       s = snd_pcm_group_substream_entry(pos);
+               snd_pcm_group_for_each_entry(s, substream) {
                        if (s == ensoniq->playback1_substream) {
                                what |= ES_P1_PAUSE;
                                snd_pcm_trigger_done(s, substream);
@@ -824,10 +822,8 @@ static int snd_ensoniq_trigger(struct snd_pcm_substream *substream, int cmd)
        case SNDRV_PCM_TRIGGER_STOP:
        {
                unsigned int what = 0;
-               struct list_head *pos;
                struct snd_pcm_substream *s;
-               snd_pcm_group_for_each(pos, substream) {
-                       s = snd_pcm_group_substream_entry(pos);
+               snd_pcm_group_for_each_entry(s, substream) {
                        if (s == ensoniq->playback1_substream) {
                                what |= ES_DAC1_EN;
                                snd_pcm_trigger_done(s, substream);
index 830a1bbd7110a058ba2765a913eda0c34849f27d..e880469beb4f9d981bfc73d8b28d187cb793105a 100644 (file)
@@ -977,11 +977,9 @@ static int snd_ice1712_pro_trigger(struct snd_pcm_substream *substream,
        {
                unsigned int what = 0;
                unsigned int old;
-               struct list_head *pos;
                struct snd_pcm_substream *s;
 
-               snd_pcm_group_for_each(pos, substream) {
-                       s = snd_pcm_group_substream_entry(pos);
+               snd_pcm_group_for_each_entry(s, substream) {
                        if (s == ice->playback_pro_substream) {
                                what |= ICE1712_PLAYBACK_START;
                                snd_pcm_trigger_done(s, substream);
index 1127ebdf5fec45971a41869d797229300fc2ba90..3f2aca20a625472a178a6dd332fff89d5e2fa25a 100644 (file)
@@ -337,13 +337,11 @@ static int snd_vt1724_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
        struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
        unsigned char what;
        unsigned char old;
-       struct list_head *pos;
        struct snd_pcm_substream *s;
 
        what = 0;
-       snd_pcm_group_for_each(pos, substream) {
+       snd_pcm_group_for_each_entry(s, substream) {
                const struct vt1724_pcm_reg *reg;
-               s = snd_pcm_group_substream_entry(pos);
                reg = s->runtime->private_data;
                what |= reg->start;
                snd_pcm_trigger_done(s, substream);
index d97413484ae9f80ba547f57ea0e932814524ea6d..e1bdeed3a46579b9df852e66c0b69e91ca885876 100644 (file)
@@ -638,7 +638,6 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
 static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd)
 {
        struct pcxhr_stream *stream;
-       struct list_head *pos;
        struct snd_pcm_substream *s;
        int i;
 
@@ -646,8 +645,7 @@ static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd)
        case SNDRV_PCM_TRIGGER_START:
                snd_printdd("SNDRV_PCM_TRIGGER_START\n");
                i = 0;
-               snd_pcm_group_for_each(pos, subs) {
-                       s = snd_pcm_group_substream_entry(pos);
+               snd_pcm_group_for_each_entry(s, subs) {
                        stream = s->runtime->private_data;
                        stream->status = PCXHR_STREAM_STATUS_SCHEDULE_RUN;
                        snd_pcm_trigger_done(s, subs);
@@ -672,8 +670,7 @@ static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd)
                break;
        case SNDRV_PCM_TRIGGER_STOP:
                snd_printdd("SNDRV_PCM_TRIGGER_STOP\n");
-               snd_pcm_group_for_each(pos, subs) {
-                       s = snd_pcm_group_substream_entry(pos);
+               snd_pcm_group_for_each_entry(s, subs) {
                        stream = s->runtime->private_data;
                        stream->status = PCXHR_STREAM_STATUS_SCHEDULE_STOP;
                        if (pcxhr_set_stream_state(stream))
index 6bb7ac650ec42dde1fc8dfb97ff304881bee976c..618653e22561ba3a208afa55138201549c224334 100644 (file)
@@ -1078,12 +1078,10 @@ static int
 snd_rme32_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 {
        struct rme32 *rme32 = snd_pcm_substream_chip(substream);
-       struct list_head *pos;
        struct snd_pcm_substream *s;
 
        spin_lock(&rme32->lock);
-       snd_pcm_group_for_each(pos, substream) {
-               s = snd_pcm_group_substream_entry(pos);
+       snd_pcm_group_for_each_entry(s, substream) {
                if (s != rme32->playback_substream &&
                    s != rme32->capture_substream)
                        continue;
@@ -1110,8 +1108,7 @@ snd_rme32_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
        
        /* prefill playback buffer */
        if (cmd == SNDRV_PCM_TRIGGER_START && rme32->fullduplex_mode) {
-               snd_pcm_group_for_each(pos, substream) {
-                       s = snd_pcm_group_substream_entry(pos);
+               snd_pcm_group_for_each_entry(s, substream) {
                        if (s == rme32->playback_substream) {
                                s->ops->ack(s);
                                break;
index 89b3c7ff5037ad85586d6a48db973a7532b158fe..6540037a11e4d9c2e693acc801baf39f6ef1758c 100644 (file)
@@ -3780,11 +3780,9 @@ static int snd_hdsp_reset(struct snd_pcm_substream *substream)
        else
                runtime->status->hw_ptr = 0;
        if (other) {
-               struct list_head *pos;
                struct snd_pcm_substream *s;
                struct snd_pcm_runtime *oruntime = other->runtime;
-               snd_pcm_group_for_each(pos, substream) {
-                       s = snd_pcm_group_substream_entry(pos);
+               snd_pcm_group_for_each_entry(s, substream) {
                        if (s == other) {
                                oruntime->status->hw_ptr = runtime->status->hw_ptr;
                                break;
@@ -3933,10 +3931,8 @@ static int snd_hdsp_trigger(struct snd_pcm_substream *substream, int cmd)
                other = hdsp->playback_substream;
 
        if (other) {
-               struct list_head *pos;
                struct snd_pcm_substream *s;
-               snd_pcm_group_for_each(pos, substream) {
-                       s = snd_pcm_group_substream_entry(pos);
+               snd_pcm_group_for_each_entry(s, substream) {
                        if (s == other) {
                                snd_pcm_trigger_done(s, substream);
                                if (cmd == SNDRV_PCM_TRIGGER_START)
index 6e95857e4e67a4cd10f5843312cae93ed661237b..d2ae6380943e6347c9ad6bea406b95d58a6b3d93 100644 (file)
@@ -3575,11 +3575,9 @@ static int snd_hdspm_reset(struct snd_pcm_substream *substream)
        else
                runtime->status->hw_ptr = 0;
        if (other) {
-               struct list_head *pos;
                struct snd_pcm_substream *s;
                struct snd_pcm_runtime *oruntime = other->runtime;
-               snd_pcm_group_for_each(pos, substream) {
-                       s = snd_pcm_group_substream_entry(pos);
+               snd_pcm_group_for_each_entry(s, substream) {
                        if (s == other) {
                                oruntime->status->hw_ptr =
                                    runtime->status->hw_ptr;
@@ -3791,10 +3789,8 @@ static int snd_hdspm_trigger(struct snd_pcm_substream *substream, int cmd)
                other = hdspm->playback_substream;
 
        if (other) {
-               struct list_head *pos;
                struct snd_pcm_substream *s;
-               snd_pcm_group_for_each(pos, substream) {
-                       s = snd_pcm_group_substream_entry(pos);
+               snd_pcm_group_for_each_entry(s, substream) {
                        if (s == other) {
                                snd_pcm_trigger_done(s, substream);
                                if (cmd == SNDRV_PCM_TRIGGER_START)
index cc3bdececce769e8f9e1fb7ab808c4639b1b33d1..bd7dbd267ed1b10e09c81023bce90ca9f57c2211 100644 (file)
@@ -1992,11 +1992,9 @@ static int snd_rme9652_reset(struct snd_pcm_substream *substream)
        else
                runtime->status->hw_ptr = 0;
        if (other) {
-               struct list_head *pos;
                struct snd_pcm_substream *s;
                struct snd_pcm_runtime *oruntime = other->runtime;
-               snd_pcm_group_for_each(pos, substream) {
-                       s = snd_pcm_group_substream_entry(pos);
+               snd_pcm_group_for_each_entry(s, substream) {
                        if (s == other) {
                                oruntime->status->hw_ptr = runtime->status->hw_ptr;
                                break;
@@ -2140,10 +2138,8 @@ static int snd_rme9652_trigger(struct snd_pcm_substream *substream,
                other = rme9652->playback_substream;
 
        if (other) {
-               struct list_head *pos;
                struct snd_pcm_substream *s;
-               snd_pcm_group_for_each(pos, substream) {
-                       s = snd_pcm_group_substream_entry(pos);
+               snd_pcm_group_for_each_entry(s, substream) {
                        if (s == other) {
                                snd_pcm_trigger_done(s, substream);
                                if (cmd == SNDRV_PCM_TRIGGER_START)
index 3bff32167f6617a13be87b4d215e43f8bf4e1c99..7ca6062724602f0a8cc9395d0231edcd2ede787c 100644 (file)
@@ -1540,7 +1540,6 @@ static int snd_trident_trigger(struct snd_pcm_substream *substream,
                                    
 {
        struct snd_trident *trident = snd_pcm_substream_chip(substream);
-       struct list_head *pos;
        struct snd_pcm_substream *s;
        unsigned int what, whati, capture_flag, spdif_flag;
        struct snd_trident_voice *voice, *evoice;
@@ -1563,8 +1562,7 @@ static int snd_trident_trigger(struct snd_pcm_substream *substream,
        what = whati = capture_flag = spdif_flag = 0;
        spin_lock(&trident->reg_lock);
        val = inl(TRID_REG(trident, T4D_STIMER)) & 0x00ffffff;
-       snd_pcm_group_for_each(pos, substream) {
-               s = snd_pcm_group_substream_entry(pos);
+       snd_pcm_group_for_each_entry(s, substream) {
                if ((struct snd_trident *) snd_pcm_substream_chip(s) == trident) {
                        voice = s->runtime->private_data;
                        evoice = voice->extra;
index 900a00de35fd7b016f0e10b7bbfa9dd2db2a5ae9..96d51abcb73ac333b304f278c8d31334665164af 100644 (file)
@@ -661,10 +661,9 @@ static int snd_cs4231_trigger(struct snd_pcm_substream *substream, int cmd)
        {
                unsigned int what = 0;
                struct snd_pcm_substream *s;
-               struct list_head *pos;
                unsigned long flags;
 
-               snd_pcm_group_for_each(pos, substream) {
+               snd_pcm_group_for_each_entry(s, substream) {
                        s = snd_pcm_group_substream_entry(pos);
                        if (s == chip->playback_substream) {
                                what |= CS4231_PLAYBACK_ENABLE;