Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: sigmadsp: Simplify with snd_ctl_activate_id()

Use the standard snd_ctl_activate_id() helper instead of an open code
for code simplification.

Acked-by: Mark Brown <broonie@kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: "Nuno Sá" <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230718141304.1032-7-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

+4 -21
+4 -21
sound/soc/codecs/sigmadsp.c
··· 669 669 struct sigmadsp_control *ctrl, unsigned int samplerate_mask) 670 670 { 671 671 struct snd_card *card = sigmadsp->component->card->snd_card; 672 - struct snd_kcontrol_volatile *vd; 673 - struct snd_ctl_elem_id id; 674 672 bool active; 675 - bool changed = false; 673 + int changed; 676 674 677 675 active = sigmadsp_samplerate_valid(ctrl->samplerates, samplerate_mask); 678 - 679 - down_write(&card->controls_rwsem); 680 - if (!ctrl->kcontrol) { 681 - up_write(&card->controls_rwsem); 676 + if (!ctrl->kcontrol) 682 677 return; 683 - } 684 - 685 - id = ctrl->kcontrol->id; 686 - vd = &ctrl->kcontrol->vd[0]; 687 - if (active == (bool)(vd->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE)) { 688 - vd->access ^= SNDRV_CTL_ELEM_ACCESS_INACTIVE; 689 - changed = true; 690 - } 691 - up_write(&card->controls_rwsem); 692 - 693 - if (active && changed) { 678 + changed = snd_ctl_activate_id(card, &ctrl->kcontrol->id, active); 679 + if (active && changed > 0) { 694 680 mutex_lock(&sigmadsp->lock); 695 681 if (ctrl->cached) 696 682 sigmadsp_ctrl_write(sigmadsp, ctrl, ctrl->cache); 697 683 mutex_unlock(&sigmadsp->lock); 698 684 } 699 - 700 - if (changed) 701 - snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_INFO, &id); 702 685 } 703 686 704 687 /**