[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <ea012cdeda63560e99e83d2fc25ce584031fb519.1501095307.git.arvind.yadav.cs@gmail.com>
Date: Thu, 27 Jul 2017 00:28:52 +0530
From: Arvind Yadav <arvind.yadav.cs@...il.com>
To: krzk@...nel.org, broonie@...nel.org, sbkim73@...sung.com,
s.nawrocki@...sung.com, perex@...ex.cz, tiwai@...e.com
Cc: alsa-devel@...a-project.org, linux-kernel@...r.kernel.org
Subject: [PATCH] ASoC: samsung: s3c2412: cleanups / fixes for preparation of clocks.
-Use devm_clk_get() to make cleanup paths more simple.
-clk_prepare_enable() can fail here and we must check its return value.
-Add s3c_i2sv2_remove cleanup function of s3c_i2sv2_probe.
-No need to iounmap. Here, mapping done by devm_ioremap_resource.
Signed-off-by: Arvind Yadav <arvind.yadav.cs@...il.com>
---
sound/soc/samsung/s3c-i2s-v2.c | 19 ++++++++++++++++---
sound/soc/samsung/s3c-i2s-v2.h | 3 +++
sound/soc/samsung/s3c2412-i2s.c | 10 ++++++++--
3 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/sound/soc/samsung/s3c-i2s-v2.c b/sound/soc/samsung/s3c-i2s-v2.c
index 8f42dea..ab4899f 100644
--- a/sound/soc/samsung/s3c-i2s-v2.c
+++ b/sound/soc/samsung/s3c-i2s-v2.c
@@ -625,20 +625,24 @@ int s3c_i2sv2_probe(struct snd_soc_dai *dai,
{
struct device *dev = dai->dev;
unsigned int iismod;
+ int ret;
i2s->dev = dev;
/* record our i2s structure for later use in the callbacks */
snd_soc_dai_set_drvdata(dai, i2s);
- i2s->iis_pclk = clk_get(dev, "iis");
+ i2s->iis_pclk = devm_clk_get(dev, "iis");
if (IS_ERR(i2s->iis_pclk)) {
dev_err(dev, "failed to get iis_clock\n");
- iounmap(i2s->regs);
return -ENOENT;
}
- clk_enable(i2s->iis_pclk);
+ ret = clk_prepare_enable(i2s->iis_pclk);
+ if (ret) {
+ dev_err(dev, "failed to prepare iis_clock\n");
+ return ret;
+ }
/* Mark ourselves as in TXRX mode so we can run through our cleanup
* process without warnings. */
@@ -652,6 +656,15 @@ int s3c_i2sv2_probe(struct snd_soc_dai *dai,
}
EXPORT_SYMBOL_GPL(s3c_i2sv2_probe);
+int s3c_i2sv2_remove(struct snd_soc_dai *dai)
+{
+ struct s3c_i2sv2_info *i2s = to_info(dai);
+
+ clk_disable_unprepare(i2s->iis_pclk);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(s3c_i2sv2_remove);
+
#ifdef CONFIG_PM
static int s3c2412_i2s_suspend(struct snd_soc_dai *dai)
{
diff --git a/sound/soc/samsung/s3c-i2s-v2.h b/sound/soc/samsung/s3c-i2s-v2.h
index 182d805..d6844b9 100644
--- a/sound/soc/samsung/s3c-i2s-v2.h
+++ b/sound/soc/samsung/s3c-i2s-v2.h
@@ -91,6 +91,9 @@ extern int s3c_i2sv2_probe(struct snd_soc_dai *dai,
struct s3c_i2sv2_info *i2s,
unsigned long base);
+
+extern int s3c_i2sv2_remove(struct snd_soc_dai *dai);
+
/**
* s3c_i2sv2_register_component - register component and dai with soc core
* @dev: DAI device
diff --git a/sound/soc/samsung/s3c2412-i2s.c b/sound/soc/samsung/s3c2412-i2s.c
index 0a47182..adfbd52d 100644
--- a/sound/soc/samsung/s3c2412-i2s.c
+++ b/sound/soc/samsung/s3c2412-i2s.c
@@ -65,13 +65,18 @@ static int s3c2412_i2s_probe(struct snd_soc_dai *dai)
s3c2412_i2s.iis_cclk = devm_clk_get(dai->dev, "i2sclk");
if (IS_ERR(s3c2412_i2s.iis_cclk)) {
pr_err("failed to get i2sclk clock\n");
+ s3c_i2sv2_remove(dai);
return PTR_ERR(s3c2412_i2s.iis_cclk);
}
/* Set MPLL as the source for IIS CLK */
- clk_set_parent(s3c2412_i2s.iis_cclk, clk_get(NULL, "mpll"));
- clk_prepare_enable(s3c2412_i2s.iis_cclk);
+ clk_set_parent(s3c2412_i2s.iis_cclk, devm_clk_get(dai->dev, "mpll"));
+ ret = clk_prepare_enable(s3c2412_i2s.iis_cclk);
+ if (ret) {
+ s3c_i2sv2_remove(dai);
+ return ret;
+ }
s3c2412_i2s.iis_cclk = s3c2412_i2s.iis_pclk;
@@ -85,6 +90,7 @@ static int s3c2412_i2s_probe(struct snd_soc_dai *dai)
static int s3c2412_i2s_remove(struct snd_soc_dai *dai)
{
clk_disable_unprepare(s3c2412_i2s.iis_cclk);
+ s3c_i2sv2_remove(dai);
return 0;
}
--
2.7.4
Powered by blists - more mailing lists