summaryrefslogtreecommitdiff
path: root/sound/usb/clock.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2021-05-18 18:21:12 +0300
committerTakashi Iwai <tiwai@suse.de>2021-05-19 17:23:05 +0300
commit481f17c41803985446fd12887b2c042f9c43b0d5 (patch)
tree5cb45f66f30da6580062fae0d09625000472bd01 /sound/usb/clock.c
parent9ec730052fa262a9b66993d282a39511e4819e06 (diff)
downloadlinux-481f17c41803985446fd12887b2c042f9c43b0d5.tar.xz
ALSA: usb-audio: Handle error for the current selector gracefully
Currently we bail out when the device returns an error or an invalid value for the current clock selector value via uac_clock_selector_get_val(). But it's possible that the device is really uninitialized and waits for the setup of the proper route at first. For handling such a case, this patch lets the driver dealing with the error or the invalid error more gracefully, choosing the clock source automatically instead. Link: https://lore.kernel.org/r/20210518152112.8016-3-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/clock.c')
-rw-r--r--sound/usb/clock.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/sound/usb/clock.c b/sound/usb/clock.c
index 48a79f1b6233..772478c725c2 100644
--- a/sound/usb/clock.c
+++ b/sound/usb/clock.c
@@ -299,8 +299,11 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
/* the entity ID we are looking for is a selector.
* find out what it currently selects */
ret = uac_clock_selector_get_val(chip, clock_id);
- if (ret < 0)
- return ret;
+ if (ret < 0) {
+ if (!chip->autoclock)
+ return ret;
+ goto find_others;
+ }
/* Selector values are one-based */
@@ -309,7 +312,10 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
"%s(): selector reported illegal value, id %d, ret %d\n",
__func__, clock_id, ret);
- return -EINVAL;
+ if (!chip->autoclock)
+ return -EINVAL;
+ ret = 0;
+ goto find_others;
}
find_source:
@@ -326,6 +332,7 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
if (!validate || ret > 0 || !chip->autoclock)
return ret;
+ find_others:
/* The current clock source is invalid, try others. */
for (i = 1; i <= pins; i++) {
if (i == cur)