Commit aa8edd8c authored by Takashi Iwai's avatar Takashi Iwai

ALSA: pcm: Refactoring snd_pcm_action()

Just a small code refactoring to reduce more lines.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent e3a4bd5e
...@@ -900,14 +900,19 @@ static int snd_pcm_action_single(struct action_ops *ops, ...@@ -900,14 +900,19 @@ static int snd_pcm_action_single(struct action_ops *ops,
return res; return res;
} }
/* call in mutex-protected context */ /*
static int snd_pcm_action_mutex(struct action_ops *ops, * Note: call with stream lock
*/
static int snd_pcm_action(struct action_ops *ops,
struct snd_pcm_substream *substream, struct snd_pcm_substream *substream,
int state) int state)
{ {
int res; int res;
if (snd_pcm_stream_linked(substream)) { if (!snd_pcm_stream_linked(substream))
return snd_pcm_action_single(ops, substream, state);
if (substream->pcm->nonatomic) {
if (!mutex_trylock(&substream->group->mutex)) { if (!mutex_trylock(&substream->group->mutex)) {
mutex_unlock(&substream->self_group.mutex); mutex_unlock(&substream->self_group.mutex);
mutex_lock(&substream->group->mutex); mutex_lock(&substream->group->mutex);
...@@ -916,24 +921,6 @@ static int snd_pcm_action_mutex(struct action_ops *ops, ...@@ -916,24 +921,6 @@ static int snd_pcm_action_mutex(struct action_ops *ops,
res = snd_pcm_action_group(ops, substream, state, 1); res = snd_pcm_action_group(ops, substream, state, 1);
mutex_unlock(&substream->group->mutex); mutex_unlock(&substream->group->mutex);
} else { } else {
res = snd_pcm_action_single(ops, substream, state);
}
return res;
}
/*
* Note: call with stream lock
*/
static int snd_pcm_action(struct action_ops *ops,
struct snd_pcm_substream *substream,
int state)
{
int res;
if (substream->pcm->nonatomic)
return snd_pcm_action_mutex(ops, substream, state);
if (snd_pcm_stream_linked(substream)) {
if (!spin_trylock(&substream->group->lock)) { if (!spin_trylock(&substream->group->lock)) {
spin_unlock(&substream->self_group.lock); spin_unlock(&substream->self_group.lock);
spin_lock(&substream->group->lock); spin_lock(&substream->group->lock);
...@@ -941,8 +928,6 @@ static int snd_pcm_action(struct action_ops *ops, ...@@ -941,8 +928,6 @@ static int snd_pcm_action(struct action_ops *ops,
} }
res = snd_pcm_action_group(ops, substream, state, 1); res = snd_pcm_action_group(ops, substream, state, 1);
spin_unlock(&substream->group->lock); spin_unlock(&substream->group->lock);
} else {
res = snd_pcm_action_single(ops, substream, state);
} }
return res; return res;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment