diff options
author | Giuliano Pochini <pochini@shiny.it> | 2006-03-13 08:11:11 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-03-22 04:37:23 -0500 |
commit | 646494007b48e8897888cd407c2b7d1d69cb2e58 (patch) | |
tree | 02d72d5f844ecb0ce3c25b1b8401ca3b172fa866 /sound/core/control_compat.c | |
parent | 9230d2148a0c53188c216b446cf17ea213ebca8a (diff) |
[ALSA] make control.c suspend aware
Modules: Control Midlevel
This patch prevents user-space apps from accessing the hardware via
control interface while the soundcard is suspended.
Signed-off-by: Giuliano Pochini <pochini@shiny.it>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/control_compat.c')
-rw-r--r-- | sound/core/control_compat.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c index a529b62972b4..84fef5084e17 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, | |||
107 | */ | 107 | */ |
108 | if (get_user(data->value.enumerated.item, &data32->value.enumerated.item)) | 108 | if (get_user(data->value.enumerated.item, &data32->value.enumerated.item)) |
109 | goto error; | 109 | goto error; |
110 | err = snd_ctl_elem_info(ctl, data); | 110 | |
111 | snd_power_lock(ctl->card); | ||
112 | err = snd_power_wait(ctl->card, SNDRV_CTL_POWER_D0, NULL); | ||
113 | if (err >= 0) | ||
114 | err = snd_ctl_elem_info(ctl, data); | ||
115 | snd_power_unlock(ctl->card); | ||
116 | |||
111 | if (err < 0) | 117 | if (err < 0) |
112 | goto error; | 118 | goto error; |
113 | /* restore info to 32bit */ | 119 | /* restore info to 32bit */ |
@@ -286,9 +292,14 @@ static int snd_ctl_elem_read_user_compat(struct snd_card *card, | |||
286 | 292 | ||
287 | if ((err = copy_ctl_value_from_user(card, data, data32, &type, &count)) < 0) | 293 | if ((err = copy_ctl_value_from_user(card, data, data32, &type, &count)) < 0) |
288 | goto error; | 294 | goto error; |
289 | if ((err = snd_ctl_elem_read(card, data)) < 0) | 295 | |
290 | goto error; | 296 | snd_power_lock(card); |
291 | err = copy_ctl_value_to_user(data32, data, type, count); | 297 | err = snd_power_wait(card, SNDRV_CTL_POWER_D0, NULL); |
298 | if (err >= 0) | ||
299 | err = snd_ctl_elem_read(card, data); | ||
300 | snd_power_unlock(card); | ||
301 | if (err >= 0) | ||
302 | err = copy_ctl_value_to_user(data32, data, type, count); | ||
292 | error: | 303 | error: |
293 | kfree(data); | 304 | kfree(data); |
294 | return err; | 305 | return err; |
@@ -298,17 +309,23 @@ static int snd_ctl_elem_write_user_compat(struct snd_ctl_file *file, | |||
298 | struct snd_ctl_elem_value32 __user *data32) | 309 | struct snd_ctl_elem_value32 __user *data32) |
299 | { | 310 | { |
300 | struct snd_ctl_elem_value *data; | 311 | struct snd_ctl_elem_value *data; |
312 | struct snd_card *card = file->card; | ||
301 | int err, type, count; | 313 | int err, type, count; |
302 | 314 | ||
303 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 315 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
304 | if (data == NULL) | 316 | if (data == NULL) |
305 | return -ENOMEM; | 317 | return -ENOMEM; |
306 | 318 | ||
307 | if ((err = copy_ctl_value_from_user(file->card, data, data32, &type, &count)) < 0) | 319 | if ((err = copy_ctl_value_from_user(card, data, data32, &type, &count)) < 0) |
308 | goto error; | ||
309 | if ((err = snd_ctl_elem_write(file->card, file, data)) < 0) | ||
310 | goto error; | 320 | goto error; |
311 | err = copy_ctl_value_to_user(data32, data, type, count); | 321 | |
322 | snd_power_lock(card); | ||
323 | err = snd_power_wait(card, SNDRV_CTL_POWER_D0, NULL); | ||
324 | if (err >= 0) | ||
325 | err = snd_ctl_elem_write(card, file, data); | ||
326 | snd_power_unlock(card); | ||
327 | if (err >= 0) | ||
328 | err = copy_ctl_value_to_user(data32, data, type, count); | ||
312 | error: | 329 | error: |
313 | kfree(data); | 330 | kfree(data); |
314 | return err; | 331 | return err; |