diff options
author | Geoffrey D. Bennett <g@b4.vu> | 2021-06-22 03:39:33 +0930 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2021-06-22 21:36:03 +0200 |
commit | 6fd9d695f305c8e18e8e87c28117c249040641c8 (patch) | |
tree | 4cbc3184b6c1084b5b7a4cb126a0d77337ee0ee8 /sound/usb | |
parent | d92b91576e3787659917f32d514de8c4d75631b4 (diff) |
ALSA: usb-audio: scarlett2: Move info lookup out of init function
The info variable is not used by snd_scarlett_gen2_init() except to
pass it to snd_scarlett_gen2_controls_create(), so move the lookup
into that function.
Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/c4b6d17708e104503d9a2b88f9b3320bb9904cfa.1624294591.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/mixer_scarlett_gen2.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c index 481ebdd1a0df..5cc4296944f5 100644 --- a/sound/usb/mixer_scarlett_gen2.c +++ b/sound/usb/mixer_scarlett_gen2.c @@ -2249,13 +2249,19 @@ static int scarlett2_init_notify(struct usb_mixer_interface *mixer) return usb_submit_urb(mixer->urb, GFP_KERNEL); } -static int snd_scarlett_gen2_controls_create(struct usb_mixer_interface *mixer, - const struct scarlett2_device_info *info) +static int snd_scarlett_gen2_controls_create(struct usb_mixer_interface *mixer) { + const struct scarlett2_device_info **info = scarlett2_devices; int err; + /* Find device in scarlett2_devices */ + while (*info && (*info)->usb_id != mixer->chip->usb_id) + info++; + if (!*info) + return -EINVAL; + /* Initialise private data */ - err = scarlett2_init_private(mixer, info); + err = scarlett2_init_private(mixer, *info); if (err < 0) return err; @@ -2310,19 +2316,12 @@ static int snd_scarlett_gen2_controls_create(struct usb_mixer_interface *mixer, int snd_scarlett_gen2_init(struct usb_mixer_interface *mixer) { struct snd_usb_audio *chip = mixer->chip; - const struct scarlett2_device_info **info = scarlett2_devices; int err; /* only use UAC_VERSION_2 */ if (!mixer->protocol) return 0; - /* find device in scarlett2_devices */ - while (*info && (*info)->usb_id != chip->usb_id) - info++; - if (!*info) - return -EINVAL; - if (!(chip->setup & SCARLETT2_ENABLE)) { usb_audio_info(chip, "Focusrite Scarlett Gen 2 Mixer Driver disabled; " @@ -2338,7 +2337,7 @@ int snd_scarlett_gen2_init(struct usb_mixer_interface *mixer) "Focusrite Scarlett Gen 2 Mixer Driver enabled pid=0x%04x", USB_ID_PRODUCT(chip->usb_id)); - err = snd_scarlett_gen2_controls_create(mixer, *info); + err = snd_scarlett_gen2_controls_create(mixer); if (err < 0) usb_audio_err(mixer->chip, "Error initialising Scarlett Mixer Driver: %d", |