summaryrefslogtreecommitdiff
path: root/include/sound/control.h
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2024-04-02 22:19:21 +0100
committerMark Brown <broonie@kernel.org>2024-04-02 22:19:21 +0100
commitdbc93a554fcec8369a504e098726f0d44175c29c (patch)
tree2939a94768e1bf6c66494a78a9d172daf20fc578 /include/sound/control.h
parent4189b54220e5af15e948a48524b45d5ea2e5660d (diff)
parentef7784e41db73f3d31ce545227ebba4483479a26 (diff)
ASoC: Use snd_ctl_find_id_mixer() instead of
Merge series from Richard Fitzgerald <rf@opensource.cirrus.com>: The first two patches change snd_soc_card_get_kcontrol() to use the core snd_ctl_find_id_mixer() functionality instead of open-coding its own list walk. The last patch adds a KUnit test for this, which was tested on the original and modified code.
Diffstat (limited to 'include/sound/control.h')
-rw-r--r--include/sound/control.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/sound/control.h b/include/sound/control.h
index 9a4f4f7138da..c1659036c4a7 100644
--- a/include/sound/control.h
+++ b/include/sound/control.h
@@ -167,6 +167,29 @@ snd_ctl_find_id_mixer(struct snd_card *card, const char *name)
return snd_ctl_find_id(card, &id);
}
+/**
+ * snd_ctl_find_id_mixer_locked - find the control instance with the given name string
+ * @card: the card instance
+ * @name: the name string
+ *
+ * Finds the control instance with the given name and
+ * @SNDRV_CTL_ELEM_IFACE_MIXER. Other fields are set to zero.
+ *
+ * This is merely a wrapper to snd_ctl_find_id_locked().
+ * The caller must down card->controls_rwsem before calling this function.
+ *
+ * Return: The pointer of the instance if found, or %NULL if not.
+ */
+static inline struct snd_kcontrol *
+snd_ctl_find_id_mixer_locked(struct snd_card *card, const char *name)
+{
+ struct snd_ctl_elem_id id = {};
+
+ id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
+ strscpy(id.name, name, sizeof(id.name));
+ return snd_ctl_find_id_locked(card, &id);
+}
+
int snd_ctl_create(struct snd_card *card);
int snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn);