aboutsummaryrefslogtreecommitdiff
path: root/sound/core/control_compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core/control_compat.c')
-rw-r--r--sound/core/control_compat.c49
1 files changed, 36 insertions, 13 deletions
diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
index 418c6d4e5da..84fef5084e1 100644
--- a/sound/core/control_compat.c
+++ b/sound/core/control_compat.c
@@ -107,7 +107,13 @@ static int snd_ctl_elem_info_compat(struct snd_ctl_file *ctl,
*/
if (get_user(data->value.enumerated.item, &data32->value.enumerated.item))
goto error;
- err = snd_ctl_elem_info(ctl, data);
+
+ snd_power_lock(ctl->card);
+ err = snd_power_wait(ctl->card, SNDRV_CTL_POWER_D0, NULL);
+ if (err >= 0)
+ err = snd_ctl_elem_info(ctl, data);
+ snd_power_unlock(ctl->card);
+
if (err < 0)
goto error;
/* restore info to 32bit */
@@ -167,7 +173,7 @@ static int get_ctl_type(struct snd_card *card, struct snd_ctl_elem_id *id,
int *countp)
{
struct snd_kcontrol *kctl;
- struct snd_ctl_elem_info info;
+ struct snd_ctl_elem_info *info;
int err;
down_read(&card->controls_rwsem);
@@ -176,13 +182,19 @@ static int get_ctl_type(struct snd_card *card, struct snd_ctl_elem_id *id,
up_read(&card->controls_rwsem);
return -ENXIO;
}
- info.id = *id;
- err = kctl->info(kctl, &info);
+ info = kzalloc(sizeof(*info), GFP_KERNEL);
+ if (info == NULL) {
+ up_read(&card->controls_rwsem);
+ return -ENOMEM;
+ }
+ info->id = *id;
+ err = kctl->info(kctl, info);
up_read(&card->controls_rwsem);
if (err >= 0) {
- err = info.type;
- *countp = info.count;
+ err = info->type;
+ *countp = info->count;
}
+ kfree(info);
return err;
}
@@ -280,9 +292,14 @@ static int snd_ctl_elem_read_user_compat(struct snd_card *card,
if ((err = copy_ctl_value_from_user(card, data, data32, &type, &count)) < 0)
goto error;
- if ((err = snd_ctl_elem_read(card, data)) < 0)
- goto error;
- err = copy_ctl_value_to_user(data32, data, type, count);
+
+ snd_power_lock(card);
+ err = snd_power_wait(card, SNDRV_CTL_POWER_D0, NULL);
+ if (err >= 0)
+ err = snd_ctl_elem_read(card, data);
+ snd_power_unlock(card);
+ if (err >= 0)
+ err = copy_ctl_value_to_user(data32, data, type, count);
error:
kfree(data);
return err;
@@ -292,17 +309,23 @@ static int snd_ctl_elem_write_user_compat(struct snd_ctl_file *file,
struct snd_ctl_elem_value32 __user *data32)
{
struct snd_ctl_elem_value *data;
+ struct snd_card *card = file->card;
int err, type, count;
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (data == NULL)
return -ENOMEM;
- if ((err = copy_ctl_value_from_user(file->card, data, data32, &type, &count)) < 0)
- goto error;
- if ((err = snd_ctl_elem_write(file->card, file, data)) < 0)
+ if ((err = copy_ctl_value_from_user(card, data, data32, &type, &count)) < 0)
goto error;
- err = copy_ctl_value_to_user(data32, data, type, count);
+
+ snd_power_lock(card);
+ err = snd_power_wait(card, SNDRV_CTL_POWER_D0, NULL);
+ if (err >= 0)
+ err = snd_ctl_elem_write(card, file, data);
+ snd_power_unlock(card);
+ if (err >= 0)
+ err = copy_ctl_value_to_user(data32, data, type, count);
error:
kfree(data);
return err;