From: Naveen Krishna Chatradhi <ch.naveen@samsung.com>
To: linux-iio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
dianders@chromium.org, gregkh@linuxfoundation.org,
naveenkrishna.ch@gmail.com, lars@metafoo.de, cpgs@samsung.com,
grundler@chromium.org, Naveen Krishna Ch <ch.naveen@samsung.com>
Subject: [PATCH 2/5] iio: exynos_adc: rearrange clock and regulator enable/disable calls
Date: Fri, 25 Apr 2014 15:44:44 +0530 [thread overview]
Message-ID: <1398420888-5506-3-git-send-email-ch.naveen@samsung.com> (raw)
In-Reply-To: <1398420888-5506-1-git-send-email-ch.naveen@samsung.com>
From: Naveen Krishna Ch <ch.naveen@samsung.com>
This patch maintains the following order in
probe(), remove(), resume() and suspend() calls
regulator enable, clk prepare enable
...
clk disable unprepare, regulator disable
While at it,
1. enable the regulator before the iio_device_register()
2. handle the return values for enable/disable calls
Change-Id: I764d9d60f72caa7ea6b0609db49a74115574f081
Signed-off-by: Naveen Krishna Ch <ch.naveen@samsung.com>
---
This change fixes the comments given by Jonathan regarding the
order of clock and regulator enable/disable calls.
https://lkml.org/lkml/2014/4/23/644
drivers/iio/adc/exynos_adc.c | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
index affa93f..a2b8b1a 100644
--- a/drivers/iio/adc/exynos_adc.c
+++ b/drivers/iio/adc/exynos_adc.c
@@ -316,6 +316,14 @@ static int exynos_adc_probe(struct platform_device *pdev)
goto err_irq;
}
+ ret = regulator_enable(info->vdd);
+ if (ret)
+ goto err_irq;
+
+ ret = clk_prepare_enable(info->clk);
+ if (ret)
+ goto err_disable_reg;
+
info->version = exynos_adc_get_version(pdev);
platform_set_drvdata(pdev, indio_dev);
@@ -334,13 +342,7 @@ static int exynos_adc_probe(struct platform_device *pdev)
ret = iio_device_register(indio_dev);
if (ret)
- goto err_irq;
-
- ret = regulator_enable(info->vdd);
- if (ret)
- goto err_iio_dev;
-
- clk_prepare_enable(info->clk);
+ goto err_disable_clk;
exynos_adc_hw_init(info);
@@ -355,10 +357,11 @@ static int exynos_adc_probe(struct platform_device *pdev)
err_of_populate:
device_for_each_child(&indio_dev->dev, NULL,
exynos_adc_remove_devices);
- regulator_disable(info->vdd);
- clk_disable_unprepare(info->clk);
-err_iio_dev:
iio_device_unregister(indio_dev);
+err_disable_clk:
+ clk_disable_unprepare(info->clk);
+err_disable_reg:
+ regulator_disable(info->vdd);
err_irq:
free_irq(info->irq, info);
return ret;
@@ -371,9 +374,10 @@ static int exynos_adc_remove(struct platform_device *pdev)
device_for_each_child(&indio_dev->dev, NULL,
exynos_adc_remove_devices);
- regulator_disable(info->vdd);
clk_disable_unprepare(info->clk);
+ regulator_disable(info->vdd);
writel(0, info->enable_reg);
+
iio_device_unregister(indio_dev);
free_irq(info->irq, info);
@@ -398,8 +402,8 @@ static int exynos_adc_suspend(struct device *dev)
}
clk_disable_unprepare(info->clk);
- writel(0, info->enable_reg);
regulator_disable(info->vdd);
+ writel(0, info->enable_reg);
return 0;
}
@@ -410,12 +414,14 @@ static int exynos_adc_resume(struct device *dev)
struct exynos_adc *info = iio_priv(indio_dev);
int ret;
+ writel(1, info->enable_reg);
ret = regulator_enable(info->vdd);
if (ret)
return ret;
- writel(1, info->enable_reg);
- clk_prepare_enable(info->clk);
+ ret = clk_prepare_enable(info->clk);
+ if (ret)
+ return ret;
exynos_adc_hw_init(info);
--
1.7.9.5
next prev parent reply other threads:[~2014-04-25 10:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-25 10:14 [PATCH 0/5] iio: exynos_adc: fix minor nits in the driver Naveen Krishna Chatradhi
2014-04-25 10:14 ` [PATCH 1/5] iio: exynos_adc: use indio_dev->dev structure to handle child nodes Naveen Krishna Chatradhi
2014-04-25 15:46 ` Doug Anderson
2014-04-26 12:53 ` Jonathan Cameron
2014-04-26 13:51 ` Naveen Krishna Ch
2014-04-25 10:14 ` Naveen Krishna Chatradhi [this message]
2014-04-25 16:06 ` [PATCH 2/5] iio: exynos_adc: rearrange clock and regulator enable/disable calls Doug Anderson
2014-04-25 10:14 ` [PATCH 3/5] iio: exynos_adc: reduce timeout and use wait_for_completion_timeout Naveen Krishna Chatradhi
2014-04-25 16:28 ` Doug Anderson
2014-04-25 10:14 ` [PATCH 4/5] iio: exynos_adc: do a soft reset in case of timeout Naveen Krishna Chatradhi
2014-04-25 16:29 ` Doug Anderson
2014-04-25 10:14 ` [PATCH 5/5] iio: exynos_adc: do a reinit_completion before the conversion Naveen Krishna Chatradhi
2014-04-25 16:32 ` Doug Anderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1398420888-5506-3-git-send-email-ch.naveen@samsung.com \
--to=ch.naveen@samsung.com \
--cc=cpgs@samsung.com \
--cc=dianders@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=grundler@chromium.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=naveenkrishna.ch@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®