|
|
@@ -1154,8 +1154,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 :
|
|
|
@@ -1164,21 +1162,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;
|