diff mbox

[1/5] ASoC: simple_card_utils: add asoc_simple_card_clk_enable/disable()

Message ID 874lvs4pd4.wl%kuninori.morimoto.gx@renesas.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Kuninori Morimoto June 7, 2017, 12:29 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Current simple-card-utils sets asoc_simple_dai::clk via
asoc_simple_card_parse_clk(), and requested parameter is only
simple_dai. But current simple card drivers are using
simple_dai::clk directly for clk_enable/disable.
Encapsulation is one of simple card util's purpose.
Let's encapsulate it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/simple_card_utils.h     | 2 ++
 sound/soc/generic/simple-card-utils.c | 6 ++++++
 2 files changed, 8 insertions(+)

Comments

Mark Brown June 8, 2017, 2:50 p.m. UTC | #1
On Wed, Jun 07, 2017 at 12:29:05AM +0000, Kuninori Morimoto wrote:

> +#define asoc_simple_card_clk_enable(dai) clk_prepare_enable((dai)->clk)
> +#define asoc_simple_card_clk_disable(dai) clk_disable_unprepare((dai)->clk)

Could we make these static inline functions instead please?  It
shouldn't make any difference to the generated code but it's a bit more
type safe.
Kuninori Morimoto June 8, 2017, 11:39 p.m. UTC | #2
Hi Mark

> > +#define asoc_simple_card_clk_enable(dai) clk_prepare_enable((dai)->clk)
> > +#define asoc_simple_card_clk_disable(dai) clk_disable_unprepare((dai)->clk)
> 
> Could we make these static inline functions instead please?  It
> shouldn't make any difference to the generated code but it's a bit more
> type safe.

OK, will do in v2

Best regards
---
Kuninori Morimoto
diff mbox

Patch

diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index 108cae4..9e8e829 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -45,6 +45,8 @@  int asoc_simple_card_parse_clk(struct device *dev,
 			       struct device_node *dai_of_node,
 			       struct asoc_simple_dai *simple_dai,
 			       const char *name);
+#define asoc_simple_card_clk_enable(dai) clk_prepare_enable((dai)->clk)
+#define asoc_simple_card_clk_disable(dai) clk_disable_unprepare((dai)->clk)
 
 #define asoc_simple_card_parse_cpu(node, dai_link,				\
 				   list_name, cells_name, is_single_link)	\
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index d9d8b8a..f7df08b 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -128,6 +128,12 @@  int asoc_simple_card_parse_clk(struct device *dev,
 	clk = devm_get_clk_from_child(dev, node, NULL);
 	if (!IS_ERR(clk)) {
 		simple_dai->sysclk = clk_get_rate(clk);
+
+		/*
+		 * This enables
+		 *	asoc_simple_card_clk_enable()
+		 *	asoc_simple_card_clk_disable()
+		 */
 		simple_dai->clk = clk;
 	} else if (!of_property_read_u32(node, "system-clock-frequency", &val)) {
 		simple_dai->sysclk = val;