[PATCH 10/14] ASoC: simple-card-utils: add simple_props_to_xxx() macro

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Thu Apr 1 06:16:28 CEST 2021


From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>

We shouldn't use dai_props->cpus/codecs/cpu_dai/codec_dai/codec_conf
directly, because these are array to supporting multi CPU/Codec/Platform.
This patch adds asoc_link_to_xxx() macro for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
 include/sound/simple_card_utils.h | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index e366e432c475..78b6cf0194d2 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -74,32 +74,45 @@ struct asoc_simple_priv {
 #define simple_priv_to_dev(priv)	(simple_priv_to_card(priv)->dev)
 #define simple_priv_to_link(priv, i)	(simple_priv_to_card(priv)->dai_link + (i))
 
+#define simple_props_to_dlc_cpu(props, i)	((props)->cpus + i)
+#define simple_props_to_dlc_codec(props, i)	((props)->codecs + i)
+#define simple_props_to_dlc_platform(props, i)	((props)->platforms + i)
+
+#define simple_props_to_dai_cpu(props, i)	((props)->cpu_dai + i)
+#define simple_props_to_dai_codec(props, i)	((props)->codec_dai + i)
+#define simple_props_to_codec_conf(props, i)	((props)->codec_conf + i)
+
 #define for_each_prop_dlc_cpus(props, i, cpu)				\
 	for ((i) = 0;							\
-	     ((i) < (props)->num.cpus) && ((cpu) = &(props)->cpus[i]);	\
+	     ((i) < (props)->num.cpus) &&				\
+		     ((cpu) = simple_props_to_dlc_cpu(props, i));	\
 	     (i)++)
-#define for_each_prop_dlc_codecs(props, i, codec)				\
+#define for_each_prop_dlc_codecs(props, i, codec)			\
 	for ((i) = 0;							\
-	     ((i) < (props)->num.codecs) && ((codec) = &(props)->codecs[i]); \
+	     ((i) < (props)->num.codecs) &&				\
+		     ((codec) = simple_props_to_dlc_codec(props, i));	\
 	     (i)++)
 #define for_each_prop_dlc_platforms(props, i, platform)			\
 	for ((i) = 0;							\
-	     ((i) < (props)->num.platforms) && ((platform) = &(props)->platforms[i]); \
+	     ((i) < (props)->num.platforms) &&				\
+		     ((platform) = simple_props_to_dlc_platform(props, i)); \
 	     (i)++)
 #define for_each_prop_codec_conf(props, i, conf)			\
 	for ((i) = 0;							\
 	     ((i) < (props)->num.codecs) &&				\
 		     (props)->codec_conf &&				\
-		     ((conf) = &(props)->codec_conf[i]);		\
+		     ((conf) = simple_props_to_codec_conf(props, i));	\
 	     (i)++)
 
 #define for_each_prop_dai_cpu(props, i, cpu)				\
 	for ((i) = 0;							\
-	     ((i) < (props)->num.cpus) && ((cpu) = &(props)->cpu_dai[i]); \
+	     ((i) < (props)->num.cpus) &&				\
+		     ((cpu) = simple_props_to_dai_cpu(props, i));	\
 	     (i)++)
 #define for_each_prop_dai_codec(props, i, codec)			\
 	for ((i) = 0;							\
-	     ((i) < (props)->num.codecs) && ((codec) = &(props)->codec_dai[i]); \
+	     ((i) < (props)->num.codecs) &&				\
+		     ((codec) = simple_props_to_dai_codec(props, i));	\
 	     (i)++)
 
 struct link_info {
-- 
2.25.1



More information about the Alsa-devel mailing list