All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Naveen Krishna Chatradhi <ch.naveen@samsung.com>,
	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, t.figa@samsung.com
Subject: Re: [PATCH 2/5 v3] iio: exynos_adc: rearrange clk and regulator enable/disable calls
Date: Wed, 30 Apr 2014 21:44:14 +0100	[thread overview]
Message-ID: <5361609E.5070609@kernel.org> (raw)
In-Reply-To: <1398850015-17761-3-git-send-email-ch.naveen@samsung.com>

On 30/04/14 10:26, Naveen Krishna Chatradhi wrote:
> 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
>
> Signed-off-by: Naveen Krishna Ch <ch.naveen@samsung.com>
> Reviewed-by: Doug Anderson <dianders@chromium.org>
Applied to the togreg branch of iio.git.

Thanks,
> ---
> Changes since v2:
> Remove extra unused line and add Doug's Reviewed-by
> Changes since v1:
> corrected the register/unregister and enabling/disbaling sequences
>
>   drivers/iio/adc/exynos_adc.c |   62 ++++++++++++++++++++++--------------------
>   1 file changed, 33 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
> index affa93f..ff98c5d 100644
> --- a/drivers/iio/adc/exynos_adc.c
> +++ b/drivers/iio/adc/exynos_adc.c
> @@ -290,32 +290,30 @@ static int exynos_adc_probe(struct platform_device *pdev)
>
>   	init_completion(&info->completion);
>
> -	ret = request_irq(info->irq, exynos_adc_isr,
> -					0, dev_name(&pdev->dev), info);
> -	if (ret < 0) {
> -		dev_err(&pdev->dev, "failed requesting irq, irq = %d\n",
> -							info->irq);
> -		return ret;
> -	}
> -
> -	writel(1, info->enable_reg);
> -
>   	info->clk = devm_clk_get(&pdev->dev, "adc");
>   	if (IS_ERR(info->clk)) {
>   		dev_err(&pdev->dev, "failed getting clock, err = %ld\n",
>   							PTR_ERR(info->clk));
> -		ret = PTR_ERR(info->clk);
> -		goto err_irq;
> +		return PTR_ERR(info->clk);
>   	}
>
>   	info->vdd = devm_regulator_get(&pdev->dev, "vdd");
>   	if (IS_ERR(info->vdd)) {
>   		dev_err(&pdev->dev, "failed getting regulator, err = %ld\n",
>   							PTR_ERR(info->vdd));
> -		ret = PTR_ERR(info->vdd);
> -		goto err_irq;
> +		return PTR_ERR(info->vdd);
>   	}
>
> +	ret = regulator_enable(info->vdd);
> +	if (ret)
> +		return ret;
> +
> +	ret = clk_prepare_enable(info->clk);
> +	if (ret)
> +		goto err_disable_reg;
> +
> +	writel(1, info->enable_reg);
> +
>   	info->version = exynos_adc_get_version(pdev);
>
>   	platform_set_drvdata(pdev, indio_dev);
> @@ -332,16 +330,18 @@ static int exynos_adc_probe(struct platform_device *pdev)
>   	else
>   		indio_dev->num_channels = MAX_ADC_V2_CHANNELS;
>
> +	ret = request_irq(info->irq, exynos_adc_isr,
> +					0, dev_name(&pdev->dev), info);
> +	if (ret < 0) {
> +		dev_err(&pdev->dev, "failed requesting irq, irq = %d\n",
> +							info->irq);
> +		goto err_disable_clk;
> +	}
> +
>   	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);
> -
>   	exynos_adc_hw_init(info);
>
>   	ret = of_platform_populate(np, exynos_adc_match, NULL, &indio_dev->dev);
> @@ -355,12 +355,14 @@ 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_irq:
>   	free_irq(info->irq, info);
> +err_disable_clk:
> +	writel(0, info->enable_reg);
> +	clk_disable_unprepare(info->clk);
> +err_disable_reg:
> +	regulator_disable(info->vdd);
>   	return ret;
>   }
>
> @@ -371,11 +373,11 @@ 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);
> -	writel(0, info->enable_reg);
>   	iio_device_unregister(indio_dev);
>   	free_irq(info->irq, info);
> +	writel(0, info->enable_reg);
> +	clk_disable_unprepare(info->clk);
> +	regulator_disable(info->vdd);
>
>   	return 0;
>   }
> @@ -397,8 +399,8 @@ static int exynos_adc_suspend(struct device *dev)
>   		writel(con, ADC_V1_CON(info->regs));
>   	}
>
> -	clk_disable_unprepare(info->clk);
>   	writel(0, info->enable_reg);
> +	clk_disable_unprepare(info->clk);
>   	regulator_disable(info->vdd);
>
>   	return 0;
> @@ -414,9 +416,11 @@ static int exynos_adc_resume(struct device *dev)
>   	if (ret)
>   		return ret;
>
> -	writel(1, info->enable_reg);
> -	clk_prepare_enable(info->clk);
> +	ret = clk_prepare_enable(info->clk);
> +	if (ret)
> +		return ret;
>
> +	writel(1, info->enable_reg);
>   	exynos_adc_hw_init(info);
>
>   	return 0;
>


  reply	other threads:[~2014-04-30 20:42 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-30  9:26 [PATCH 0/5 v3] iio: exynos_adc: fix minor nits in the driver Naveen Krishna Chatradhi
2014-04-30  9:26 ` [PATCH 1/5 v3] iio: exynos_adc: use indio_dev->dev structure to handle child nodes Naveen Krishna Chatradhi
2014-04-30 20:43   ` Jonathan Cameron
2014-04-30 20:43     ` Jonathan Cameron
2014-04-30  9:26 ` [PATCH 2/5 v3] iio: exynos_adc: rearrange clk and regulator enable/disable calls Naveen Krishna Chatradhi
2014-04-30 20:44   ` Jonathan Cameron [this message]
2014-04-30  9:26 ` [PATCH 3/5 v3] iio: exynos_adc: reduce timeout and use wait_for_completion_timeout Naveen Krishna Chatradhi
2014-04-30 20:44   ` Jonathan Cameron
2014-04-30 20:44     ` Jonathan Cameron
2014-04-30  9:26 ` [PATCH 4/5 v3] iio: exynos_adc: do a soft reset in case of timeout Naveen Krishna Chatradhi
2014-04-30 20:47   ` Jonathan Cameron
2014-04-30 20:47     ` Jonathan Cameron
2014-04-30  9:26 ` [PATCH 5/5 v3] iio: exynos_adc: do a reinit_completion before the conversion Naveen Krishna Chatradhi
2014-04-30 20:49   ` Jonathan Cameron
2014-04-30 20:49     ` Jonathan Cameron
2014-04-30 23:23     ` Doug Anderson
2014-04-30 23:23       ` Doug Anderson
2014-05-01  5:48       ` Jonathan Cameron
2014-05-01  5:48         ` Jonathan Cameron

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=5361609E.5070609@kernel.org \
    --to=jic23@kernel.org \
    --cc=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 \
    --cc=t.figa@samsung.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.