]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: soc-dapm: add snd_soc_dapm_alloc()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tue, 20 Jan 2026 00:14:54 +0000 (00:14 +0000)
committerMark Brown <broonie@kernel.org>
Mon, 26 Jan 2026 11:44:45 +0000 (11:44 +0000)
Because struct snd_soc_dapm_context is soc-dapm framework specific, user
driver don't need to access its member directly, we would like to hide
them. struct snd_soc_dapm_context will be removed from header in the
future.

Current card/component are using dapm_context instance. But it will be
moved to soc-dapm.c, and we can use will be only pointer. Makes it to
pointer.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://patch.msgid.link/87h5shqgw1.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc-component.h
include/sound/soc-dapm.h
include/sound/soc.h
sound/soc/soc-core.c
sound/soc/soc-dapm.c

index e538784746db78f826ab4dcd56401d29e9df6f86..2a2b74b24a6096d5dcdcd3a02d5e2f8e8a4596e3 100644 (file)
@@ -237,8 +237,7 @@ struct snd_soc_component {
         * the driver will be marked as BROKEN when these fields are removed.
         */
 
-       /* Don't use these, use snd_soc_component_get_dapm() */
-       struct snd_soc_dapm_context dapm;
+       struct snd_soc_dapm_context *dapm;
 
        /* machine specific init */
        int (*init)(struct snd_soc_component *component);
@@ -268,7 +267,7 @@ struct snd_soc_component {
 static inline struct snd_soc_dapm_context *snd_soc_component_to_dapm(
        struct snd_soc_component *component)
 {
-       return &component->dapm;
+       return component->dapm;
 }
 
 /**
index 010d63db5436b14b85237c0552443f5554d48cc4..6f3e1b57cda32c85c3f52808daa1156a596cb2db 100644 (file)
@@ -627,6 +627,8 @@ enum snd_soc_dapm_direction {
 #define SND_SOC_DAPM_EP_SOURCE SND_SOC_DAPM_DIR_TO_EP(SND_SOC_DAPM_DIR_IN)
 #define SND_SOC_DAPM_EP_SINK   SND_SOC_DAPM_DIR_TO_EP(SND_SOC_DAPM_DIR_OUT)
 
+struct snd_soc_dapm_context *snd_soc_dapm_alloc(struct device *dev);
+
 int snd_soc_dapm_regulator_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event);
 int snd_soc_dapm_clock_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event);
 int snd_soc_dapm_pinctrl_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event);
index aa0fe6b802934b3c1056eacf3cbe063647ff0845..7d8376c8e1bededf7f5a3cb478b6f1f966c99da5 100644 (file)
@@ -1076,7 +1076,7 @@ struct snd_soc_card {
        struct list_head dobj_list;
 
        /* Generic DAPM context for the card */
-       struct snd_soc_dapm_context dapm;
+       struct snd_soc_dapm_context *dapm;
        struct snd_soc_dapm_stats dapm_stats;
 
 #ifdef CONFIG_DEBUG_FS
@@ -1136,7 +1136,7 @@ static inline int snd_soc_card_is_instantiated(struct snd_soc_card *card)
 
 static inline struct snd_soc_dapm_context *snd_soc_card_to_dapm(struct snd_soc_card *card)
 {
-       return &card->dapm;
+       return card->dapm;
 }
 
 /* SoC machine DAI configuration, glues a codec and cpu DAI together */
index e4b21bf39e59f611aad4c8da1bc4a38c5078d17d..355ccc95f28ba3cb63b94f646d0b7db328cd1123 100644 (file)
@@ -2556,6 +2556,10 @@ int snd_soc_register_card(struct snd_soc_card *card)
        if (!card->name || !card->dev)
                return -EINVAL;
 
+       card->dapm = snd_soc_dapm_alloc(card->dev);
+       if (!card->dapm)
+               return -ENOMEM;
+
        dev_set_drvdata(card->dev, card);
 
        INIT_LIST_HEAD(&card->widgets);
@@ -2840,6 +2844,10 @@ int snd_soc_component_initialize(struct snd_soc_component *component,
                                 const struct snd_soc_component_driver *driver,
                                 struct device *dev)
 {
+       component->dapm = snd_soc_dapm_alloc(dev);
+       if (!component->dapm)
+               return -ENOMEM;
+
        INIT_LIST_HEAD(&component->dai_list);
        INIT_LIST_HEAD(&component->dobj_list);
        INIT_LIST_HEAD(&component->card_list);
index 4c2007c61ca14330cb9c153fa7c9eb03d9a757ff..7aef57dcb2a72b149316336b062b543d9242a336 100644 (file)
@@ -165,6 +165,11 @@ static void pop_dbg(struct device *dev, u32 pop_time, const char *fmt, ...)
        kfree(buf);
 }
 
+struct snd_soc_dapm_context *snd_soc_dapm_alloc(struct device *dev)
+{
+       return devm_kzalloc(dev, sizeof(struct snd_soc_dapm_context), GFP_KERNEL);
+}
+
 struct device *snd_soc_dapm_to_dev(struct snd_soc_dapm_context *dapm)
 {
        if (dapm->component)
@@ -1076,7 +1081,7 @@ static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm,
        if (ret != 0)
                goto out;
 
-       if (dapm != &card->dapm)
+       if (dapm != card->dapm)
                ret = snd_soc_dapm_force_bias_level(dapm, level);
 
        if (ret != 0)