summaryrefslogtreecommitdiff
path: root/sound/core/control.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2017-08-30 16:13:25 +0200
committerTakashi Iwai <tiwai@suse.de>2017-08-30 20:44:29 +0200
commit7d8e8292013ab72ae1f1500cbc91f198ccb1826d (patch)
tree5586c0e3b0483c98d1fe210a87246fd70131ba35 /sound/core/control.c
parent3454a476f2f5d6d3cac3b3f907190ffc58c4fd6f (diff)
ALSA: Get rid of card power_lock
Currently we're taking power_lock at each card component for assuring the power-up sequence, but it doesn't help anything in the implementation at the moment: it just serializes unnecessarily the callers, but it doesn't protect about the power state change itself. It used to have some usefulness in the early days where we managed the PM manually. But now the suspend/resume core procedure is beyond our hands, and power_lock lost its meaning. This patch drops the power_lock from allover the places. There shouldn't be any issues by this change, as it's no helper regarding the power state change. Rather we'll get better performance by removing the serialization; which is the only slight concern of any behavior change, but it can't be a showstopper, after all. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/control.c')
-rw-r--r--sound/core/control.c58
1 files changed, 31 insertions, 27 deletions
diff --git a/sound/core/control.c b/sound/core/control.c
index 51d4b4ad3e1d..56b3e2d49c82 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -864,14 +864,14 @@ 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);
- if (result >= 0)
- if (copy_to_user(_info, &info, sizeof(info)))
- return -EFAULT;
+ if (result < 0)
+ return result;
+ result = snd_ctl_elem_info(ctl, &info);
+ if (result < 0)
+ return result;
+ if (copy_to_user(_info, &info, sizeof(info)))
+ return -EFAULT;
return result;
}
@@ -905,17 +905,19 @@ static int snd_ctl_elem_read_user(struct snd_card *card,
if (IS_ERR(control))
return PTR_ERR(control);
- snd_power_lock(card);
result = snd_power_wait(card, SNDRV_CTL_POWER_D0);
- if (result >= 0) {
- down_read(&card->controls_rwsem);
- result = snd_ctl_elem_read(card, control);
- up_read(&card->controls_rwsem);
- }
- snd_power_unlock(card);
- if (result >= 0)
- if (copy_to_user(_control, control, sizeof(*control)))
- result = -EFAULT;
+ if (result < 0)
+ goto error;
+
+ down_read(&card->controls_rwsem);
+ result = snd_ctl_elem_read(card, control);
+ up_read(&card->controls_rwsem);
+ if (result < 0)
+ goto error;
+
+ if (copy_to_user(_control, control, sizeof(*control)))
+ result = -EFAULT;
+ error:
kfree(control);
return result;
}
@@ -964,17 +966,19 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file,
return PTR_ERR(control);
card = file->card;
- snd_power_lock(card);
result = snd_power_wait(card, SNDRV_CTL_POWER_D0);
- if (result >= 0) {
- down_write(&card->controls_rwsem);
- result = snd_ctl_elem_write(card, file, control);
- up_write(&card->controls_rwsem);
- }
- snd_power_unlock(card);
- if (result >= 0)
- if (copy_to_user(_control, control, sizeof(*control)))
- result = -EFAULT;
+ if (result < 0)
+ goto error;
+
+ down_write(&card->controls_rwsem);
+ result = snd_ctl_elem_write(card, file, control);
+ up_write(&card->controls_rwsem);
+ if (result < 0)
+ goto error;
+
+ if (copy_to_user(_control, control, sizeof(*control)))
+ result = -EFAULT;
+ error:
kfree(control);
return result;
}