aboutsummaryrefslogtreecommitdiff
path: root/sound/core/control.c
diff options
context:
space:
mode:
authordroidfivex <droidfivex@gmail.com>2016-11-18 01:05:47 +0900
committerdroidfivex <droidfivex@gmail.com>2016-11-18 01:05:47 +0900
commit1e8e1576c95730e425f472a569bb15325329a99e (patch)
tree66b14ebbc47c0bc6023aa57b91b1ab5a9ee6c8e6 /sound/core/control.c
parent8b77716a2a034c7658ea6569ddaa814c312dd94f (diff)
parent30bdd78c2f639b28acc02a4133479311e01b18ce (diff)
Merge branch 'cm-13.0' into cm-14.1HEADq10.0o8.0n7.1n7.0
Diffstat (limited to 'sound/core/control.c')
-rw-r--r--sound/core/control.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/sound/core/control.c b/sound/core/control.c
index 2487a6bb1c5..ef06e1439cd 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -1130,8 +1130,6 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,
struct user_element *ue;
int idx, err;
- if (!replace && card->user_ctl_count >= MAX_USER_CONTROLS)
- return -ENOMEM;
if (info->count < 1)
return -EINVAL;
access = info->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE :
@@ -1140,21 +1138,16 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,
SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE));
info->id.numid = 0;
memset(&kctl, 0, sizeof(kctl));
- down_write(&card->controls_rwsem);
- _kctl = snd_ctl_find_id(card, &info->id);
- err = 0;
- if (_kctl) {
- if (replace)
- err = snd_ctl_remove(card, _kctl);
- else
- err = -EBUSY;
- } else {
- if (replace)
- err = -ENOENT;
+
+ if (replace) {
+ err = snd_ctl_remove_user_ctl(file, &info->id);
+ if (err)
+ return err;
}
- up_write(&card->controls_rwsem);
- if (err < 0)
- return err;
+
+ if (card->user_ctl_count >= MAX_USER_CONTROLS)
+ return -ENOMEM;
+
memcpy(&kctl.id, &info->id, sizeof(info->id));
kctl.count = info->owner ? info->owner : 1;
access |= SNDRV_CTL_ELEM_ACCESS_USER;