2019-09-09 02:24:47

by Katsuhiro Suzuki

[permalink] [raw]
Subject: [PATCH 1/2] ASoC: es8316: fix redundant codes of clock

This patch removes redundant null checks for optional MCLK clock.
And fix DT binding document for changing clock property to optional
from required.

Signed-off-by: Katsuhiro Suzuki <[email protected]>
---
.../bindings/sound/everest,es8316.txt | 3 ++
sound/soc/codecs/es8316.c | 31 ++++++++-----------
2 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/everest,es8316.txt b/Documentation/devicetree/bindings/sound/everest,es8316.txt
index aefcff9c48a2..1bf03c5f2af4 100644
--- a/Documentation/devicetree/bindings/sound/everest,es8316.txt
+++ b/Documentation/devicetree/bindings/sound/everest,es8316.txt
@@ -6,6 +6,9 @@ Required properties:

- compatible : should be "everest,es8316"
- reg : the I2C address of the device for I2C
+
+Optional properties:
+
- clocks : a list of phandle, should contain entries for clock-names
- clock-names : should include as follows:
"mclk" : master clock (MCLK) of the device
diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c
index d07d50f51b28..1424ecd6952c 100644
--- a/sound/soc/codecs/es8316.c
+++ b/sound/soc/codecs/es8316.c
@@ -373,11 +373,9 @@ static int es8316_set_dai_sysclk(struct snd_soc_dai *codec_dai,
if (freq == 0)
return 0;

- if (es8316->mclk) {
- ret = clk_set_rate(es8316->mclk, freq);
- if (ret)
- return ret;
- }
+ ret = clk_set_rate(es8316->mclk, freq);
+ if (ret)
+ return ret;

/* Limit supported sample rates to ones that can be autodetected
* by the codec running in slave mode.
@@ -712,20 +710,18 @@ static int es8316_probe(struct snd_soc_component *component)

es8316->component = component;

- es8316->mclk = devm_clk_get(component->dev, "mclk");
- if (PTR_ERR(es8316->mclk) == -EPROBE_DEFER)
- return -EPROBE_DEFER;
+ es8316->mclk = devm_clk_get_optional(component->dev, "mclk");
if (IS_ERR(es8316->mclk)) {
- dev_err(component->dev, "clock is invalid, ignored\n");
- es8316->mclk = NULL;
+ dev_err(component->dev, "unable to get mclk\n");
+ return PTR_ERR(es8316->mclk);
}
+ if (!es8316->mclk)
+ dev_warn(component->dev, "assuming static mclk\n");

- if (es8316->mclk) {
- ret = clk_prepare_enable(es8316->mclk);
- if (ret) {
- dev_err(component->dev, "unable to enable clock\n");
- return ret;
- }
+ ret = clk_prepare_enable(es8316->mclk);
+ if (ret) {
+ dev_err(component->dev, "unable to enable mclk\n");
+ return ret;
}

/* Reset codec and enable current state machine */
@@ -754,8 +750,7 @@ static void es8316_remove(struct snd_soc_component *component)
{
struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component);

- if (es8316->mclk)
- clk_disable_unprepare(es8316->mclk);
+ clk_disable_unprepare(es8316->mclk);
}

static const struct snd_soc_component_driver soc_component_dev_es8316 = {
--
2.23.0.rc1


2019-09-09 22:25:41

by Mark Brown

[permalink] [raw]
Subject: Applied "ASoC: es8316: fix redundant codes of clock" to the asoc tree

The patch

ASoC: es8316: fix redundant codes of clock

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4

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 0db0c62c88b84b135bbaf784499a08e536354a43 Mon Sep 17 00:00:00 2001
From: Katsuhiro Suzuki <[email protected]>
Date: Sun, 8 Sep 2019 01:36:52 +0900
Subject: [PATCH] ASoC: es8316: fix redundant codes of clock

This patch removes redundant null checks for optional MCLK clock.
And fix DT binding document for changing clock property to optional
from required.

Signed-off-by: Katsuhiro Suzuki <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
---
.../bindings/sound/everest,es8316.txt | 3 ++
sound/soc/codecs/es8316.c | 31 ++++++++-----------
2 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/everest,es8316.txt b/Documentation/devicetree/bindings/sound/everest,es8316.txt
index aefcff9c48a2..1bf03c5f2af4 100644
--- a/Documentation/devicetree/bindings/sound/everest,es8316.txt
+++ b/Documentation/devicetree/bindings/sound/everest,es8316.txt
@@ -6,6 +6,9 @@ Required properties:

- compatible : should be "everest,es8316"
- reg : the I2C address of the device for I2C
+
+Optional properties:
+
- clocks : a list of phandle, should contain entries for clock-names
- clock-names : should include as follows:
"mclk" : master clock (MCLK) of the device
diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c
index 6248b01ca049..e9fa4981ccef 100644
--- a/sound/soc/codecs/es8316.c
+++ b/sound/soc/codecs/es8316.c
@@ -370,11 +370,9 @@ static int es8316_set_dai_sysclk(struct snd_soc_dai *codec_dai,
if (freq == 0)
return 0;

- if (es8316->mclk) {
- ret = clk_set_rate(es8316->mclk, freq);
- if (ret)
- return ret;
- }
+ ret = clk_set_rate(es8316->mclk, freq);
+ if (ret)
+ return ret;

/* Limit supported sample rates to ones that can be autodetected
* by the codec running in slave mode.
@@ -709,20 +707,18 @@ static int es8316_probe(struct snd_soc_component *component)

es8316->component = component;

- es8316->mclk = devm_clk_get(component->dev, "mclk");
- if (PTR_ERR(es8316->mclk) == -EPROBE_DEFER)
- return -EPROBE_DEFER;
+ es8316->mclk = devm_clk_get_optional(component->dev, "mclk");
if (IS_ERR(es8316->mclk)) {
- dev_err(component->dev, "clock is invalid, ignored\n");
- es8316->mclk = NULL;
+ dev_err(component->dev, "unable to get mclk\n");
+ return PTR_ERR(es8316->mclk);
}
+ if (!es8316->mclk)
+ dev_warn(component->dev, "assuming static mclk\n");

- if (es8316->mclk) {
- ret = clk_prepare_enable(es8316->mclk);
- if (ret) {
- dev_err(component->dev, "unable to enable clock\n");
- return ret;
- }
+ ret = clk_prepare_enable(es8316->mclk);
+ if (ret) {
+ dev_err(component->dev, "unable to enable mclk\n");
+ return ret;
}

/* Reset codec and enable current state machine */
@@ -751,8 +747,7 @@ static void es8316_remove(struct snd_soc_component *component)
{
struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component);

- if (es8316->mclk)
- clk_disable_unprepare(es8316->mclk);
+ clk_disable_unprepare(es8316->mclk);
}

static const struct snd_soc_component_driver soc_component_dev_es8316 = {
--
2.20.1