aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2014-10-31 09:45:04 -0400
committerTakashi Iwai <tiwai@suse.de>2014-10-31 10:27:02 -0400
commite3a4bd5eec52912108e287146052f2624acbec7a (patch)
treee45d0a4fc4ec9701079a840b8986e0f9b6af1ef8 /sound/core
parent4c41421657a3760056976fd517e7e6b3615febb3 (diff)
ALSA: pcm: Simplify snd_pcm_action_lock_irq()
The function snd_pcm_action_lock_irq() can be much simplified by simply wrapping snd_pcm_action() with the stream lock. This was rather the original idea, but later it was open coded for optimization. However, looking at the optimization part closely, one notices that the probability of the optimized path is quite low; in normal situations, the linked stream action happens only for the triggered substream, thus the operation becomes identical. So the code simplification has a clear win, especially because we have now doubly codes for both atomic and non-atomic locks. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/pcm_native.c41
1 files changed, 3 insertions, 38 deletions
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 4d5795d8b9f7..b92b605fc784 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -947,28 +947,6 @@ static int snd_pcm_action(struct action_ops *ops,
947 return res; 947 return res;
948} 948}
949 949
950static int snd_pcm_action_lock_mutex(struct action_ops *ops,
951 struct snd_pcm_substream *substream,
952 int state)
953{
954 int res;
955
956 down_read(&snd_pcm_link_rwsem);
957 if (snd_pcm_stream_linked(substream)) {
958 mutex_lock(&substream->group->mutex);
959 mutex_lock(&substream->self_group.mutex);
960 res = snd_pcm_action_group(ops, substream, state, 1);
961 mutex_unlock(&substream->self_group.mutex);
962 mutex_unlock(&substream->group->mutex);
963 } else {
964 mutex_lock(&substream->self_group.mutex);
965 res = snd_pcm_action_single(ops, substream, state);
966 mutex_unlock(&substream->self_group.mutex);
967 }
968 up_read(&snd_pcm_link_rwsem);
969 return res;
970}
971
972/* 950/*
973 * Note: don't use any locks before 951 * Note: don't use any locks before
974 */ 952 */
@@ -978,22 +956,9 @@ static int snd_pcm_action_lock_irq(struct action_ops *ops,
978{ 956{
979 int res; 957 int res;
980 958
981 if (substream->pcm->nonatomic) 959 snd_pcm_stream_lock_irq(substream);
982 return snd_pcm_action_lock_mutex(ops, substream, state); 960 res = snd_pcm_action(ops, substream, state);
983 961 snd_pcm_stream_unlock_irq(substream);
984 read_lock_irq(&snd_pcm_link_rwlock);
985 if (snd_pcm_stream_linked(substream)) {
986 spin_lock(&substream->group->lock);
987 spin_lock(&substream->self_group.lock);
988 res = snd_pcm_action_group(ops, substream, state, 1);
989 spin_unlock(&substream->self_group.lock);
990 spin_unlock(&substream->group->lock);
991 } else {
992 spin_lock(&substream->self_group.lock);
993 res = snd_pcm_action_single(ops, substream, state);
994 spin_unlock(&substream->self_group.lock);
995 }
996 read_unlock_irq(&snd_pcm_link_rwlock);
997 return res; 962 return res;
998} 963}
999 964