Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef991b95 authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela
Browse files

[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: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent 5e24c1c1
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -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)
{
+10 −17
Original line number Diff line number Diff line
@@ -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);
+1 −3
Original line number Diff line number Diff line
@@ -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);
+1 −3
Original line number Diff line number Diff line
@@ -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);
+1 −3
Original line number Diff line number Diff line
@@ -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;
Loading