[alsa-devel] [PATCH 0/5] ASoC: add/use asoc_simple_card_clk_xxx()
Hi Mark
This is v2 of Simple/Audio card clk encapsulation patch set. Mark wanted to use "static inline" instead of #define. But, this time I selected to use normal function instead of inline. Thus, it becomes asoc_simple_card_clk_register/enable/disable() now. It is easy to search card clk related code now.
Kuninori Morimoto (5): ASoC: simple_card_utils: add asoc_simple_card_clk_xxx() ASoC: simple-card: use asoc_simple_card_clk_xxx() ASoC: simple-scu-card: use asoc_simple_card_clk_xxx() ASoC: audio-graph-scu-card: use asoc_simple_card_clk_xxx() ASoC: audio-graph-card: use asoc_simple_card_clk_xxx()
include/sound/simple_card_utils.h | 2 ++ sound/soc/generic/audio-graph-card.c | 10 +++++----- sound/soc/generic/audio-graph-scu-card.c | 4 ++-- sound/soc/generic/simple-card-utils.c | 19 ++++++++++++++++++- sound/soc/generic/simple-card.c | 10 +++++----- sound/soc/generic/simple-scu-card.c | 4 ++-- 6 files changed, 34 insertions(+), 15 deletions(-)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current simple-card-utils sets asoc_simple_dai::clk via asoc_simple_card_parse_clk(). Current simple card drivers are using it 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 --- v1 -> v2
- asoc_simple_card_clk_xxx #define -> function - add new asoc_simple_card_clk_register
include/sound/simple_card_utils.h | 2 ++ sound/soc/generic/simple-card-utils.c | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 108cae4..840d624 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); +int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai); +void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai);
#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..beb4e38 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -110,6 +110,22 @@ int asoc_simple_card_parse_card_name(struct snd_soc_card *card, } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_name);
+static void asoc_simple_card_clk_register(struct asoc_simple_dai *dai, + struct clk *clk) +{ + dai->clk = clk; +} + +int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai) +{ + return clk_prepare_enable(dai->clk); +} + +void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai) +{ + clk_disable_unprepare(dai->clk); +} + int asoc_simple_card_parse_clk(struct device *dev, struct device_node *node, struct device_node *dai_of_node, @@ -128,7 +144,8 @@ 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); - simple_dai->clk = clk; + + asoc_simple_card_clk_register(simple_dai, clk); } else if (!of_property_read_u32(node, "system-clock-frequency", &val)) { simple_dai->sysclk = val; } else {
The patch
ASoC: simple_card_utils: add asoc_simple_card_clk_xxx()
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From 891caea417469b4efdf506b6be1ef461b759c999 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Fri, 9 Jun 2017 00:43:18 +0000 Subject: [PATCH] ASoC: simple_card_utils: add asoc_simple_card_clk_xxx()
Current simple-card-utils sets asoc_simple_dai::clk via asoc_simple_card_parse_clk(). Current simple card drivers are using it 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 Signed-off-by: Mark Brown broonie@kernel.org --- include/sound/simple_card_utils.h | 2 ++ sound/soc/generic/simple-card-utils.c | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 108cae459ed0..840d624148df 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); +int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai); +void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai);
#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 d9d8b8a58348..beb4e3817d22 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -110,6 +110,22 @@ int asoc_simple_card_parse_card_name(struct snd_soc_card *card, } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_name);
+static void asoc_simple_card_clk_register(struct asoc_simple_dai *dai, + struct clk *clk) +{ + dai->clk = clk; +} + +int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai) +{ + return clk_prepare_enable(dai->clk); +} + +void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai) +{ + clk_disable_unprepare(dai->clk); +} + int asoc_simple_card_parse_clk(struct device *dev, struct device_node *node, struct device_node *dai_of_node, @@ -128,7 +144,8 @@ 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); - simple_dai->clk = clk; + + asoc_simple_card_clk_register(simple_dai, clk); } else if (!of_property_read_u32(node, "system-clock-frequency", &val)) { simple_dai->sysclk = val; } else {
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current simple-card-utils sets asoc_simple_dai::clk via asoc_simple_card_parse_clk(). Current simple card drivers are using it directly for clk_enable/disable. Encapsulation is one of simple card util's purpose. Let's use asoc_simple_card_clk_enable/disable.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- v1 -> v2
- no change
sound/soc/generic/simple-card.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 1039202..276607d 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -118,13 +118,13 @@ static int asoc_simple_card_startup(struct snd_pcm_substream *substream) simple_priv_to_props(priv, rtd->num); int ret;
- ret = clk_prepare_enable(dai_props->cpu_dai.clk); + ret = asoc_simple_card_clk_enable(&dai_props->cpu_dai); if (ret) return ret;
- ret = clk_prepare_enable(dai_props->codec_dai.clk); + ret = asoc_simple_card_clk_enable(&dai_props->codec_dai); if (ret) - clk_disable_unprepare(dai_props->cpu_dai.clk); + asoc_simple_card_clk_disable(&dai_props->cpu_dai);
return ret; } @@ -136,9 +136,9 @@ static void asoc_simple_card_shutdown(struct snd_pcm_substream *substream) struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num);
- clk_disable_unprepare(dai_props->cpu_dai.clk); + asoc_simple_card_clk_disable(&dai_props->cpu_dai);
- clk_disable_unprepare(dai_props->codec_dai.clk); + asoc_simple_card_clk_disable(&dai_props->codec_dai); }
static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current simple-card-utils sets asoc_simple_dai::clk via asoc_simple_card_parse_clk(). Current simple card drivers are using it directly for clk_enable/disable. Encapsulation is one of simple card util's purpose. Let's use asoc_simple_card_clk_enable/disable.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- v1 -> v2
- no change
sound/soc/generic/simple-scu-card.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/generic/simple-scu-card.c b/sound/soc/generic/simple-scu-card.c index 5faf5d6..f203783 100644 --- a/sound/soc/generic/simple-scu-card.c +++ b/sound/soc/generic/simple-scu-card.c @@ -47,7 +47,7 @@ static int asoc_simple_card_startup(struct snd_pcm_substream *substream) struct asoc_simple_dai *dai_props = simple_priv_to_props(priv, rtd->num);
- return clk_prepare_enable(dai_props->clk); + return asoc_simple_card_clk_enable(dai_props); }
static void asoc_simple_card_shutdown(struct snd_pcm_substream *substream) @@ -57,7 +57,7 @@ static void asoc_simple_card_shutdown(struct snd_pcm_substream *substream) struct asoc_simple_dai *dai_props = simple_priv_to_props(priv, rtd->num);
- clk_disable_unprepare(dai_props->clk); + asoc_simple_card_clk_disable(dai_props); }
static const struct snd_soc_ops asoc_simple_card_ops = {
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current simple-card-utils sets asoc_simple_dai::clk via asoc_simple_card_parse_clk(). Current simple card drivers are using it directly for clk_enable/disable. Encapsulation is one of simple card util's purpose. Let's use asoc_simple_card_clk_enable/disable.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- v1 -> v2
- no change
sound/soc/generic/audio-graph-scu-card.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/generic/audio-graph-scu-card.c b/sound/soc/generic/audio-graph-scu-card.c index 0066102..27a261e 100644 --- a/sound/soc/generic/audio-graph-scu-card.c +++ b/sound/soc/generic/audio-graph-scu-card.c @@ -45,7 +45,7 @@ static int asoc_graph_card_startup(struct snd_pcm_substream *substream) struct graph_card_data *priv = snd_soc_card_get_drvdata(rtd->card); struct asoc_simple_dai *dai_props = graph_priv_to_props(priv, rtd->num);
- return clk_prepare_enable(dai_props->clk); + return asoc_simple_card_clk_enable(dai_props); }
static void asoc_graph_card_shutdown(struct snd_pcm_substream *substream) @@ -54,7 +54,7 @@ static void asoc_graph_card_shutdown(struct snd_pcm_substream *substream) struct graph_card_data *priv = snd_soc_card_get_drvdata(rtd->card); struct asoc_simple_dai *dai_props = graph_priv_to_props(priv, rtd->num);
- clk_disable_unprepare(dai_props->clk); + asoc_simple_card_clk_disable(dai_props); }
static struct snd_soc_ops asoc_graph_card_ops = {
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current simple-card-utils sets asoc_simple_dai::clk via asoc_simple_card_parse_clk(). Current simple card drivers are using it directly for clk_enable/disable. Encapsulation is one of simple card util's purpose. Let's use asoc_simple_card_clk_enable/disable.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- v1 -> v2
- no change
sound/soc/generic/audio-graph-card.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 0180b28..b5bb791 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -44,13 +44,13 @@ static int asoc_graph_card_startup(struct snd_pcm_substream *substream) struct graph_dai_props *dai_props = graph_priv_to_props(priv, rtd->num); int ret;
- ret = clk_prepare_enable(dai_props->cpu_dai.clk); + ret = asoc_simple_card_clk_enable(&dai_props->cpu_dai); if (ret) return ret;
- ret = clk_prepare_enable(dai_props->codec_dai.clk); + ret = asoc_simple_card_clk_enable(&dai_props->codec_dai); if (ret) - clk_disable_unprepare(dai_props->cpu_dai.clk); + asoc_simple_card_clk_disable(&dai_props->cpu_dai);
return ret; } @@ -61,9 +61,9 @@ static void asoc_graph_card_shutdown(struct snd_pcm_substream *substream) struct graph_card_data *priv = snd_soc_card_get_drvdata(rtd->card); struct graph_dai_props *dai_props = graph_priv_to_props(priv, rtd->num);
- clk_disable_unprepare(dai_props->cpu_dai.clk); + asoc_simple_card_clk_disable(&dai_props->cpu_dai);
- clk_disable_unprepare(dai_props->codec_dai.clk); + asoc_simple_card_clk_disable(&dai_props->codec_dai); }
static struct snd_soc_ops asoc_graph_card_ops = {
participants (2)
-
Kuninori Morimoto
-
Mark Brown