Commit df23fcd5 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: audio-graph-card: add ep_to_port() / port_to_ports()

Current audio-graph-card is using of_get_parent() to get "port" from
"ep", or get "ports" from "port". But it is difficlut to understand,
and "ports" might not exist.
This patch adds ep_to_port() to get "port" from "ep", and port_to_ports()
to get "ports" from "port". "ports" will be NULL if not exist.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://msgid.link/r/8734q2h6fz.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent f2d7e859
...@@ -19,6 +19,18 @@ ...@@ -19,6 +19,18 @@
#define DPCM_SELECTABLE 1 #define DPCM_SELECTABLE 1
#define ep_to_port(ep) of_get_parent(ep)
static struct device_node *port_to_ports(struct device_node *port)
{
struct device_node *ports = of_get_parent(port);
if (!of_node_name_eq(ports, "ports")) {
of_node_put(ports);
return NULL;
}
return ports;
}
static int graph_outdrv_event(struct snd_soc_dapm_widget *w, static int graph_outdrv_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, struct snd_kcontrol *kcontrol,
int event) int event)
...@@ -68,8 +80,8 @@ static void graph_parse_convert(struct device *dev, ...@@ -68,8 +80,8 @@ static void graph_parse_convert(struct device *dev,
struct simple_util_data *adata) struct simple_util_data *adata)
{ {
struct device_node *top = dev->of_node; struct device_node *top = dev->of_node;
struct device_node *port = of_get_parent(ep); struct device_node *port = ep_to_port(ep);
struct device_node *ports = of_get_parent(port); struct device_node *ports = port_to_ports(port);
struct device_node *node = of_graph_get_port_parent(ep); struct device_node *node = of_graph_get_port_parent(ep);
simple_util_parse_convert(top, NULL, adata); simple_util_parse_convert(top, NULL, adata);
...@@ -87,8 +99,8 @@ static void graph_parse_mclk_fs(struct device_node *top, ...@@ -87,8 +99,8 @@ static void graph_parse_mclk_fs(struct device_node *top,
struct device_node *ep, struct device_node *ep,
struct simple_dai_props *props) struct simple_dai_props *props)
{ {
struct device_node *port = of_get_parent(ep); struct device_node *port = ep_to_port(ep);
struct device_node *ports = of_get_parent(port); struct device_node *ports = port_to_ports(port);
of_property_read_u32(top, "mclk-fs", &props->mclk_fs); of_property_read_u32(top, "mclk-fs", &props->mclk_fs);
if (of_node_name_eq(ports, "ports")) if (of_node_name_eq(ports, "ports"))
...@@ -231,8 +243,8 @@ static int graph_dai_link_of_dpcm(struct simple_util_priv *priv, ...@@ -231,8 +243,8 @@ static int graph_dai_link_of_dpcm(struct simple_util_priv *priv,
"be.%pOFP.%s", codecs->of_node, codecs->dai_name); "be.%pOFP.%s", codecs->of_node, codecs->dai_name);
/* check "prefix" from top node */ /* check "prefix" from top node */
port = of_get_parent(ep); port = ep_to_port(ep);
ports = of_get_parent(port); ports = port_to_ports(port);
snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node, snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node,
"prefix"); "prefix");
if (of_node_name_eq(ports, "ports")) if (of_node_name_eq(ports, "ports"))
...@@ -350,7 +362,7 @@ static int __graph_for_each_link(struct simple_util_priv *priv, ...@@ -350,7 +362,7 @@ static int __graph_for_each_link(struct simple_util_priv *priv,
/* get codec */ /* get codec */
codec_ep = of_graph_get_remote_endpoint(cpu_ep); codec_ep = of_graph_get_remote_endpoint(cpu_ep);
codec_port = of_get_parent(codec_ep); codec_port = ep_to_port(codec_ep);
/* get convert-xxx property */ /* get convert-xxx property */
memset(&adata, 0, sizeof(adata)); memset(&adata, 0, sizeof(adata));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment