aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2007-02-22 06:52:53 -0500
committerJaroslav Kysela <perex@suse.cz>2007-05-11 10:55:42 -0400
commitef991b95aa1351a5782cfaccb9aefba76ca8b990 (patch)
tree129762745099142652615dbe1c4c29725cca51c8 /sound/core
parent5e24c1c1c496c4603395d6e9cc320f85008fc891 (diff)
[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>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/pcm_native.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 905234817c89..42a039cc50a8 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -712,26 +712,22 @@ static int snd_pcm_action_group(struct action_ops *ops,
712 struct snd_pcm_substream *substream, 712 struct snd_pcm_substream *substream,
713 int state, int do_lock) 713 int state, int do_lock)
714{ 714{
715 struct list_head *pos;
716 struct snd_pcm_substream *s = NULL; 715 struct snd_pcm_substream *s = NULL;
717 struct snd_pcm_substream *s1; 716 struct snd_pcm_substream *s1;
718 int res = 0; 717 int res = 0;
719 718
720 snd_pcm_group_for_each(pos, substream) { 719 snd_pcm_group_for_each_entry(s, substream) {
721 s = snd_pcm_group_substream_entry(pos);
722 if (do_lock && s != substream) 720 if (do_lock && s != substream)
723 spin_lock(&s->self_group.lock); 721 spin_lock(&s->self_group.lock);
724 res = ops->pre_action(s, state); 722 res = ops->pre_action(s, state);
725 if (res < 0) 723 if (res < 0)
726 goto _unlock; 724 goto _unlock;
727 } 725 }
728 snd_pcm_group_for_each(pos, substream) { 726 snd_pcm_group_for_each_entry(s, substream) {
729 s = snd_pcm_group_substream_entry(pos);
730 res = ops->do_action(s, state); 727 res = ops->do_action(s, state);
731 if (res < 0) { 728 if (res < 0) {
732 if (ops->undo_action) { 729 if (ops->undo_action) {
733 snd_pcm_group_for_each(pos, substream) { 730 snd_pcm_group_for_each_entry(s1, substream) {
734 s1 = snd_pcm_group_substream_entry(pos);
735 if (s1 == s) /* failed stream */ 731 if (s1 == s) /* failed stream */
736 break; 732 break;
737 ops->undo_action(s1, state); 733 ops->undo_action(s1, state);
@@ -741,15 +737,13 @@ static int snd_pcm_action_group(struct action_ops *ops,
741 goto _unlock; 737 goto _unlock;
742 } 738 }
743 } 739 }
744 snd_pcm_group_for_each(pos, substream) { 740 snd_pcm_group_for_each_entry(s, substream) {
745 s = snd_pcm_group_substream_entry(pos);
746 ops->post_action(s, state); 741 ops->post_action(s, state);
747 } 742 }
748 _unlock: 743 _unlock:
749 if (do_lock) { 744 if (do_lock) {
750 /* unlock streams */ 745 /* unlock streams */
751 snd_pcm_group_for_each(pos, substream) { 746 snd_pcm_group_for_each_entry(s1, substream) {
752 s1 = snd_pcm_group_substream_entry(pos);
753 if (s1 != substream) 747 if (s1 != substream)
754 spin_unlock(&s1->self_group.lock); 748 spin_unlock(&s1->self_group.lock);
755 if (s1 == s) /* end */ 749 if (s1 == s) /* end */
@@ -1438,7 +1432,7 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream)
1438{ 1432{
1439 struct snd_card *card; 1433 struct snd_card *card;
1440 struct snd_pcm_runtime *runtime; 1434 struct snd_pcm_runtime *runtime;
1441 struct list_head *pos; 1435 struct snd_pcm_substream *s;
1442 int result = 0; 1436 int result = 0;
1443 int i, num_drecs; 1437 int i, num_drecs;
1444 struct drain_rec *drec, drec_tmp, *d; 1438 struct drain_rec *drec, drec_tmp, *d;
@@ -1473,8 +1467,7 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream)
1473 1467
1474 /* count only playback streams */ 1468 /* count only playback streams */
1475 num_drecs = 0; 1469 num_drecs = 0;
1476 snd_pcm_group_for_each(pos, substream) { 1470 snd_pcm_group_for_each_entry(s, substream) {
1477 struct snd_pcm_substream *s = snd_pcm_group_substream_entry(pos);
1478 runtime = s->runtime; 1471 runtime = s->runtime;
1479 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { 1472 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1480 d = &drec[num_drecs++]; 1473 d = &drec[num_drecs++];
@@ -1674,7 +1667,7 @@ static void relink_to_local(struct snd_pcm_substream *substream)
1674 1667
1675static int snd_pcm_unlink(struct snd_pcm_substream *substream) 1668static int snd_pcm_unlink(struct snd_pcm_substream *substream)
1676{ 1669{
1677 struct list_head *pos; 1670 struct snd_pcm_substream *s;
1678 int res = 0; 1671 int res = 0;
1679 1672
1680 down_write(&snd_pcm_link_rwsem); 1673 down_write(&snd_pcm_link_rwsem);
@@ -1686,8 +1679,8 @@ static int snd_pcm_unlink(struct snd_pcm_substream *substream)
1686 list_del(&substream->link_list); 1679 list_del(&substream->link_list);
1687 substream->group->count--; 1680 substream->group->count--;
1688 if (substream->group->count == 1) { /* detach the last stream, too */ 1681 if (substream->group->count == 1) { /* detach the last stream, too */
1689 snd_pcm_group_for_each(pos, substream) { 1682 snd_pcm_group_for_each_entry(s, substream) {
1690 relink_to_local(snd_pcm_group_substream_entry(pos)); 1683 relink_to_local(s);
1691 break; 1684 break;
1692 } 1685 }
1693 kfree(substream->group); 1686 kfree(substream->group);