Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[ALSA] Add snd_pcm_group_for_each_entry() for code cleanup

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>

authored by

Takashi Iwai and committed by
Jaroslav Kysela
ef991b95 5e24c1c1

+34 -85
+2 -5
include/sound/pcm.h
··· 603 603 read_unlock_irqrestore(&snd_pcm_link_rwlock, (flags)); \ 604 604 } while (0) 605 605 606 - #define snd_pcm_group_for_each(pos, substream) \ 607 - list_for_each(pos, &substream->group->substreams) 608 - 609 - #define snd_pcm_group_substream_entry(pos) \ 610 - list_entry(pos, struct snd_pcm_substream, link_list) 606 + #define snd_pcm_group_for_each_entry(s, substream) \ 607 + list_for_each_entry(s, &substream->group->substreams, link_list) 611 608 612 609 static inline int snd_pcm_running(struct snd_pcm_substream *substream) 613 610 {
+10 -17
sound/core/pcm_native.c
··· 712 712 struct snd_pcm_substream *substream, 713 713 int state, int do_lock) 714 714 { 715 - struct list_head *pos; 716 715 struct snd_pcm_substream *s = NULL; 717 716 struct snd_pcm_substream *s1; 718 717 int res = 0; 719 718 720 - snd_pcm_group_for_each(pos, substream) { 721 - s = snd_pcm_group_substream_entry(pos); 719 + snd_pcm_group_for_each_entry(s, substream) { 722 720 if (do_lock && s != substream) 723 721 spin_lock(&s->self_group.lock); 724 722 res = ops->pre_action(s, state); 725 723 if (res < 0) 726 724 goto _unlock; 727 725 } 728 - snd_pcm_group_for_each(pos, substream) { 729 - s = snd_pcm_group_substream_entry(pos); 726 + snd_pcm_group_for_each_entry(s, substream) { 730 727 res = ops->do_action(s, state); 731 728 if (res < 0) { 732 729 if (ops->undo_action) { 733 - snd_pcm_group_for_each(pos, substream) { 734 - s1 = snd_pcm_group_substream_entry(pos); 730 + snd_pcm_group_for_each_entry(s1, substream) { 735 731 if (s1 == s) /* failed stream */ 736 732 break; 737 733 ops->undo_action(s1, state); ··· 737 741 goto _unlock; 738 742 } 739 743 } 740 - snd_pcm_group_for_each(pos, substream) { 741 - s = snd_pcm_group_substream_entry(pos); 744 + snd_pcm_group_for_each_entry(s, substream) { 742 745 ops->post_action(s, state); 743 746 } 744 747 _unlock: 745 748 if (do_lock) { 746 749 /* unlock streams */ 747 - snd_pcm_group_for_each(pos, substream) { 748 - s1 = snd_pcm_group_substream_entry(pos); 750 + snd_pcm_group_for_each_entry(s1, substream) { 749 751 if (s1 != substream) 750 752 spin_unlock(&s1->self_group.lock); 751 753 if (s1 == s) /* end */ ··· 1432 1438 { 1433 1439 struct snd_card *card; 1434 1440 struct snd_pcm_runtime *runtime; 1435 - struct list_head *pos; 1441 + struct snd_pcm_substream *s; 1436 1442 int result = 0; 1437 1443 int i, num_drecs; 1438 1444 struct drain_rec *drec, drec_tmp, *d; ··· 1467 1473 1468 1474 /* count only playback streams */ 1469 1475 num_drecs = 0; 1470 - snd_pcm_group_for_each(pos, substream) { 1471 - struct snd_pcm_substream *s = snd_pcm_group_substream_entry(pos); 1476 + snd_pcm_group_for_each_entry(s, substream) { 1472 1477 runtime = s->runtime; 1473 1478 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { 1474 1479 d = &drec[num_drecs++]; ··· 1667 1674 1668 1675 static int snd_pcm_unlink(struct snd_pcm_substream *substream) 1669 1676 { 1670 - struct list_head *pos; 1677 + struct snd_pcm_substream *s; 1671 1678 int res = 0; 1672 1679 1673 1680 down_write(&snd_pcm_link_rwsem); ··· 1679 1686 list_del(&substream->link_list); 1680 1687 substream->group->count--; 1681 1688 if (substream->group->count == 1) { /* detach the last stream, too */ 1682 - snd_pcm_group_for_each(pos, substream) { 1683 - relink_to_local(snd_pcm_group_substream_entry(pos)); 1689 + snd_pcm_group_for_each_entry(s, substream) { 1690 + relink_to_local(s); 1684 1691 break; 1685 1692 } 1686 1693 kfree(substream->group);
+1 -3
sound/isa/cs423x/cs4231_lib.c
··· 405 405 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); 406 406 int result = 0; 407 407 unsigned int what; 408 - struct list_head *pos; 409 408 struct snd_pcm_substream *s; 410 409 int do_start; 411 410 ··· 424 425 } 425 426 426 427 what = 0; 427 - snd_pcm_group_for_each(pos, substream) { 428 - s = snd_pcm_group_substream_entry(pos); 428 + snd_pcm_group_for_each_entry(s, substream) { 429 429 if (s == chip->playback_substream) { 430 430 what |= CS4231_PLAYBACK_ENABLE; 431 431 snd_pcm_trigger_done(s, substream);
+1 -3
sound/isa/opti9xx/opti92x-ad1848.c
··· 934 934 case SNDRV_PCM_TRIGGER_STOP: 935 935 { 936 936 unsigned int what = 0; 937 - struct list_head *pos; 938 937 struct snd_pcm_substream *s; 939 - snd_pcm_group_for_each(pos, substream) { 940 - s = snd_pcm_group_substream_entry(pos); 938 + snd_pcm_group_for_each_entry(s, substream) { 941 939 if (s == chip->playback_substream) { 942 940 what |= OPTi93X_PLAYBACK_ENABLE; 943 941 snd_pcm_trigger_done(s, substream);
+1 -3
sound/pci/ali5451/ali5451.c
··· 1224 1224 1225 1225 { 1226 1226 struct snd_ali *codec = snd_pcm_substream_chip(substream); 1227 - struct list_head *pos; 1228 1227 struct snd_pcm_substream *s; 1229 1228 unsigned int what, whati, capture_flag; 1230 1229 struct snd_ali_voice *pvoice = NULL, *evoice = NULL; ··· 1242 1243 } 1243 1244 1244 1245 what = whati = capture_flag = 0; 1245 - snd_pcm_group_for_each(pos, substream) { 1246 - s = snd_pcm_group_substream_entry(pos); 1246 + snd_pcm_group_for_each_entry(s, substream) { 1247 1247 if ((struct snd_ali *) snd_pcm_substream_chip(s) == codec) { 1248 1248 pvoice = s->runtime->private_data; 1249 1249 evoice = pvoice->extra;
+1 -3
sound/pci/ca0106/ca0106_main.c
··· 775 775 struct snd_ca0106_pcm *epcm; 776 776 int channel; 777 777 int result = 0; 778 - struct list_head *pos; 779 778 struct snd_pcm_substream *s; 780 779 u32 basic = 0; 781 780 u32 extended = 0; ··· 789 790 running=0; 790 791 break; 791 792 } 792 - snd_pcm_group_for_each(pos, substream) { 793 - s = snd_pcm_group_substream_entry(pos); 793 + snd_pcm_group_for_each_entry(s, substream) { 794 794 runtime = s->runtime; 795 795 epcm = runtime->private_data; 796 796 channel = epcm->channel_id;
+1 -3
sound/pci/echoaudio/echoaudio.c
··· 705 705 struct audiopipe *pipe = runtime->private_data; 706 706 int i, err; 707 707 u32 channelmask = 0; 708 - struct list_head *pos; 709 708 struct snd_pcm_substream *s; 710 709 711 - snd_pcm_group_for_each(pos, substream) { 712 - s = snd_pcm_group_substream_entry(pos); 710 + snd_pcm_group_for_each_entry(s, substream) { 713 711 for (i = 0; i < DSP_MAXPIPES; i++) { 714 712 if (s == chip->substream[i]) { 715 713 channelmask |= 1 << i;
+1 -3
sound/pci/emu10k1/p16v.c
··· 433 433 struct snd_emu10k1_pcm *epcm; 434 434 int channel; 435 435 int result = 0; 436 - struct list_head *pos; 437 436 struct snd_pcm_substream *s; 438 437 u32 basic = 0; 439 438 u32 inte = 0; ··· 447 448 running = 0; 448 449 break; 449 450 } 450 - snd_pcm_group_for_each(pos, substream) { 451 - s = snd_pcm_group_substream_entry(pos); 451 + snd_pcm_group_for_each_entry(s, substream) { 452 452 runtime = s->runtime; 453 453 epcm = runtime->private_data; 454 454 channel = substream->pcm->device-emu->p16v_device_offset;
+2 -6
sound/pci/ens1370.c
··· 798 798 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 799 799 { 800 800 unsigned int what = 0; 801 - struct list_head *pos; 802 801 struct snd_pcm_substream *s; 803 - snd_pcm_group_for_each(pos, substream) { 804 - s = snd_pcm_group_substream_entry(pos); 802 + snd_pcm_group_for_each_entry(s, substream) { 805 803 if (s == ensoniq->playback1_substream) { 806 804 what |= ES_P1_PAUSE; 807 805 snd_pcm_trigger_done(s, substream); ··· 822 824 case SNDRV_PCM_TRIGGER_STOP: 823 825 { 824 826 unsigned int what = 0; 825 - struct list_head *pos; 826 827 struct snd_pcm_substream *s; 827 - snd_pcm_group_for_each(pos, substream) { 828 - s = snd_pcm_group_substream_entry(pos); 828 + snd_pcm_group_for_each_entry(s, substream) { 829 829 if (s == ensoniq->playback1_substream) { 830 830 what |= ES_DAC1_EN; 831 831 snd_pcm_trigger_done(s, substream);
+1 -3
sound/pci/ice1712/ice1712.c
··· 977 977 { 978 978 unsigned int what = 0; 979 979 unsigned int old; 980 - struct list_head *pos; 981 980 struct snd_pcm_substream *s; 982 981 983 - snd_pcm_group_for_each(pos, substream) { 984 - s = snd_pcm_group_substream_entry(pos); 982 + snd_pcm_group_for_each_entry(s, substream) { 985 983 if (s == ice->playback_pro_substream) { 986 984 what |= ICE1712_PLAYBACK_START; 987 985 snd_pcm_trigger_done(s, substream);
+1 -3
sound/pci/ice1712/ice1724.c
··· 337 337 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 338 338 unsigned char what; 339 339 unsigned char old; 340 - struct list_head *pos; 341 340 struct snd_pcm_substream *s; 342 341 343 342 what = 0; 344 - snd_pcm_group_for_each(pos, substream) { 343 + snd_pcm_group_for_each_entry(s, substream) { 345 344 const struct vt1724_pcm_reg *reg; 346 - s = snd_pcm_group_substream_entry(pos); 347 345 reg = s->runtime->private_data; 348 346 what |= reg->start; 349 347 snd_pcm_trigger_done(s, substream);
+2 -5
sound/pci/pcxhr/pcxhr.c
··· 638 638 static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd) 639 639 { 640 640 struct pcxhr_stream *stream; 641 - struct list_head *pos; 642 641 struct snd_pcm_substream *s; 643 642 int i; 644 643 ··· 645 646 case SNDRV_PCM_TRIGGER_START: 646 647 snd_printdd("SNDRV_PCM_TRIGGER_START\n"); 647 648 i = 0; 648 - snd_pcm_group_for_each(pos, subs) { 649 - s = snd_pcm_group_substream_entry(pos); 649 + snd_pcm_group_for_each_entry(s, subs) { 650 650 stream = s->runtime->private_data; 651 651 stream->status = PCXHR_STREAM_STATUS_SCHEDULE_RUN; 652 652 snd_pcm_trigger_done(s, subs); ··· 670 672 break; 671 673 case SNDRV_PCM_TRIGGER_STOP: 672 674 snd_printdd("SNDRV_PCM_TRIGGER_STOP\n"); 673 - snd_pcm_group_for_each(pos, subs) { 674 - s = snd_pcm_group_substream_entry(pos); 675 + snd_pcm_group_for_each_entry(s, subs) { 675 676 stream = s->runtime->private_data; 676 677 stream->status = PCXHR_STREAM_STATUS_SCHEDULE_STOP; 677 678 if (pcxhr_set_stream_state(stream))
+2 -5
sound/pci/rme32.c
··· 1078 1078 snd_rme32_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 1079 1079 { 1080 1080 struct rme32 *rme32 = snd_pcm_substream_chip(substream); 1081 - struct list_head *pos; 1082 1081 struct snd_pcm_substream *s; 1083 1082 1084 1083 spin_lock(&rme32->lock); 1085 - snd_pcm_group_for_each(pos, substream) { 1086 - s = snd_pcm_group_substream_entry(pos); 1084 + snd_pcm_group_for_each_entry(s, substream) { 1087 1085 if (s != rme32->playback_substream && 1088 1086 s != rme32->capture_substream) 1089 1087 continue; ··· 1108 1110 1109 1111 /* prefill playback buffer */ 1110 1112 if (cmd == SNDRV_PCM_TRIGGER_START && rme32->fullduplex_mode) { 1111 - snd_pcm_group_for_each(pos, substream) { 1112 - s = snd_pcm_group_substream_entry(pos); 1113 + snd_pcm_group_for_each_entry(s, substream) { 1113 1114 if (s == rme32->playback_substream) { 1114 1115 s->ops->ack(s); 1115 1116 break;
+2 -6
sound/pci/rme9652/hdsp.c
··· 3780 3780 else 3781 3781 runtime->status->hw_ptr = 0; 3782 3782 if (other) { 3783 - struct list_head *pos; 3784 3783 struct snd_pcm_substream *s; 3785 3784 struct snd_pcm_runtime *oruntime = other->runtime; 3786 - snd_pcm_group_for_each(pos, substream) { 3787 - s = snd_pcm_group_substream_entry(pos); 3785 + snd_pcm_group_for_each_entry(s, substream) { 3788 3786 if (s == other) { 3789 3787 oruntime->status->hw_ptr = runtime->status->hw_ptr; 3790 3788 break; ··· 3931 3933 other = hdsp->playback_substream; 3932 3934 3933 3935 if (other) { 3934 - struct list_head *pos; 3935 3936 struct snd_pcm_substream *s; 3936 - snd_pcm_group_for_each(pos, substream) { 3937 - s = snd_pcm_group_substream_entry(pos); 3937 + snd_pcm_group_for_each_entry(s, substream) { 3938 3938 if (s == other) { 3939 3939 snd_pcm_trigger_done(s, substream); 3940 3940 if (cmd == SNDRV_PCM_TRIGGER_START)
+2 -6
sound/pci/rme9652/hdspm.c
··· 3575 3575 else 3576 3576 runtime->status->hw_ptr = 0; 3577 3577 if (other) { 3578 - struct list_head *pos; 3579 3578 struct snd_pcm_substream *s; 3580 3579 struct snd_pcm_runtime *oruntime = other->runtime; 3581 - snd_pcm_group_for_each(pos, substream) { 3582 - s = snd_pcm_group_substream_entry(pos); 3580 + snd_pcm_group_for_each_entry(s, substream) { 3583 3581 if (s == other) { 3584 3582 oruntime->status->hw_ptr = 3585 3583 runtime->status->hw_ptr; ··· 3789 3791 other = hdspm->playback_substream; 3790 3792 3791 3793 if (other) { 3792 - struct list_head *pos; 3793 3794 struct snd_pcm_substream *s; 3794 - snd_pcm_group_for_each(pos, substream) { 3795 - s = snd_pcm_group_substream_entry(pos); 3795 + snd_pcm_group_for_each_entry(s, substream) { 3796 3796 if (s == other) { 3797 3797 snd_pcm_trigger_done(s, substream); 3798 3798 if (cmd == SNDRV_PCM_TRIGGER_START)
+2 -6
sound/pci/rme9652/rme9652.c
··· 1992 1992 else 1993 1993 runtime->status->hw_ptr = 0; 1994 1994 if (other) { 1995 - struct list_head *pos; 1996 1995 struct snd_pcm_substream *s; 1997 1996 struct snd_pcm_runtime *oruntime = other->runtime; 1998 - snd_pcm_group_for_each(pos, substream) { 1999 - s = snd_pcm_group_substream_entry(pos); 1997 + snd_pcm_group_for_each_entry(s, substream) { 2000 1998 if (s == other) { 2001 1999 oruntime->status->hw_ptr = runtime->status->hw_ptr; 2002 2000 break; ··· 2138 2140 other = rme9652->playback_substream; 2139 2141 2140 2142 if (other) { 2141 - struct list_head *pos; 2142 2143 struct snd_pcm_substream *s; 2143 - snd_pcm_group_for_each(pos, substream) { 2144 - s = snd_pcm_group_substream_entry(pos); 2144 + snd_pcm_group_for_each_entry(s, substream) { 2145 2145 if (s == other) { 2146 2146 snd_pcm_trigger_done(s, substream); 2147 2147 if (cmd == SNDRV_PCM_TRIGGER_START)
+1 -3
sound/pci/trident/trident_main.c
··· 1540 1540 1541 1541 { 1542 1542 struct snd_trident *trident = snd_pcm_substream_chip(substream); 1543 - struct list_head *pos; 1544 1543 struct snd_pcm_substream *s; 1545 1544 unsigned int what, whati, capture_flag, spdif_flag; 1546 1545 struct snd_trident_voice *voice, *evoice; ··· 1562 1563 what = whati = capture_flag = spdif_flag = 0; 1563 1564 spin_lock(&trident->reg_lock); 1564 1565 val = inl(TRID_REG(trident, T4D_STIMER)) & 0x00ffffff; 1565 - snd_pcm_group_for_each(pos, substream) { 1566 - s = snd_pcm_group_substream_entry(pos); 1566 + snd_pcm_group_for_each_entry(s, substream) { 1567 1567 if ((struct snd_trident *) snd_pcm_substream_chip(s) == trident) { 1568 1568 voice = s->runtime->private_data; 1569 1569 evoice = voice->extra;
+1 -2
sound/sparc/cs4231.c
··· 661 661 { 662 662 unsigned int what = 0; 663 663 struct snd_pcm_substream *s; 664 - struct list_head *pos; 665 664 unsigned long flags; 666 665 667 - snd_pcm_group_for_each(pos, substream) { 666 + snd_pcm_group_for_each_entry(s, substream) { 668 667 s = snd_pcm_group_substream_entry(pos); 669 668 if (s == chip->playback_substream) { 670 669 what |= CS4231_PLAYBACK_ENABLE;