* [PATCH 0/2] ASoC: meson: preparation for Card capsuling
@ 2026-07-21 1:36 Kuninori Morimoto
2026-07-21 1:36 ` [PATCH RFC 1/2] ASoC: meson: meson-card-utils: use meson_card_parse_of_optional() Kuninori Morimoto
2026-07-21 1:36 ` [PATCH 2/2] ASoC: meson: meson-card: use priv instead of card on each functions Kuninori Morimoto
0 siblings, 2 replies; 8+ messages in thread
From: Kuninori Morimoto @ 2026-07-21 1:36 UTC (permalink / raw)
To: Jaroslav Kysela, Jerome Brunet, Kevin Hilman, Liam Girdwood,
Mark Brown, Martin Blumenstingl, Neil Armstrong, Takashi Iwai
Cc: linux-arm-kernel, linux-sound
Hi Meson developers
I will post Card capsuling patch.
To makes its review easy, tidyup meson drivers to reduce
un-related diff as preparation.
No functional change, but is preparation for cleanup driver.
[1/2] is RFC
Kuninori Morimoto (2):
ASoC: meson: meson-card-utils: use meson_card_parse_of_optional()
ASoC: meson: meson-card: use priv instead of card on each functions
sound/soc/meson/axg-card.c | 63 ++++++++++++++++--------------
sound/soc/meson/gx-card.c | 23 +++++------
sound/soc/meson/meson-card-utils.c | 59 +++++++++++++++-------------
sound/soc/meson/meson-card.h | 11 +++---
4 files changed, 83 insertions(+), 73 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH RFC 1/2] ASoC: meson: meson-card-utils: use meson_card_parse_of_optional()
2026-07-21 1:36 [PATCH 0/2] ASoC: meson: preparation for Card capsuling Kuninori Morimoto
@ 2026-07-21 1:36 ` Kuninori Morimoto
2026-07-21 7:32 ` Jerome Brunet
2026-07-21 1:36 ` [PATCH 2/2] ASoC: meson: meson-card: use priv instead of card on each functions Kuninori Morimoto
1 sibling, 1 reply; 8+ messages in thread
From: Kuninori Morimoto @ 2026-07-21 1:36 UTC (permalink / raw)
To: Jaroslav Kysela, Jerome Brunet, Kevin Hilman, Liam Girdwood,
Mark Brown, Martin Blumenstingl, Neil Armstrong, Takashi Iwai
Cc: linux-arm-kernel, linux-sound
We already have meson_card_parse_of_optional(). Let's use it for
snd_soc_of_parse_aux_devs() too.
It is using snd_soc_of_parse_card_name(), but let's keep as-is
for it for now. Beuase it will be not able to share code when
Card capsuling.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/meson/meson-card-utils.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/soc/meson/meson-card-utils.c b/sound/soc/meson/meson-card-utils.c
index 8617a4661a339..d144ab79b645b 100644
--- a/sound/soc/meson/meson-card-utils.c
+++ b/sound/soc/meson/meson-card-utils.c
@@ -300,7 +300,8 @@ int meson_card_probe(struct platform_device *pdev)
if (ret)
goto out_err;
- ret = snd_soc_of_parse_aux_devs(&priv->card, "audio-aux-devs");
+ ret = meson_card_parse_of_optional(&priv->card, "audio-aux-devs",
+ snd_soc_of_parse_aux_devs);
if (ret)
goto out_err;
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] ASoC: meson: meson-card: use priv instead of card on each functions
2026-07-21 1:36 [PATCH 0/2] ASoC: meson: preparation for Card capsuling Kuninori Morimoto
2026-07-21 1:36 ` [PATCH RFC 1/2] ASoC: meson: meson-card-utils: use meson_card_parse_of_optional() Kuninori Morimoto
@ 2026-07-21 1:36 ` Kuninori Morimoto
2026-07-21 7:35 ` Jerome Brunet
1 sibling, 1 reply; 8+ messages in thread
From: Kuninori Morimoto @ 2026-07-21 1:36 UTC (permalink / raw)
To: Jaroslav Kysela, Jerome Brunet, Kevin Hilman, Liam Girdwood,
Mark Brown, Martin Blumenstingl, Neil Armstrong, Takashi Iwai
Cc: linux-arm-kernel, linux-sound
We can get card via priv->card, use priv for function param.
No functional change, but is preparation for Card capsuling.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/meson/axg-card.c | 63 ++++++++++++++++--------------
sound/soc/meson/gx-card.c | 23 +++++------
sound/soc/meson/meson-card-utils.c | 58 ++++++++++++++-------------
sound/soc/meson/meson-card.h | 11 +++---
4 files changed, 82 insertions(+), 73 deletions(-)
diff --git a/sound/soc/meson/axg-card.c b/sound/soc/meson/axg-card.c
index b4dca80e15e40..3d345dc33cb6f 100644
--- a/sound/soc/meson/axg-card.c
+++ b/sound/soc/meson/axg-card.c
@@ -100,28 +100,28 @@ static int axg_card_tdm_dai_lb_init(struct snd_soc_pcm_runtime *rtd)
return 0;
}
-static int axg_card_add_tdm_loopback(struct snd_soc_card *card,
+static int axg_card_add_tdm_loopback(struct meson_card *priv,
int *index)
{
- struct meson_card *priv = snd_soc_card_get_drvdata(card);
struct snd_soc_dai_link *pad;
struct snd_soc_dai_link *lb;
struct snd_soc_dai_link_component *dlc;
+ struct device *dev = priv->card.dev;
int ret;
/* extend links */
- ret = meson_card_reallocate_links(card, card->num_links + 1);
+ ret = meson_card_reallocate_links(priv, priv->card.num_links + 1);
if (ret)
return ret;
- pad = &card->dai_link[*index];
- lb = &card->dai_link[*index + 1];
+ pad = &priv->card.dai_link[*index];
+ lb = &priv->card.dai_link[*index + 1];
- lb->name = devm_kasprintf(card->dev, GFP_KERNEL, "%s-lb", pad->name);
+ lb->name = devm_kasprintf(dev, GFP_KERNEL, "%s-lb", pad->name);
if (!lb->name)
return -ENOMEM;
- dlc = devm_kzalloc(card->dev, sizeof(*dlc), GFP_KERNEL);
+ dlc = devm_kzalloc(dev, sizeof(*dlc), GFP_KERNEL);
if (!dlc)
return -ENOMEM;
@@ -153,18 +153,19 @@ static int axg_card_add_tdm_loopback(struct snd_soc_card *card,
return 0;
}
-static int axg_card_parse_cpu_tdm_slots(struct snd_soc_card *card,
+static int axg_card_parse_cpu_tdm_slots(struct meson_card *priv,
struct snd_soc_dai_link *link,
struct device_node *node,
struct axg_dai_link_tdm_data *be)
{
+ struct device *dev = priv->card.dev;
char propname[32];
u32 tx, rx;
int i;
- be->tx_mask = devm_kcalloc(card->dev, AXG_TDM_NUM_LANES,
+ be->tx_mask = devm_kcalloc(dev, AXG_TDM_NUM_LANES,
sizeof(*be->tx_mask), GFP_KERNEL);
- be->rx_mask = devm_kcalloc(card->dev, AXG_TDM_NUM_LANES,
+ be->rx_mask = devm_kcalloc(dev, AXG_TDM_NUM_LANES,
sizeof(*be->rx_mask), GFP_KERNEL);
if (!be->tx_mask || !be->rx_mask)
return -ENOMEM;
@@ -191,7 +192,7 @@ static int axg_card_parse_cpu_tdm_slots(struct snd_soc_card *card,
/* ... but the interface should at least have one direction */
if (!tx && !rx) {
- dev_err(card->dev, "tdm link has no cpu slots\n");
+ dev_err(dev, "tdm link has no cpu slots\n");
return -EINVAL;
}
@@ -207,7 +208,7 @@ static int axg_card_parse_cpu_tdm_slots(struct snd_soc_card *card,
* Error if the slots can't accommodate the largest mask or
* if it is just too big
*/
- dev_err(card->dev, "bad slot number\n");
+ dev_err(dev, "bad slot number\n");
return -EINVAL;
}
@@ -216,14 +217,15 @@ static int axg_card_parse_cpu_tdm_slots(struct snd_soc_card *card,
return 0;
}
-static int axg_card_parse_codecs_masks(struct snd_soc_card *card,
+static int axg_card_parse_codecs_masks(struct meson_card *priv,
struct snd_soc_dai_link *link,
struct device_node *node,
struct axg_dai_link_tdm_data *be)
{
struct axg_dai_link_tdm_mask *codec_mask;
+ struct device *dev = priv->card.dev;
- codec_mask = devm_kcalloc(card->dev, link->num_codecs,
+ codec_mask = devm_kcalloc(dev, link->num_codecs,
sizeof(*codec_mask), GFP_KERNEL);
if (!codec_mask)
return -ENOMEM;
@@ -242,17 +244,17 @@ static int axg_card_parse_codecs_masks(struct snd_soc_card *card,
return 0;
}
-static int axg_card_parse_tdm(struct snd_soc_card *card,
+static int axg_card_parse_tdm(struct meson_card *priv,
struct device_node *node,
int *index)
{
- struct meson_card *priv = snd_soc_card_get_drvdata(card);
- struct snd_soc_dai_link *link = &card->dai_link[*index];
+ struct snd_soc_dai_link *link = &priv->card.dai_link[*index];
struct axg_dai_link_tdm_data *be;
+ struct device *dev = priv->card.dev;
int ret;
/* Allocate tdm link parameters */
- be = devm_kzalloc(card->dev, sizeof(*be), GFP_KERNEL);
+ be = devm_kzalloc(dev, sizeof(*be), GFP_KERNEL);
if (!be)
return -ENOMEM;
priv->link_data[*index] = be;
@@ -264,19 +266,19 @@ static int axg_card_parse_tdm(struct snd_soc_card *card,
of_property_read_u32(node, "mclk-fs", &be->mclk_fs);
- ret = axg_card_parse_cpu_tdm_slots(card, link, node, be);
+ ret = axg_card_parse_cpu_tdm_slots(priv, link, node, be);
if (ret) {
- dev_err(card->dev, "error parsing tdm link slots\n");
+ dev_err(dev, "error parsing tdm link slots\n");
return ret;
}
- ret = axg_card_parse_codecs_masks(card, link, node, be);
+ ret = axg_card_parse_codecs_masks(priv, link, node, be);
if (ret)
return ret;
/* Add loopback if the pad dai has playback */
if (!link->capture_only) {
- ret = axg_card_add_tdm_loopback(card, index);
+ ret = axg_card_add_tdm_loopback(priv, index);
if (ret)
return ret;
}
@@ -305,14 +307,15 @@ static int axg_card_cpu_is_codec(struct device_node *np)
of_device_is_compatible(np, DT_PREFIX "g12a-toacodec");
}
-static int axg_card_add_link(struct snd_soc_card *card, struct device_node *np,
+static int axg_card_add_link(struct meson_card *priv, struct device_node *np,
int *index)
{
- struct snd_soc_dai_link *dai_link = &card->dai_link[*index];
+ struct snd_soc_dai_link *dai_link = &priv->card.dai_link[*index];
struct snd_soc_dai_link_component *cpu;
+ struct device *dev = priv->card.dev;
int ret;
- cpu = devm_kzalloc(card->dev, sizeof(*cpu), GFP_KERNEL);
+ cpu = devm_kzalloc(dev, sizeof(*cpu), GFP_KERNEL);
if (!cpu)
return -ENOMEM;
@@ -320,17 +323,17 @@ static int axg_card_add_link(struct snd_soc_card *card, struct device_node *np,
dai_link->num_cpus = 1;
dai_link->nonatomic = true;
- ret = meson_card_parse_dai(card, np, dai_link->cpus);
+ ret = meson_card_parse_dai(priv, np, dai_link->cpus);
if (ret)
return ret;
if (axg_card_cpu_is_playback_fe(dai_link->cpus->of_node))
- return meson_card_set_fe_link(card, dai_link, np, true);
+ return meson_card_set_fe_link(priv, dai_link, np, true);
else if (axg_card_cpu_is_capture_fe(dai_link->cpus->of_node))
- return meson_card_set_fe_link(card, dai_link, np, false);
+ return meson_card_set_fe_link(priv, dai_link, np, false);
- ret = meson_card_set_be_link(card, dai_link, np);
+ ret = meson_card_set_be_link(priv, dai_link, np);
if (ret)
return ret;
@@ -340,7 +343,7 @@ static int axg_card_add_link(struct snd_soc_card *card, struct device_node *np,
} else {
dai_link->no_pcm = 1;
if (axg_card_cpu_is_tdm_iface(dai_link->cpus->of_node))
- ret = axg_card_parse_tdm(card, np, index);
+ ret = axg_card_parse_tdm(priv, np, index);
}
return ret;
diff --git a/sound/soc/meson/gx-card.c b/sound/soc/meson/gx-card.c
index b408cc2bbc919..c0cbf31f28db5 100644
--- a/sound/soc/meson/gx-card.c
+++ b/sound/soc/meson/gx-card.c
@@ -41,16 +41,16 @@ static const struct snd_soc_ops gx_card_i2s_be_ops = {
.hw_params = gx_card_i2s_be_hw_params,
};
-static int gx_card_parse_i2s(struct snd_soc_card *card,
+static int gx_card_parse_i2s(struct meson_card *priv,
struct device_node *node,
int *index)
{
- struct meson_card *priv = snd_soc_card_get_drvdata(card);
- struct snd_soc_dai_link *link = &card->dai_link[*index];
+ struct snd_soc_dai_link *link = &priv->card.dai_link[*index];
struct gx_dai_link_i2s_data *be;
+ struct device *dev = priv->card.dev;
/* Allocate i2s link parameters */
- be = devm_kzalloc(card->dev, sizeof(*be), GFP_KERNEL);
+ be = devm_kzalloc(dev, sizeof(*be), GFP_KERNEL);
if (!be)
return -ENOMEM;
priv->link_data[*index] = be;
@@ -76,28 +76,29 @@ static int gx_card_cpu_identify(struct snd_soc_dai_link_component *c,
return 0;
}
-static int gx_card_add_link(struct snd_soc_card *card, struct device_node *np,
+static int gx_card_add_link(struct meson_card *priv, struct device_node *np,
int *index)
{
- struct snd_soc_dai_link *dai_link = &card->dai_link[*index];
+ struct snd_soc_dai_link *dai_link = &priv->card.dai_link[*index];
struct snd_soc_dai_link_component *cpu;
+ struct device *dev = priv->card.dev;
int ret;
- cpu = devm_kzalloc(card->dev, sizeof(*cpu), GFP_KERNEL);
+ cpu = devm_kzalloc(dev, sizeof(*cpu), GFP_KERNEL);
if (!cpu)
return -ENOMEM;
dai_link->cpus = cpu;
dai_link->num_cpus = 1;
- ret = meson_card_parse_dai(card, np, dai_link->cpus);
+ ret = meson_card_parse_dai(priv, np, dai_link->cpus);
if (ret)
return ret;
if (gx_card_cpu_identify(dai_link->cpus, "FIFO"))
- return meson_card_set_fe_link(card, dai_link, np, true);
+ return meson_card_set_fe_link(priv, dai_link, np, true);
- ret = meson_card_set_be_link(card, dai_link, np);
+ ret = meson_card_set_be_link(priv, dai_link, np);
if (ret)
return ret;
@@ -109,7 +110,7 @@ static int gx_card_add_link(struct snd_soc_card *card, struct device_node *np,
dai_link->no_pcm = 1;
/* Check if the cpu is the i2s encoder and parse i2s data */
if (gx_card_cpu_identify(dai_link->cpus, "I2S Encoder"))
- ret = gx_card_parse_i2s(card, np, index);
+ ret = gx_card_parse_i2s(priv, np, index);
}
return ret;
diff --git a/sound/soc/meson/meson-card-utils.c b/sound/soc/meson/meson-card-utils.c
index d144ab79b645b..7329711aefa56 100644
--- a/sound/soc/meson/meson-card-utils.c
+++ b/sound/soc/meson/meson-card-utils.c
@@ -39,10 +39,9 @@ int meson_card_i2s_set_sysclk(struct snd_pcm_substream *substream,
}
EXPORT_SYMBOL_GPL(meson_card_i2s_set_sysclk);
-int meson_card_reallocate_links(struct snd_soc_card *card,
+int meson_card_reallocate_links(struct meson_card *priv,
unsigned int num_links)
{
- struct meson_card *priv = snd_soc_card_get_drvdata(card);
struct snd_soc_dai_link *links;
void **ldata;
@@ -67,10 +66,11 @@ int meson_card_reallocate_links(struct snd_soc_card *card,
}
EXPORT_SYMBOL_GPL(meson_card_reallocate_links);
-int meson_card_parse_dai(struct snd_soc_card *card,
+int meson_card_parse_dai(struct meson_card *priv,
struct device_node *node,
struct snd_soc_dai_link_component *dlc)
{
+ struct device *dev = priv->card.dev;
int ret;
if (!dlc || !node)
@@ -78,18 +78,19 @@ int meson_card_parse_dai(struct snd_soc_card *card,
ret = snd_soc_of_get_dlc(node, NULL, dlc, 0);
if (ret)
- return dev_err_probe(card->dev, ret, "can't parse dai\n");
+ return dev_err_probe(dev, ret, "can't parse dai\n");
return ret;
}
EXPORT_SYMBOL_GPL(meson_card_parse_dai);
-static int meson_card_set_link_name(struct snd_soc_card *card,
+static int meson_card_set_link_name(struct meson_card *priv,
struct snd_soc_dai_link *link,
struct device_node *node,
const char *prefix)
{
- char *name = devm_kasprintf(card->dev, GFP_KERNEL, "%s.%s",
+ struct device *dev = priv->card.dev;
+ char *name = devm_kasprintf(dev, GFP_KERNEL, "%s.%s",
prefix, node->full_name);
if (!name)
return -ENOMEM;
@@ -127,21 +128,22 @@ unsigned int meson_card_parse_daifmt(struct device_node *node,
}
EXPORT_SYMBOL_GPL(meson_card_parse_daifmt);
-int meson_card_set_be_link(struct snd_soc_card *card,
+int meson_card_set_be_link(struct meson_card *priv,
struct snd_soc_dai_link *link,
struct device_node *node)
{
struct snd_soc_dai_link_component *codec;
+ struct device *dev = priv->card.dev;
int ret, num_codecs;
num_codecs = of_get_child_count(node);
if (!num_codecs) {
- dev_err(card->dev, "be link %s has no codec\n",
+ dev_err(dev, "be link %s has no codec\n",
node->full_name);
return -EINVAL;
}
- codec = devm_kcalloc(card->dev, num_codecs, sizeof(*codec), GFP_KERNEL);
+ codec = devm_kcalloc(dev, num_codecs, sizeof(*codec), GFP_KERNEL);
if (!codec)
return -ENOMEM;
@@ -149,22 +151,22 @@ int meson_card_set_be_link(struct snd_soc_card *card,
link->num_codecs = num_codecs;
for_each_child_of_node_scoped(node, np) {
- ret = meson_card_parse_dai(card, np, codec);
+ ret = meson_card_parse_dai(priv, np, codec);
if (ret)
return ret;
codec++;
}
- ret = meson_card_set_link_name(card, link, node, "be");
+ ret = meson_card_set_link_name(priv, link, node, "be");
if (ret)
- dev_err(card->dev, "error setting %pOFn link name\n", node);
+ dev_err(dev, "error setting %pOFn link name\n", node);
return ret;
}
EXPORT_SYMBOL_GPL(meson_card_set_be_link);
-int meson_card_set_fe_link(struct snd_soc_card *card,
+int meson_card_set_fe_link(struct meson_card *priv,
struct snd_soc_dai_link *link,
struct device_node *node,
bool is_playback)
@@ -182,29 +184,29 @@ int meson_card_set_fe_link(struct snd_soc_card *card,
else
link->capture_only = 1;
- return meson_card_set_link_name(card, link, node, "fe");
+ return meson_card_set_link_name(priv, link, node, "fe");
}
EXPORT_SYMBOL_GPL(meson_card_set_fe_link);
-static int meson_card_add_links(struct snd_soc_card *card)
+static int meson_card_add_links(struct meson_card *priv)
{
- struct meson_card *priv = snd_soc_card_get_drvdata(card);
- struct device_node *node = card->dev->of_node;
+ struct device *dev = priv->card.dev;
+ struct device_node *node = dev->of_node;
int num, i, ret;
num = of_get_child_count(node);
if (!num) {
- dev_err(card->dev, "card has no links\n");
+ dev_err(dev, "card has no links\n");
return -EINVAL;
}
- ret = meson_card_reallocate_links(card, num);
+ ret = meson_card_reallocate_links(priv, num);
if (ret)
return ret;
i = 0;
for_each_child_of_node_scoped(node, np) {
- ret = priv->match_data->add_link(card, np, &i);
+ ret = priv->match_data->add_link(priv, np, &i);
if (ret)
return ret;
@@ -214,17 +216,19 @@ static int meson_card_add_links(struct snd_soc_card *card)
return 0;
}
-static int meson_card_parse_of_optional(struct snd_soc_card *card,
+static int meson_card_parse_of_optional(struct meson_card *priv,
const char *propname,
int (*func)(struct snd_soc_card *c,
const char *p))
{
+ struct device *dev = priv->card.dev;
+
/* If property is not provided, don't fail ... */
- if (!of_property_present(card->dev->of_node, propname))
+ if (!of_property_present(dev->of_node, propname))
return 0;
/* ... but do fail if it is provided and the parsing fails */
- return func(card, propname);
+ return func(&priv->card, propname);
}
static void meson_card_clean_references(struct meson_card *priv)
@@ -282,25 +286,25 @@ int meson_card_probe(struct platform_device *pdev)
if (ret < 0)
return ret;
- ret = meson_card_parse_of_optional(&priv->card, "audio-routing",
+ ret = meson_card_parse_of_optional(priv, "audio-routing",
snd_soc_of_parse_audio_routing);
if (ret) {
dev_err(dev, "error while parsing routing\n");
return ret;
}
- ret = meson_card_parse_of_optional(&priv->card, "audio-widgets",
+ ret = meson_card_parse_of_optional(priv, "audio-widgets",
snd_soc_of_parse_audio_simple_widgets);
if (ret) {
dev_err(dev, "error while parsing widgets\n");
return ret;
}
- ret = meson_card_add_links(&priv->card);
+ ret = meson_card_add_links(priv);
if (ret)
goto out_err;
- ret = meson_card_parse_of_optional(&priv->card, "audio-aux-devs",
+ ret = meson_card_parse_of_optional(priv, "audio-aux-devs",
snd_soc_of_parse_aux_devs);
if (ret)
goto out_err;
diff --git a/sound/soc/meson/meson-card.h b/sound/soc/meson/meson-card.h
index a0d693e4f4608..ce8d9042793bb 100644
--- a/sound/soc/meson/meson-card.h
+++ b/sound/soc/meson/meson-card.h
@@ -16,8 +16,9 @@ struct snd_pcm_hw_params;
#define DT_PREFIX "amlogic,"
+struct meson_card;
struct meson_card_match_data {
- int (*add_link)(struct snd_soc_card *card,
+ int (*add_link)(struct meson_card *priv,
struct device_node *node,
int *index);
};
@@ -35,15 +36,15 @@ int meson_card_i2s_set_sysclk(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
unsigned int mclk_fs);
-int meson_card_reallocate_links(struct snd_soc_card *card,
+int meson_card_reallocate_links(struct meson_card *priv,
unsigned int num_links);
-int meson_card_parse_dai(struct snd_soc_card *card,
+int meson_card_parse_dai(struct meson_card *priv,
struct device_node *node,
struct snd_soc_dai_link_component *dlc);
-int meson_card_set_be_link(struct snd_soc_card *card,
+int meson_card_set_be_link(struct meson_card *priv,
struct snd_soc_dai_link *link,
struct device_node *node);
-int meson_card_set_fe_link(struct snd_soc_card *card,
+int meson_card_set_fe_link(struct meson_card *priv,
struct snd_soc_dai_link *link,
struct device_node *node,
bool is_playback);
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH RFC 1/2] ASoC: meson: meson-card-utils: use meson_card_parse_of_optional()
2026-07-21 1:36 ` [PATCH RFC 1/2] ASoC: meson: meson-card-utils: use meson_card_parse_of_optional() Kuninori Morimoto
@ 2026-07-21 7:32 ` Jerome Brunet
0 siblings, 0 replies; 8+ messages in thread
From: Jerome Brunet @ 2026-07-21 7:32 UTC (permalink / raw)
To: Kuninori Morimoto
Cc: Jaroslav Kysela, Kevin Hilman, Liam Girdwood, Mark Brown,
Martin Blumenstingl, Neil Armstrong, Takashi Iwai,
linux-arm-kernel, linux-sound
On mar. 21 juil. 2026 at 01:36, Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> wrote:
> We already have meson_card_parse_of_optional(). Let's use it for
> snd_soc_of_parse_aux_devs() too.
>
> It is using snd_soc_of_parse_card_name(), but let's keep as-is
> for it for now. Beuase it will be not able to share code when
> Card capsuling.
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> sound/soc/meson/meson-card-utils.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/sound/soc/meson/meson-card-utils.c b/sound/soc/meson/meson-card-utils.c
> index 8617a4661a339..d144ab79b645b 100644
> --- a/sound/soc/meson/meson-card-utils.c
> +++ b/sound/soc/meson/meson-card-utils.c
> @@ -300,7 +300,8 @@ int meson_card_probe(struct platform_device *pdev)
> if (ret)
> goto out_err;
>
> - ret = snd_soc_of_parse_aux_devs(&priv->card, "audio-aux-devs");
> + ret = meson_card_parse_of_optional(&priv->card, "audio-aux-devs",
> + snd_soc_of_parse_aux_devs);
snd_soc_of_parse_aux_devs already properly handle if the property is not
present. I'm not a fan of adding another level of function if it does
not bring anything valuable to the mix.
Could you add more context describing what you trying to accomplish with
this "card capsuling" thing ? A link to the RFC maybe ?
> if (ret)
> goto out_err;
--
Jerome
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] ASoC: meson: meson-card: use priv instead of card on each functions
2026-07-21 1:36 ` [PATCH 2/2] ASoC: meson: meson-card: use priv instead of card on each functions Kuninori Morimoto
@ 2026-07-21 7:35 ` Jerome Brunet
2026-07-21 23:22 ` Kuninori Morimoto
0 siblings, 1 reply; 8+ messages in thread
From: Jerome Brunet @ 2026-07-21 7:35 UTC (permalink / raw)
To: Kuninori Morimoto
Cc: Jaroslav Kysela, Kevin Hilman, Liam Girdwood, Mark Brown,
Martin Blumenstingl, Neil Armstrong, Takashi Iwai,
linux-arm-kernel, linux-sound
On mar. 21 juil. 2026 at 01:36, Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> wrote:
> We can get card via priv->card, use priv for function param.
> No functional change, but is preparation for Card capsuling.
The change is simple but it will make more complex to backport fix an
older kernel once this fix is applied. So again, getting more context to
understand what you are trying to accomplish and why it needs a standard
card variable name would help.
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> sound/soc/meson/axg-card.c | 63 ++++++++++++++++--------------
> sound/soc/meson/gx-card.c | 23 +++++------
> sound/soc/meson/meson-card-utils.c | 58 ++++++++++++++-------------
> sound/soc/meson/meson-card.h | 11 +++---
> 4 files changed, 82 insertions(+), 73 deletions(-)
>
> diff --git a/sound/soc/meson/axg-card.c b/sound/soc/meson/axg-card.c
> index b4dca80e15e40..3d345dc33cb6f 100644
> --- a/sound/soc/meson/axg-card.c
> +++ b/sound/soc/meson/axg-card.c
> @@ -100,28 +100,28 @@ static int axg_card_tdm_dai_lb_init(struct snd_soc_pcm_runtime *rtd)
> return 0;
> }
>
> -static int axg_card_add_tdm_loopback(struct snd_soc_card *card,
> +static int axg_card_add_tdm_loopback(struct meson_card *priv,
> int *index)
> {
> - struct meson_card *priv = snd_soc_card_get_drvdata(card);
> struct snd_soc_dai_link *pad;
> struct snd_soc_dai_link *lb;
> struct snd_soc_dai_link_component *dlc;
> + struct device *dev = priv->card.dev;
> int ret;
>
> /* extend links */
> - ret = meson_card_reallocate_links(card, card->num_links + 1);
> + ret = meson_card_reallocate_links(priv, priv->card.num_links + 1);
> if (ret)
> return ret;
>
> - pad = &card->dai_link[*index];
> - lb = &card->dai_link[*index + 1];
> + pad = &priv->card.dai_link[*index];
> + lb = &priv->card.dai_link[*index + 1];
>
> - lb->name = devm_kasprintf(card->dev, GFP_KERNEL, "%s-lb", pad->name);
> + lb->name = devm_kasprintf(dev, GFP_KERNEL, "%s-lb", pad->name);
> if (!lb->name)
> return -ENOMEM;
>
> - dlc = devm_kzalloc(card->dev, sizeof(*dlc), GFP_KERNEL);
> + dlc = devm_kzalloc(dev, sizeof(*dlc), GFP_KERNEL);
> if (!dlc)
> return -ENOMEM;
>
> @@ -153,18 +153,19 @@ static int axg_card_add_tdm_loopback(struct snd_soc_card *card,
> return 0;
> }
>
> -static int axg_card_parse_cpu_tdm_slots(struct snd_soc_card *card,
> +static int axg_card_parse_cpu_tdm_slots(struct meson_card *priv,
> struct snd_soc_dai_link *link,
> struct device_node *node,
> struct axg_dai_link_tdm_data *be)
> {
> + struct device *dev = priv->card.dev;
> char propname[32];
> u32 tx, rx;
> int i;
>
> - be->tx_mask = devm_kcalloc(card->dev, AXG_TDM_NUM_LANES,
> + be->tx_mask = devm_kcalloc(dev, AXG_TDM_NUM_LANES,
> sizeof(*be->tx_mask), GFP_KERNEL);
> - be->rx_mask = devm_kcalloc(card->dev, AXG_TDM_NUM_LANES,
> + be->rx_mask = devm_kcalloc(dev, AXG_TDM_NUM_LANES,
> sizeof(*be->rx_mask), GFP_KERNEL);
> if (!be->tx_mask || !be->rx_mask)
> return -ENOMEM;
> @@ -191,7 +192,7 @@ static int axg_card_parse_cpu_tdm_slots(struct snd_soc_card *card,
>
> /* ... but the interface should at least have one direction */
> if (!tx && !rx) {
> - dev_err(card->dev, "tdm link has no cpu slots\n");
> + dev_err(dev, "tdm link has no cpu slots\n");
> return -EINVAL;
> }
>
> @@ -207,7 +208,7 @@ static int axg_card_parse_cpu_tdm_slots(struct snd_soc_card *card,
> * Error if the slots can't accommodate the largest mask or
> * if it is just too big
> */
> - dev_err(card->dev, "bad slot number\n");
> + dev_err(dev, "bad slot number\n");
> return -EINVAL;
> }
>
> @@ -216,14 +217,15 @@ static int axg_card_parse_cpu_tdm_slots(struct snd_soc_card *card,
> return 0;
> }
>
> -static int axg_card_parse_codecs_masks(struct snd_soc_card *card,
> +static int axg_card_parse_codecs_masks(struct meson_card *priv,
> struct snd_soc_dai_link *link,
> struct device_node *node,
> struct axg_dai_link_tdm_data *be)
> {
> struct axg_dai_link_tdm_mask *codec_mask;
> + struct device *dev = priv->card.dev;
>
> - codec_mask = devm_kcalloc(card->dev, link->num_codecs,
> + codec_mask = devm_kcalloc(dev, link->num_codecs,
> sizeof(*codec_mask), GFP_KERNEL);
> if (!codec_mask)
> return -ENOMEM;
> @@ -242,17 +244,17 @@ static int axg_card_parse_codecs_masks(struct snd_soc_card *card,
> return 0;
> }
>
> -static int axg_card_parse_tdm(struct snd_soc_card *card,
> +static int axg_card_parse_tdm(struct meson_card *priv,
> struct device_node *node,
> int *index)
> {
> - struct meson_card *priv = snd_soc_card_get_drvdata(card);
> - struct snd_soc_dai_link *link = &card->dai_link[*index];
> + struct snd_soc_dai_link *link = &priv->card.dai_link[*index];
> struct axg_dai_link_tdm_data *be;
> + struct device *dev = priv->card.dev;
> int ret;
>
> /* Allocate tdm link parameters */
> - be = devm_kzalloc(card->dev, sizeof(*be), GFP_KERNEL);
> + be = devm_kzalloc(dev, sizeof(*be), GFP_KERNEL);
> if (!be)
> return -ENOMEM;
> priv->link_data[*index] = be;
> @@ -264,19 +266,19 @@ static int axg_card_parse_tdm(struct snd_soc_card *card,
>
> of_property_read_u32(node, "mclk-fs", &be->mclk_fs);
>
> - ret = axg_card_parse_cpu_tdm_slots(card, link, node, be);
> + ret = axg_card_parse_cpu_tdm_slots(priv, link, node, be);
> if (ret) {
> - dev_err(card->dev, "error parsing tdm link slots\n");
> + dev_err(dev, "error parsing tdm link slots\n");
> return ret;
> }
>
> - ret = axg_card_parse_codecs_masks(card, link, node, be);
> + ret = axg_card_parse_codecs_masks(priv, link, node, be);
> if (ret)
> return ret;
>
> /* Add loopback if the pad dai has playback */
> if (!link->capture_only) {
> - ret = axg_card_add_tdm_loopback(card, index);
> + ret = axg_card_add_tdm_loopback(priv, index);
> if (ret)
> return ret;
> }
> @@ -305,14 +307,15 @@ static int axg_card_cpu_is_codec(struct device_node *np)
> of_device_is_compatible(np, DT_PREFIX "g12a-toacodec");
> }
>
> -static int axg_card_add_link(struct snd_soc_card *card, struct device_node *np,
> +static int axg_card_add_link(struct meson_card *priv, struct device_node *np,
> int *index)
> {
> - struct snd_soc_dai_link *dai_link = &card->dai_link[*index];
> + struct snd_soc_dai_link *dai_link = &priv->card.dai_link[*index];
> struct snd_soc_dai_link_component *cpu;
> + struct device *dev = priv->card.dev;
> int ret;
>
> - cpu = devm_kzalloc(card->dev, sizeof(*cpu), GFP_KERNEL);
> + cpu = devm_kzalloc(dev, sizeof(*cpu), GFP_KERNEL);
> if (!cpu)
> return -ENOMEM;
>
> @@ -320,17 +323,17 @@ static int axg_card_add_link(struct snd_soc_card *card, struct device_node *np,
> dai_link->num_cpus = 1;
> dai_link->nonatomic = true;
>
> - ret = meson_card_parse_dai(card, np, dai_link->cpus);
> + ret = meson_card_parse_dai(priv, np, dai_link->cpus);
> if (ret)
> return ret;
>
> if (axg_card_cpu_is_playback_fe(dai_link->cpus->of_node))
> - return meson_card_set_fe_link(card, dai_link, np, true);
> + return meson_card_set_fe_link(priv, dai_link, np, true);
> else if (axg_card_cpu_is_capture_fe(dai_link->cpus->of_node))
> - return meson_card_set_fe_link(card, dai_link, np, false);
> + return meson_card_set_fe_link(priv, dai_link, np, false);
>
>
> - ret = meson_card_set_be_link(card, dai_link, np);
> + ret = meson_card_set_be_link(priv, dai_link, np);
> if (ret)
> return ret;
>
> @@ -340,7 +343,7 @@ static int axg_card_add_link(struct snd_soc_card *card, struct device_node *np,
> } else {
> dai_link->no_pcm = 1;
> if (axg_card_cpu_is_tdm_iface(dai_link->cpus->of_node))
> - ret = axg_card_parse_tdm(card, np, index);
> + ret = axg_card_parse_tdm(priv, np, index);
> }
>
> return ret;
> diff --git a/sound/soc/meson/gx-card.c b/sound/soc/meson/gx-card.c
> index b408cc2bbc919..c0cbf31f28db5 100644
> --- a/sound/soc/meson/gx-card.c
> +++ b/sound/soc/meson/gx-card.c
> @@ -41,16 +41,16 @@ static const struct snd_soc_ops gx_card_i2s_be_ops = {
> .hw_params = gx_card_i2s_be_hw_params,
> };
>
> -static int gx_card_parse_i2s(struct snd_soc_card *card,
> +static int gx_card_parse_i2s(struct meson_card *priv,
> struct device_node *node,
> int *index)
> {
> - struct meson_card *priv = snd_soc_card_get_drvdata(card);
> - struct snd_soc_dai_link *link = &card->dai_link[*index];
> + struct snd_soc_dai_link *link = &priv->card.dai_link[*index];
> struct gx_dai_link_i2s_data *be;
> + struct device *dev = priv->card.dev;
>
> /* Allocate i2s link parameters */
> - be = devm_kzalloc(card->dev, sizeof(*be), GFP_KERNEL);
> + be = devm_kzalloc(dev, sizeof(*be), GFP_KERNEL);
> if (!be)
> return -ENOMEM;
> priv->link_data[*index] = be;
> @@ -76,28 +76,29 @@ static int gx_card_cpu_identify(struct snd_soc_dai_link_component *c,
> return 0;
> }
>
> -static int gx_card_add_link(struct snd_soc_card *card, struct device_node *np,
> +static int gx_card_add_link(struct meson_card *priv, struct device_node *np,
> int *index)
> {
> - struct snd_soc_dai_link *dai_link = &card->dai_link[*index];
> + struct snd_soc_dai_link *dai_link = &priv->card.dai_link[*index];
> struct snd_soc_dai_link_component *cpu;
> + struct device *dev = priv->card.dev;
> int ret;
>
> - cpu = devm_kzalloc(card->dev, sizeof(*cpu), GFP_KERNEL);
> + cpu = devm_kzalloc(dev, sizeof(*cpu), GFP_KERNEL);
> if (!cpu)
> return -ENOMEM;
>
> dai_link->cpus = cpu;
> dai_link->num_cpus = 1;
>
> - ret = meson_card_parse_dai(card, np, dai_link->cpus);
> + ret = meson_card_parse_dai(priv, np, dai_link->cpus);
> if (ret)
> return ret;
>
> if (gx_card_cpu_identify(dai_link->cpus, "FIFO"))
> - return meson_card_set_fe_link(card, dai_link, np, true);
> + return meson_card_set_fe_link(priv, dai_link, np, true);
>
> - ret = meson_card_set_be_link(card, dai_link, np);
> + ret = meson_card_set_be_link(priv, dai_link, np);
> if (ret)
> return ret;
>
> @@ -109,7 +110,7 @@ static int gx_card_add_link(struct snd_soc_card *card, struct device_node *np,
> dai_link->no_pcm = 1;
> /* Check if the cpu is the i2s encoder and parse i2s data */
> if (gx_card_cpu_identify(dai_link->cpus, "I2S Encoder"))
> - ret = gx_card_parse_i2s(card, np, index);
> + ret = gx_card_parse_i2s(priv, np, index);
> }
>
> return ret;
> diff --git a/sound/soc/meson/meson-card-utils.c b/sound/soc/meson/meson-card-utils.c
> index d144ab79b645b..7329711aefa56 100644
> --- a/sound/soc/meson/meson-card-utils.c
> +++ b/sound/soc/meson/meson-card-utils.c
> @@ -39,10 +39,9 @@ int meson_card_i2s_set_sysclk(struct snd_pcm_substream *substream,
> }
> EXPORT_SYMBOL_GPL(meson_card_i2s_set_sysclk);
>
> -int meson_card_reallocate_links(struct snd_soc_card *card,
> +int meson_card_reallocate_links(struct meson_card *priv,
> unsigned int num_links)
> {
> - struct meson_card *priv = snd_soc_card_get_drvdata(card);
> struct snd_soc_dai_link *links;
> void **ldata;
>
> @@ -67,10 +66,11 @@ int meson_card_reallocate_links(struct snd_soc_card *card,
> }
> EXPORT_SYMBOL_GPL(meson_card_reallocate_links);
>
> -int meson_card_parse_dai(struct snd_soc_card *card,
> +int meson_card_parse_dai(struct meson_card *priv,
> struct device_node *node,
> struct snd_soc_dai_link_component *dlc)
> {
> + struct device *dev = priv->card.dev;
> int ret;
>
> if (!dlc || !node)
> @@ -78,18 +78,19 @@ int meson_card_parse_dai(struct snd_soc_card *card,
>
> ret = snd_soc_of_get_dlc(node, NULL, dlc, 0);
> if (ret)
> - return dev_err_probe(card->dev, ret, "can't parse dai\n");
> + return dev_err_probe(dev, ret, "can't parse dai\n");
>
> return ret;
> }
> EXPORT_SYMBOL_GPL(meson_card_parse_dai);
>
> -static int meson_card_set_link_name(struct snd_soc_card *card,
> +static int meson_card_set_link_name(struct meson_card *priv,
> struct snd_soc_dai_link *link,
> struct device_node *node,
> const char *prefix)
> {
> - char *name = devm_kasprintf(card->dev, GFP_KERNEL, "%s.%s",
> + struct device *dev = priv->card.dev;
> + char *name = devm_kasprintf(dev, GFP_KERNEL, "%s.%s",
> prefix, node->full_name);
> if (!name)
> return -ENOMEM;
> @@ -127,21 +128,22 @@ unsigned int meson_card_parse_daifmt(struct device_node *node,
> }
> EXPORT_SYMBOL_GPL(meson_card_parse_daifmt);
>
> -int meson_card_set_be_link(struct snd_soc_card *card,
> +int meson_card_set_be_link(struct meson_card *priv,
> struct snd_soc_dai_link *link,
> struct device_node *node)
> {
> struct snd_soc_dai_link_component *codec;
> + struct device *dev = priv->card.dev;
> int ret, num_codecs;
>
> num_codecs = of_get_child_count(node);
> if (!num_codecs) {
> - dev_err(card->dev, "be link %s has no codec\n",
> + dev_err(dev, "be link %s has no codec\n",
> node->full_name);
> return -EINVAL;
> }
>
> - codec = devm_kcalloc(card->dev, num_codecs, sizeof(*codec), GFP_KERNEL);
> + codec = devm_kcalloc(dev, num_codecs, sizeof(*codec), GFP_KERNEL);
> if (!codec)
> return -ENOMEM;
>
> @@ -149,22 +151,22 @@ int meson_card_set_be_link(struct snd_soc_card *card,
> link->num_codecs = num_codecs;
>
> for_each_child_of_node_scoped(node, np) {
> - ret = meson_card_parse_dai(card, np, codec);
> + ret = meson_card_parse_dai(priv, np, codec);
> if (ret)
> return ret;
>
> codec++;
> }
>
> - ret = meson_card_set_link_name(card, link, node, "be");
> + ret = meson_card_set_link_name(priv, link, node, "be");
> if (ret)
> - dev_err(card->dev, "error setting %pOFn link name\n", node);
> + dev_err(dev, "error setting %pOFn link name\n", node);
>
> return ret;
> }
> EXPORT_SYMBOL_GPL(meson_card_set_be_link);
>
> -int meson_card_set_fe_link(struct snd_soc_card *card,
> +int meson_card_set_fe_link(struct meson_card *priv,
> struct snd_soc_dai_link *link,
> struct device_node *node,
> bool is_playback)
> @@ -182,29 +184,29 @@ int meson_card_set_fe_link(struct snd_soc_card *card,
> else
> link->capture_only = 1;
>
> - return meson_card_set_link_name(card, link, node, "fe");
> + return meson_card_set_link_name(priv, link, node, "fe");
> }
> EXPORT_SYMBOL_GPL(meson_card_set_fe_link);
>
> -static int meson_card_add_links(struct snd_soc_card *card)
> +static int meson_card_add_links(struct meson_card *priv)
> {
> - struct meson_card *priv = snd_soc_card_get_drvdata(card);
> - struct device_node *node = card->dev->of_node;
> + struct device *dev = priv->card.dev;
> + struct device_node *node = dev->of_node;
> int num, i, ret;
>
> num = of_get_child_count(node);
> if (!num) {
> - dev_err(card->dev, "card has no links\n");
> + dev_err(dev, "card has no links\n");
> return -EINVAL;
> }
>
> - ret = meson_card_reallocate_links(card, num);
> + ret = meson_card_reallocate_links(priv, num);
> if (ret)
> return ret;
>
> i = 0;
> for_each_child_of_node_scoped(node, np) {
> - ret = priv->match_data->add_link(card, np, &i);
> + ret = priv->match_data->add_link(priv, np, &i);
> if (ret)
> return ret;
>
> @@ -214,17 +216,19 @@ static int meson_card_add_links(struct snd_soc_card *card)
> return 0;
> }
>
> -static int meson_card_parse_of_optional(struct snd_soc_card *card,
> +static int meson_card_parse_of_optional(struct meson_card *priv,
> const char *propname,
> int (*func)(struct snd_soc_card *c,
> const char *p))
> {
> + struct device *dev = priv->card.dev;
> +
> /* If property is not provided, don't fail ... */
> - if (!of_property_present(card->dev->of_node, propname))
> + if (!of_property_present(dev->of_node, propname))
> return 0;
>
> /* ... but do fail if it is provided and the parsing fails */
> - return func(card, propname);
> + return func(&priv->card, propname);
> }
>
> static void meson_card_clean_references(struct meson_card *priv)
> @@ -282,25 +286,25 @@ int meson_card_probe(struct platform_device *pdev)
> if (ret < 0)
> return ret;
>
> - ret = meson_card_parse_of_optional(&priv->card, "audio-routing",
> + ret = meson_card_parse_of_optional(priv, "audio-routing",
> snd_soc_of_parse_audio_routing);
> if (ret) {
> dev_err(dev, "error while parsing routing\n");
> return ret;
> }
>
> - ret = meson_card_parse_of_optional(&priv->card, "audio-widgets",
> + ret = meson_card_parse_of_optional(priv, "audio-widgets",
> snd_soc_of_parse_audio_simple_widgets);
> if (ret) {
> dev_err(dev, "error while parsing widgets\n");
> return ret;
> }
>
> - ret = meson_card_add_links(&priv->card);
> + ret = meson_card_add_links(priv);
> if (ret)
> goto out_err;
>
> - ret = meson_card_parse_of_optional(&priv->card, "audio-aux-devs",
> + ret = meson_card_parse_of_optional(priv, "audio-aux-devs",
> snd_soc_of_parse_aux_devs);
> if (ret)
> goto out_err;
> diff --git a/sound/soc/meson/meson-card.h b/sound/soc/meson/meson-card.h
> index a0d693e4f4608..ce8d9042793bb 100644
> --- a/sound/soc/meson/meson-card.h
> +++ b/sound/soc/meson/meson-card.h
> @@ -16,8 +16,9 @@ struct snd_pcm_hw_params;
>
> #define DT_PREFIX "amlogic,"
>
> +struct meson_card;
> struct meson_card_match_data {
> - int (*add_link)(struct snd_soc_card *card,
> + int (*add_link)(struct meson_card *priv,
> struct device_node *node,
> int *index);
> };
> @@ -35,15 +36,15 @@ int meson_card_i2s_set_sysclk(struct snd_pcm_substream *substream,
> struct snd_pcm_hw_params *params,
> unsigned int mclk_fs);
>
> -int meson_card_reallocate_links(struct snd_soc_card *card,
> +int meson_card_reallocate_links(struct meson_card *priv,
> unsigned int num_links);
> -int meson_card_parse_dai(struct snd_soc_card *card,
> +int meson_card_parse_dai(struct meson_card *priv,
> struct device_node *node,
> struct snd_soc_dai_link_component *dlc);
> -int meson_card_set_be_link(struct snd_soc_card *card,
> +int meson_card_set_be_link(struct meson_card *priv,
> struct snd_soc_dai_link *link,
> struct device_node *node);
> -int meson_card_set_fe_link(struct snd_soc_card *card,
> +int meson_card_set_fe_link(struct meson_card *priv,
> struct snd_soc_dai_link *link,
> struct device_node *node,
> bool is_playback);
--
Jerome
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] ASoC: meson: meson-card: use priv instead of card on each functions
2026-07-21 7:35 ` Jerome Brunet
@ 2026-07-21 23:22 ` Kuninori Morimoto
2026-07-22 0:35 ` Kuninori Morimoto
0 siblings, 1 reply; 8+ messages in thread
From: Kuninori Morimoto @ 2026-07-21 23:22 UTC (permalink / raw)
To: Jerome Brunet
Cc: Jaroslav Kysela, Kevin Hilman, Liam Girdwood, Mark Brown,
Martin Blumenstingl, Neil Armstrong, Takashi Iwai,
linux-arm-kernel, linux-sound
Hi Jerome
Thank you for your review
> > We can get card via priv->card, use priv for function param.
> > No functional change, but is preparation for Card capsuling.
>
> The change is simple but it will make more complex to backport fix an
> older kernel once this fix is applied. So again, getting more context to
> understand what you are trying to accomplish and why it needs a standard
> card variable name would help.
Basically, after "Card capsuling" has done, we can't directly use card->xxx
anymore. So we need to update all of such code.
I would like to update such code as much as possible in advance.
Otherwise, "Card capsuling" patch itself will be more complex and difficult
to review.
But looking at the code again, indeed it is some rather exaggerated changes.
I think v2 can be more simple.
About [1/2], I have noticed that there is meson_card_parse_of_optional(),
but snd_soc_card_driver_of_parse_aux_devs() case didn't use it.
I wondered if it was a mistake not to use it, even though it was the same
pattern. Not a big-deal. If it is intentional, there is no problem.
Thank you for your help !!
Best regards
---
Kuninori Morimoto
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] ASoC: meson: meson-card: use priv instead of card on each functions
2026-07-21 23:22 ` Kuninori Morimoto
@ 2026-07-22 0:35 ` Kuninori Morimoto
2026-07-22 7:40 ` Jerome Brunet
0 siblings, 1 reply; 8+ messages in thread
From: Kuninori Morimoto @ 2026-07-22 0:35 UTC (permalink / raw)
To: Jerome Brunet
Cc: Jaroslav Kysela, Kevin Hilman, Liam Girdwood, Mark Brown,
Martin Blumenstingl, Neil Armstrong, Takashi Iwai,
linux-arm-kernel, linux-sound
Hi Jerome, again
I now double checked.
> > The change is simple but it will make more complex to backport fix an
> > older kernel once this fix is applied. So again, getting more context to
> > understand what you are trying to accomplish and why it needs a standard
> > card variable name would help.
>
> Basically, after "Card capsuling" has done, we can't directly use card->xxx
> anymore. So we need to update all of such code.
> I would like to update such code as much as possible in advance.
> Otherwise, "Card capsuling" patch itself will be more complex and difficult
> to review.
Current functions get "card" as parameter to get "dev".
func(card, ...)
{
struct device *dev = card->dev;
...
}
After "Card capsuling", we will use "card_driver" instead.
But switching "card" to "card_driver" only is not enough, on Meson case,
because "card_driver" don't have "dev".
On Meson case, it don't need to keep "card" in priv anymore after
"Card capsuling". So I would like to add "dev" in priv instead, and remove
"card", like this.
struct meson_card {
...
- struct snd_soc_card card;
+ struct snd_soc_card_driver card_driver;
+ struct device *dev;
...
};
Then, we can get both "card_driver" and "dev" from "priv".
If we can switch to use "priv" instead of "card" *now*, the diff will be
more small when "Card capsuling", because the patch will have
"Card capsuling diff" (A) + "switch card to priv" (B).
This diff of (B) part is doing very simple things, but is big volume,
because it is sharing the code on Meson.
- func(card, ...)
+ func(priv, ...)
{
- struct device *dev = card->dev;
+ struct device *dev = priv->dev;
+ struct snd_soc_card_driver *card_driver = priv->card_driver;
...
- snd_soc_card_xxx(card, ...);
+ snd_soc_card_xxx(card_driver, ...);
...
}
- func(card, ...);
+ func(priv, ...);
If we can merge (B) part first, remaining part (A) can be simple.
But yes, the backport will be complex.
Thank you for your help !!
Best regards
---
Kuninori Morimoto
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] ASoC: meson: meson-card: use priv instead of card on each functions
2026-07-22 0:35 ` Kuninori Morimoto
@ 2026-07-22 7:40 ` Jerome Brunet
0 siblings, 0 replies; 8+ messages in thread
From: Jerome Brunet @ 2026-07-22 7:40 UTC (permalink / raw)
To: Kuninori Morimoto
Cc: Jaroslav Kysela, Kevin Hilman, Liam Girdwood, Mark Brown,
Martin Blumenstingl, Neil Armstrong, Takashi Iwai,
linux-arm-kernel, linux-sound
On mer. 22 juil. 2026 at 00:35, Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> wrote:
> Hi Jerome, again
>
> I now double checked.
>
>> > The change is simple but it will make more complex to backport fix an
>> > older kernel once this fix is applied. So again, getting more context to
>> > understand what you are trying to accomplish and why it needs a standard
>> > card variable name would help.
>>
>> Basically, after "Card capsuling" has done, we can't directly use card->xxx
>> anymore. So we need to update all of such code.
>> I would like to update such code as much as possible in advance.
>> Otherwise, "Card capsuling" patch itself will be more complex and difficult
>> to review.
>
> Current functions get "card" as parameter to get "dev".
>
> func(card, ...)
> {
> struct device *dev = card->dev;
> ...
> }
>
> After "Card capsuling", we will use "card_driver" instead.
> But switching "card" to "card_driver" only is not enough, on Meson case,
> because "card_driver" don't have "dev".
>
> On Meson case, it don't need to keep "card" in priv anymore after
> "Card capsuling". So I would like to add "dev" in priv instead, and remove
> "card", like this.
>
> struct meson_card {
> ...
> - struct snd_soc_card card;
> + struct snd_soc_card_driver card_driver;
> + struct device *dev;
> ...
> };
>
> Then, we can get both "card_driver" and "dev" from "priv".
>
> If we can switch to use "priv" instead of "card" *now*, the diff will be
> more small when "Card capsuling", because the patch will have
> "Card capsuling diff" (A) + "switch card to priv" (B).
>
> This diff of (B) part is doing very simple things, but is big volume,
> because it is sharing the code on Meson.
>
> - func(card, ...)
> + func(priv, ...)
> {
> - struct device *dev = card->dev;
> + struct device *dev = priv->dev;
> + struct snd_soc_card_driver *card_driver = priv->card_driver;
> ...
> - snd_soc_card_xxx(card, ...);
> + snd_soc_card_xxx(card_driver, ...);
> ...
> }
>
> - func(card, ...);
> + func(priv, ...);
>
> If we can merge (B) part first, remaining part (A) can be simple.
> But yes, the backport will be complex.
>
> Thank you for your help !!
>
> Best regards
> ---
> Kuninori Morimoto
I think getting the device from the card (or other ASoC element) is a
regular pattern. I get what you are trying to do with what you call
capsuling but maybe you should add an API to query those things from
the framework ? like Something snd_soc_card_get_dev(card) ?
The driver then does not have poke the internals of the card but can
still get stuff like that from it
--
Jerome
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-07-22 7:41 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-21 1:36 [PATCH 0/2] ASoC: meson: preparation for Card capsuling Kuninori Morimoto
2026-07-21 1:36 ` [PATCH RFC 1/2] ASoC: meson: meson-card-utils: use meson_card_parse_of_optional() Kuninori Morimoto
2026-07-21 7:32 ` Jerome Brunet
2026-07-21 1:36 ` [PATCH 2/2] ASoC: meson: meson-card: use priv instead of card on each functions Kuninori Morimoto
2026-07-21 7:35 ` Jerome Brunet
2026-07-21 23:22 ` Kuninori Morimoto
2026-07-22 0:35 ` Kuninori Morimoto
2026-07-22 7:40 ` Jerome Brunet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox