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.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.c')
-rw-r--r-- | sound/core/control.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/sound/core/control.c b/sound/core/control.c index 0c29679a8576..9742bdba0de1 100644 --- a/sound/core/control.c +++ b/sound/core/control.c | |||
@@ -658,7 +658,11 @@ static int snd_ctl_elem_info_user(struct snd_ctl_file *ctl, | |||
658 | 658 | ||
659 | if (copy_from_user(&info, _info, sizeof(info))) | 659 | if (copy_from_user(&info, _info, sizeof(info))) |
660 | return -EFAULT; | 660 | return -EFAULT; |
661 | result = snd_ctl_elem_info(ctl, &info); | 661 | snd_power_lock(ctl->card); |
662 | result = snd_power_wait(ctl->card, SNDRV_CTL_POWER_D0, NULL); | ||
663 | if (result >= 0) | ||
664 | result = snd_ctl_elem_info(ctl, &info); | ||
665 | snd_power_unlock(ctl->card); | ||
662 | if (result >= 0) | 666 | if (result >= 0) |
663 | if (copy_to_user(_info, &info, sizeof(info))) | 667 | if (copy_to_user(_info, &info, sizeof(info))) |
664 | return -EFAULT; | 668 | return -EFAULT; |
@@ -708,7 +712,11 @@ static int snd_ctl_elem_read_user(struct snd_card *card, | |||
708 | kfree(control); | 712 | kfree(control); |
709 | return -EFAULT; | 713 | return -EFAULT; |
710 | } | 714 | } |
711 | result = snd_ctl_elem_read(card, control); | 715 | snd_power_lock(card); |
716 | result = snd_power_wait(card, SNDRV_CTL_POWER_D0, NULL); | ||
717 | if (result >= 0) | ||
718 | result = snd_ctl_elem_read(card, control); | ||
719 | snd_power_unlock(card); | ||
712 | if (result >= 0) | 720 | if (result >= 0) |
713 | if (copy_to_user(_control, control, sizeof(*control))) | 721 | if (copy_to_user(_control, control, sizeof(*control))) |
714 | result = -EFAULT; | 722 | result = -EFAULT; |
@@ -758,6 +766,7 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file, | |||
758 | struct snd_ctl_elem_value __user *_control) | 766 | struct snd_ctl_elem_value __user *_control) |
759 | { | 767 | { |
760 | struct snd_ctl_elem_value *control; | 768 | struct snd_ctl_elem_value *control; |
769 | struct snd_card *card; | ||
761 | int result; | 770 | int result; |
762 | 771 | ||
763 | control = kmalloc(sizeof(*control), GFP_KERNEL); | 772 | control = kmalloc(sizeof(*control), GFP_KERNEL); |
@@ -767,7 +776,12 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file, | |||
767 | kfree(control); | 776 | kfree(control); |
768 | return -EFAULT; | 777 | return -EFAULT; |
769 | } | 778 | } |
770 | result = snd_ctl_elem_write(file->card, file, control); | 779 | card = file->card; |
780 | snd_power_lock(card); | ||
781 | result = snd_power_wait(card, SNDRV_CTL_POWER_D0, NULL); | ||
782 | if (result >= 0) | ||
783 | result = snd_ctl_elem_write(card, file, control); | ||
784 | snd_power_unlock(card); | ||
771 | if (result >= 0) | 785 | if (result >= 0) |
772 | if (copy_to_user(_control, control, sizeof(*control))) | 786 | if (copy_to_user(_control, control, sizeof(*control))) |
773 | result = -EFAULT; | 787 | result = -EFAULT; |