[alsa-devel] [PATCH 09/24] ALSA: ctl: unify calls of D0-wait function for ELEM_INFO request

Takashi Sakamoto o-takashi at sakamocchi.jp
Sat Nov 25 10:19:51 CET 2017


When handling I/O request for ELEM_INFO, 'snd_power_wait()' function is
used before a call of 'snd_ctl_elem_info()' function. This is perhaps due
to performing I/O operation to actual devices. The same thing is done by
helper functions for native/compat ABI, and they can be unified.

This commit moves these duplicated codes into the callee function.

Signed-off-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>
---
 sound/core/control.c        | 7 ++++---
 sound/core/control_compat.c | 3 ---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/sound/core/control.c b/sound/core/control.c
index ad4d27c681c4..91966b190b8b 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -842,6 +842,10 @@ static int snd_ctl_elem_info(struct snd_ctl_file *ctl,
 	unsigned int index_offset;
 	int result;
 	
+	result = snd_power_wait(ctl->card, SNDRV_CTL_POWER_D0);
+	if (result < 0)
+		return result;
+
 	down_read(&card->controls_rwsem);
 	kctl = snd_ctl_find_id(card, &info->id);
 	if (kctl == NULL) {
@@ -879,9 +883,6 @@ static int snd_ctl_elem_info_user(struct snd_ctl_file *ctl,
 
 	if (copy_from_user(&info, _info, sizeof(info)))
 		return -EFAULT;
-	result = snd_power_wait(ctl->card, SNDRV_CTL_POWER_D0);
-	if (result < 0)
-		return result;
 	result = snd_ctl_elem_info(ctl, &info);
 	if (result < 0)
 		return result;
diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
index f0559ed785e0..e6169b2bc6b3 100644
--- a/sound/core/control_compat.c
+++ b/sound/core/control_compat.c
@@ -489,9 +489,6 @@ 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_power_wait(ctl->card, SNDRV_CTL_POWER_D0);
-	if (err < 0)
-		goto error;
 	err = snd_ctl_elem_info(ctl, data);
 	if (err < 0)
 		goto error;
-- 
2.14.1



More information about the Alsa-devel mailing list