linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / sound / core / control.c
index 22565c9..ebf68f1 100644 (file)
@@ -309,29 +309,28 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
 {
        struct snd_ctl_elem_id id;
        unsigned int idx;
-       int err = -EINVAL;
 
+       snd_assert(card != NULL, return -EINVAL);
        if (! kcontrol)
-               return err;
-       snd_assert(card != NULL, goto error);
-       snd_assert(kcontrol->info != NULL, goto error);
+               return -EINVAL;
+       snd_assert(kcontrol->info != NULL, return -EINVAL);
        id = kcontrol->id;
        down_write(&card->controls_rwsem);
        if (snd_ctl_find_id(card, &id)) {
                up_write(&card->controls_rwsem);
+               snd_ctl_free_one(kcontrol);
                snd_printd(KERN_ERR "control %i:%i:%i:%s:%i is already present\n",
                                        id.iface,
                                        id.device,
                                        id.subdevice,
                                        id.name,
                                        id.index);
-               err = -EBUSY;
-               goto error;
+               return -EBUSY;
        }
        if (snd_ctl_find_hole(card, kcontrol->count) < 0) {
                up_write(&card->controls_rwsem);
-               err = -ENOMEM;
-               goto error;
+               snd_ctl_free_one(kcontrol);
+               return -ENOMEM;
        }
        list_add_tail(&kcontrol->list, &card->controls);
        card->controls_count += kcontrol->count;
@@ -341,10 +340,6 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
        for (idx = 0; idx < kcontrol->count; idx++, id.index++, id.numid++)
                snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id);
        return 0;
-
- error:
-       snd_ctl_free_one(kcontrol);
-       return err;
 }
 
 /**
@@ -663,11 +658,7 @@ static int snd_ctl_elem_info_user(struct snd_ctl_file *ctl,
 
        if (copy_from_user(&info, _info, sizeof(info)))
                return -EFAULT;
-       snd_power_lock(ctl->card);
-       result = snd_power_wait(ctl->card, SNDRV_CTL_POWER_D0);
-       if (result >= 0)
-               result = snd_ctl_elem_info(ctl, &info);
-       snd_power_unlock(ctl->card);
+       result = snd_ctl_elem_info(ctl, &info);
        if (result >= 0)
                if (copy_to_user(_info, &info, sizeof(info)))
                        return -EFAULT;
@@ -717,11 +708,7 @@ static int snd_ctl_elem_read_user(struct snd_card *card,
                kfree(control);
                return -EFAULT;
        }
-       snd_power_lock(card);
-       result = snd_power_wait(card, SNDRV_CTL_POWER_D0);
-       if (result >= 0)
-               result = snd_ctl_elem_read(card, control);
-       snd_power_unlock(card);
+       result = snd_ctl_elem_read(card, control);
        if (result >= 0)
                if (copy_to_user(_control, control, sizeof(*control)))
                        result = -EFAULT;
@@ -771,7 +758,6 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file,
                                   struct snd_ctl_elem_value __user *_control)
 {
        struct snd_ctl_elem_value *control;
-       struct snd_card *card;
        int result;
 
        control = kmalloc(sizeof(*control), GFP_KERNEL);
@@ -781,12 +767,7 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file,
                kfree(control);
                return -EFAULT;
        }
-       card = file->card;
-       snd_power_lock(card);
-       result = snd_power_wait(card, SNDRV_CTL_POWER_D0);
-       if (result >= 0)
-               result = snd_ctl_elem_write(card, file, control);
-       snd_power_unlock(card);
+       result = snd_ctl_elem_write(file->card, file, control);
        if (result >= 0)
                if (copy_to_user(_control, control, sizeof(*control)))
                        result = -EFAULT;
@@ -973,6 +954,7 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,
        if (ue == NULL)
                return -ENOMEM;
        ue->info = *info;
+       ue->info.access = 0;
        ue->elem_data = (char *)ue + sizeof(*ue);
        ue->elem_data_size = private_size;
        kctl.private_free = snd_ctl_elem_user_free;