ALSA: oxygen: use helper to activate the SPDIF PCM control
Subsystems (2)
PATCH 1/1 ALSA: oxygen: use helper to activate the SPDIF PCM control
oxygen_open() and oxygen_close() modify the SPDIF PCM control access flags while holding chip->mutex. Direct access changes bypass the control core locking and notification path.
Move the access transition outside the driver mutex and use snd_ctl_activate_id(), which serializes the control update with the control core.
Fixes d0ce9946c52e ("[ALSA] add CMI8788 driver")
Assisted-by LLM
Signed-off-by Runyu Xiao <[email protected]>
--- sound/pci/oxygen/oxygen_pcm.c | 37 +++++++++++++++-------------------- 1 file changed, 16 insertions(+), 21 deletions(-)
sound/pci/oxygen/oxygen_pcm.c +16 -21
@@ -171,16 +171,14 @@ static int oxygen_open(struct snd_pcm_substream *substream,snd_pcm_set_sync (substream); chip->streams[channel] = substream; -guard (mutex)(&chip->mutex); - chip->pcm_active |=1 << channel; -if (channel ==PCM_SPDIF ) { - chip->spdif_pcm_bits = chip->spdif_bits; - chip->controls[CONTROL_SPDIF_PCM ]->vd[0 ].access &= - ~SNDRV_CTL_ELEM_ACCESS_INACTIVE ; -snd_ctl_notify (chip->card,SNDRV_CTL_EVENT_MASK_VALUE | -SNDRV_CTL_EVENT_MASK_INFO , - &chip->controls[CONTROL_SPDIF_PCM ]->id); + scoped_guard(mutex, &chip->mutex) { + chip->pcm_active |=1 << channel; +if (channel ==PCM_SPDIF ) + chip->spdif_pcm_bits = chip->spdif_bits; } +if (channel ==PCM_SPDIF ) +snd_ctl_activate_id (chip->card, + &chip->controls[CONTROL_SPDIF_PCM ]->id,1 );return 0 ; }
@@ -220,19 +218,16 @@ static int oxygen_close(struct snd_pcm_substream *substream)struct oxygen *chip =snd_pcm_substream_chip (substream);unsigned int channel =oxygen_substream_channel (substream); -guard (mutex)(&chip->mutex); - chip->pcm_active &= ~(1 << channel); -if (channel ==PCM_SPDIF ) { - chip->controls[CONTROL_SPDIF_PCM ]->vd[0 ].access |= -SNDRV_CTL_ELEM_ACCESS_INACTIVE ; -snd_ctl_notify (chip->card,SNDRV_CTL_EVENT_MASK_VALUE | -SNDRV_CTL_EVENT_MASK_INFO , - &chip->controls[CONTROL_SPDIF_PCM ]->id); - } -if (channel ==PCM_SPDIF || channel ==PCM_MULTICH ) -oxygen_update_spdif_source (chip); + scoped_guard(mutex, &chip->mutex) { + chip->pcm_active &= ~(1 << channel); +if (channel ==PCM_SPDIF || channel ==PCM_MULTICH ) +oxygen_update_spdif_source (chip); - chip->streams[channel] =NULL ; + chip->streams[channel] =NULL ; + } +if (channel ==PCM_SPDIF ) +snd_ctl_activate_id (chip->card, + &chip->controls[CONTROL_SPDIF_PCM ]->id,0 );return 0 ; }
Signature · 1 line
2.34.1
Takashi Iwai
AppliedQuoted 5 lines · Runyu Xiao
oxygen_open()andoxygen_close()modify the SPDIF PCM control access flags while holdingchip->mutex. Direct access changes bypass the control core locking and notification path.
Quoted 7 lines
Move the access transition outside the driver mutex and use
snd_ctl_activate_id(), which serializes the control update with the control core.Fixes d0ce9946c52e ("[ALSA] add CMI8788 driver")Assisted-by LLMSigned-off-by Runyu Xiao <[email protected]>
Applied to for-next branch. Thanks.
Takashi