From: Jonathan Cameron <jic23@kernel.org>
To: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Cc: etienne.carriere@st.com, lars@metafoo.de, olivier.moysan@st.com,
pmeerw@pmeerw.net, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, krzk@kernel.org,
peter.ujfalusi@ti.com, andy.shevchenko@gmail.com,
Xu Wang <vulab@iscas.ac.cn>,
mcoquelin.stm32@gmail.com, alexandru.ardelean@analog.com,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org, alexandre.torgue@st.com
Subject: Re: [PATCH] iio: adc: stm32-adc: Remove redundant null check before clk_prepare_enable/clk_disable_unprepare
Date: Tue, 29 Dec 2020 17:14:41 +0000 [thread overview]
Message-ID: <20201229171441.5bfa812b@archlinux> (raw)
In-Reply-To: <ccf4d36d-dbb0-aea0-5625-4aaf6850c73d@foss.st.com>
On Fri, 18 Dec 2020 15:32:32 +0100
Fabrice Gasnier <fabrice.gasnier@foss.st.com> wrote:
> On 12/18/20 10:35 AM, Xu Wang wrote:
> > Because clk_prepare_enable() and clk_disable_unprepare() already checked
> > NULL clock parameter, so the additional checks are unnecessary, just
> > remove them.
> >
> > Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
> > ---
> > drivers/iio/adc/stm32-adc-core.c | 29 +++++++++++------------------
> > drivers/iio/adc/stm32-adc.c | 14 +++++---------
> > 2 files changed, 16 insertions(+), 27 deletions(-)
>
> Hi Xu,
>
> Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Applied,
thanks,
Jonathan
>
> Thanks for your patch,
> Best Regards,
> Fabrice
>
> >
> > diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c
> > index 9d1ad6e38e85..c088cb990193 100644
> > --- a/drivers/iio/adc/stm32-adc-core.c
> > +++ b/drivers/iio/adc/stm32-adc-core.c
> > @@ -535,20 +535,16 @@ static int stm32_adc_core_hw_start(struct device *dev)
> > goto err_switches_dis;
> > }
> >
> > - if (priv->bclk) {
> > - ret = clk_prepare_enable(priv->bclk);
> > - if (ret < 0) {
> > - dev_err(dev, "bus clk enable failed\n");
> > - goto err_regulator_disable;
> > - }
> > + ret = clk_prepare_enable(priv->bclk);
> > + if (ret < 0) {
> > + dev_err(dev, "bus clk enable failed\n");
> > + goto err_regulator_disable;
> > }
> >
> > - if (priv->aclk) {
> > - ret = clk_prepare_enable(priv->aclk);
> > - if (ret < 0) {
> > - dev_err(dev, "adc clk enable failed\n");
> > - goto err_bclk_disable;
> > - }
> > + ret = clk_prepare_enable(priv->aclk);
> > + if (ret < 0) {
> > + dev_err(dev, "adc clk enable failed\n");
> > + goto err_bclk_disable;
> > }
> >
> > writel_relaxed(priv->ccr_bak, priv->common.base + priv->cfg->regs->ccr);
> > @@ -556,8 +552,7 @@ static int stm32_adc_core_hw_start(struct device *dev)
> > return 0;
> >
> > err_bclk_disable:
> > - if (priv->bclk)
> > - clk_disable_unprepare(priv->bclk);
> > + clk_disable_unprepare(priv->bclk);
> > err_regulator_disable:
> > regulator_disable(priv->vref);
> > err_switches_dis:
> > @@ -575,10 +570,8 @@ static void stm32_adc_core_hw_stop(struct device *dev)
> >
> > /* Backup CCR that may be lost (depends on power state to achieve) */
> > priv->ccr_bak = readl_relaxed(priv->common.base + priv->cfg->regs->ccr);
> > - if (priv->aclk)
> > - clk_disable_unprepare(priv->aclk);
> > - if (priv->bclk)
> > - clk_disable_unprepare(priv->bclk);
> > + clk_disable_unprepare(priv->aclk);
> > + clk_disable_unprepare(priv->bclk);
> > regulator_disable(priv->vref);
> > stm32_adc_core_switches_supply_dis(priv);
> > regulator_disable(priv->vdda);
> > diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
> > index c067c994dae2..f7c53cea509a 100644
> > --- a/drivers/iio/adc/stm32-adc.c
> > +++ b/drivers/iio/adc/stm32-adc.c
> > @@ -546,8 +546,7 @@ static int stm32_adc_hw_stop(struct device *dev)
> > if (adc->cfg->unprepare)
> > adc->cfg->unprepare(indio_dev);
> >
> > - if (adc->clk)
> > - clk_disable_unprepare(adc->clk);
> > + clk_disable_unprepare(adc->clk);
> >
> > return 0;
> > }
> > @@ -558,11 +557,9 @@ static int stm32_adc_hw_start(struct device *dev)
> > struct stm32_adc *adc = iio_priv(indio_dev);
> > int ret;
> >
> > - if (adc->clk) {
> > - ret = clk_prepare_enable(adc->clk);
> > - if (ret)
> > - return ret;
> > - }
> > + ret = clk_prepare_enable(adc->clk);
> > + if (ret)
> > + return ret;
> >
> > stm32_adc_set_res(adc);
> >
> > @@ -575,8 +572,7 @@ static int stm32_adc_hw_start(struct device *dev)
> > return 0;
> >
> > err_clk_dis:
> > - if (adc->clk)
> > - clk_disable_unprepare(adc->clk);
> > + clk_disable_unprepare(adc->clk);
> >
> > return ret;
> > }
> >
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2020-12-29 17:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-18 9:35 [PATCH] iio: adc: stm32-adc: Remove redundant null check before clk_prepare_enable/clk_disable_unprepare Xu Wang
2020-12-18 14:32 ` Fabrice Gasnier
2020-12-29 17:14 ` Jonathan Cameron [this message]
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=20201229171441.5bfa812b@archlinux \
--to=jic23@kernel.org \
--cc=alexandre.torgue@st.com \
--cc=alexandru.ardelean@analog.com \
--cc=andy.shevchenko@gmail.com \
--cc=etienne.carriere@st.com \
--cc=fabrice.gasnier@foss.st.com \
--cc=krzk@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=olivier.moysan@st.com \
--cc=peter.ujfalusi@ti.com \
--cc=pmeerw@pmeerw.net \
--cc=vulab@iscas.ac.cn \
/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;
as well as URLs for NNTP newsgroup(s).