ALSA: scarlett2: Refactor scarlett2_config_save()

Use the new scarlett2_usb_activate_config() helper function rather
than preparing the request manually and calling scarlett2_usb().

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/bbc733dc081f311fb3167e81b15cd76324aa6307.1703444932.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Geoffrey D. Bennett 2023-12-25 05:57:16 +10:30 committed by Takashi Iwai
parent 7f4d8dbea2
commit 9c2ea88e9e
1 changed files with 19 additions and 21 deletions

View File

@ -1562,27 +1562,6 @@ static int scarlett2_usb_get_config(
return 0;
}
/* Send SCARLETT2_USB_DATA_CMD SCARLETT2_USB_CONFIG_SAVE */
static void scarlett2_config_save(struct usb_mixer_interface *mixer)
{
__le32 req = cpu_to_le32(SCARLETT2_USB_CONFIG_SAVE);
int err = scarlett2_usb(mixer, SCARLETT2_USB_DATA_CMD,
&req, sizeof(u32),
NULL, 0);
if (err < 0)
usb_audio_err(mixer->chip, "config save failed: %d\n", err);
}
/* Delayed work to save config */
static void scarlett2_config_save_work(struct work_struct *work)
{
struct scarlett2_data *private =
container_of(work, struct scarlett2_data, work.work);
scarlett2_config_save(private->mixer);
}
/* Send a SCARLETT2_USB_SET_DATA command.
* offset: location in the device's data space
* size: size in bytes of the value (1, 2, 4)
@ -1686,6 +1665,25 @@ static int scarlett2_usb_set_config(
return 0;
}
/* Send SCARLETT2_USB_DATA_CMD SCARLETT2_USB_CONFIG_SAVE */
static void scarlett2_config_save(struct usb_mixer_interface *mixer)
{
int err;
err = scarlett2_usb_activate_config(mixer, SCARLETT2_USB_CONFIG_SAVE);
if (err < 0)
usb_audio_err(mixer->chip, "config save failed: %d\n", err);
}
/* Delayed work to save config */
static void scarlett2_config_save_work(struct work_struct *work)
{
struct scarlett2_data *private =
container_of(work, struct scarlett2_data, work.work);
scarlett2_config_save(private->mixer);
}
/* Send a USB message to get sync status; result placed in *sync */
static int scarlett2_usb_get_sync_status(
struct usb_mixer_interface *mixer,