diff options
author | Takashi Iwai <tiwai@suse.de> | 2020-11-23 09:53:36 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2020-11-23 15:16:04 +0100 |
commit | 6aa719d15a1903eb3fd0e052ae53f3b024ad4d05 (patch) | |
tree | 026ff7427535388baf0850e848991c535c3bb0a1 /sound/usb/pcm.c | |
parent | ALSA: usb-audio: Refactoring endpoint URB deactivation (diff) | |
download | linux-6aa719d15a1903eb3fd0e052ae53f3b024ad4d05.tar.xz linux-6aa719d15a1903eb3fd0e052ae53f3b024ad4d05.zip |
ALSA: usb-audio: Drop unneeded snd_usb_substream fields
Some fields like interface and alt_idx in snd_usb_substream are mostly
useless now as they can be referred via either cur_audiofmt or
data_endpoint assigned to the substream. Drop those, and also assure
the concurrency about the access of cur_audiofmt field.
Tested-by: Keith Milner <kamilner@superlative.org>
Tested-by: Dylan Robinson <dylan_robinson@motu.com>
Link: https://lore.kernel.org/r/20201123085347.19667-31-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/pcm.c')
-rw-r--r-- | sound/usb/pcm.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index fc028492dd1a..95a6a854dc55 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -797,20 +797,11 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream, subs->sync_endpoint); } - subs->interface = fmt->iface; - subs->altset_idx = fmt->altset_idx; + mutex_lock(&chip->mutex); subs->cur_audiofmt = fmt; + mutex_unlock(&chip->mutex); ret = configure_endpoints(chip, subs); - if (ret < 0) - goto unlock; - - subs->pcm_format = params_format(hw_params); - subs->period_bytes = params_period_bytes(hw_params); - subs->period_frames = params_period_size(hw_params); - subs->buffer_periods = params_periods(hw_params); - subs->channels = params_channels(hw_params); - subs->cur_rate = params_rate(hw_params); unlock: if (ret < 0) @@ -835,9 +826,9 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream) struct snd_usb_audio *chip = subs->stream->chip; snd_media_stop_pipeline(subs); + mutex_lock(&chip->mutex); subs->cur_audiofmt = NULL; - subs->cur_rate = 0; - subs->period_bytes = 0; + mutex_unlock(&chip->mutex); if (!snd_usb_lock_shutdown(chip)) { if (stop_endpoints(subs)) sync_pending_stops(subs); @@ -1274,8 +1265,6 @@ static int snd_usb_pcm_open(struct snd_pcm_substream *substream) struct snd_usb_substream *subs = &as->substream[direction]; int ret; - subs->interface = -1; - subs->altset_idx = 0; runtime->hw = snd_usb_hardware; runtime->private_data = subs; subs->pcm_substream = substream; @@ -1308,7 +1297,6 @@ static int snd_usb_pcm_close(struct snd_pcm_substream *substream) snd_media_stop_pipeline(subs); if (!snd_usb_lock_shutdown(subs->stream->chip)) { - subs->interface = -1; ret = snd_usb_pcm_change_state(subs, UAC3_PD_STATE_D1); snd_usb_unlock_shutdown(subs->stream->chip); if (ret < 0) @@ -1570,10 +1558,10 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, } bytes = frames * ep->stride; - if (unlikely(subs->pcm_format == SNDRV_PCM_FORMAT_DSD_U16_LE && + if (unlikely(ep->cur_format == SNDRV_PCM_FORMAT_DSD_U16_LE && subs->cur_audiofmt->dsd_dop)) { fill_playback_urb_dsd_dop(subs, urb, bytes); - } else if (unlikely(subs->pcm_format == SNDRV_PCM_FORMAT_DSD_U8 && + } else if (unlikely(ep->cur_format == SNDRV_PCM_FORMAT_DSD_U8 && subs->cur_audiofmt->dsd_bitrev)) { /* bit-reverse the bytes */ u8 *buf = urb->transfer_buffer; |