summaryrefslogtreecommitdiffstats
path: root/sound/core/pcm.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2014-02-19 14:30:29 +0100
committerTakashi Iwai <tiwai@suse.de>2015-02-02 14:21:21 +0100
commit23c18d4bfd73ee24070849faf98b3ab01263a3c4 (patch)
tree944e0e24bd847fdbbddd8baf5ab0976c0fdcfa81 /sound/core/pcm.c
parent92b7952da8279189aad352efbf9f2e7001de9524 (diff)
downloadlinux-23c18d4bfd73ee24070849faf98b3ab01263a3c4.tar.gz
linux-23c18d4bfd73ee24070849faf98b3ab01263a3c4.tar.bz2
linux-23c18d4bfd73ee24070849faf98b3ab01263a3c4.zip
ALSA: control: Provide a helper to look for the preferred subdevice
Instead of open-coding the search over the control file loop, provide a helper function for the preferred subdevice assigned to the current process. Reviewed-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/pcm.c')
-rw-r--r--sound/core/pcm.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index dba5180e5b80..1b7c473720fa 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -161,7 +161,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card,
if (get_user(val, (int __user *)arg))
return -EFAULT;
- control->prefer_pcm_subdevice = val;
+ control->preferred_subdevice[SND_CTL_SUBDEV_PCM] = val;
return 0;
}
}
@@ -901,9 +901,8 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
struct snd_pcm_str * pstr;
struct snd_pcm_substream *substream;
struct snd_pcm_runtime *runtime;
- struct snd_ctl_file *kctl;
struct snd_card *card;
- int prefer_subdevice = -1;
+ int prefer_subdevice;
size_t size;
if (snd_BUG_ON(!pcm || !rsubstream))
@@ -914,15 +913,7 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
return -ENODEV;
card = pcm->card;
- read_lock(&card->ctl_files_rwlock);
- list_for_each_entry(kctl, &card->ctl_files, list) {
- if (kctl->pid == task_pid(current)) {
- prefer_subdevice = kctl->prefer_pcm_subdevice;
- if (prefer_subdevice != -1)
- break;
- }
- }
- read_unlock(&card->ctl_files_rwlock);
+ prefer_subdevice = snd_ctl_get_preferred_subdevice(card, SND_CTL_SUBDEV_PCM);
switch (stream) {
case SNDRV_PCM_STREAM_PLAYBACK: