From: George Stark <gnstark@sberdevices.ru>
To: Jonathan Cameron <jic23@kernel.org>
Cc: <lars@metafoo.de>, <neil.armstrong@linaro.org>,
<khilman@baylibre.com>, <jbrunet@baylibre.com>,
<martin.blumenstingl@googlemail.com>,
<andriy.shevchenko@linux.intel.com>, <nuno.sa@analog.com>,
<linux-iio@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>,
<linux-amlogic@lists.infradead.org>, <kernel@sberdevices.ru>
Subject: Re: [PATCH v1 1/1] iio: adc: meson: fix core clock enable/disable moment
Date: Fri, 21 Jul 2023 12:58:49 +0300 [thread overview]
Message-ID: <e028c2dc-07e3-71d3-422d-08c6e3a4a99f@sberdevices.ru> (raw)
In-Reply-To: <20230715182121.29f83d76@jic23-huawei>
Hello Jonathan
Thanks for the feedback.
On 7/15/23 20:21, Jonathan Cameron wrote:
> On Fri, 14 Jul 2023 22:03:15 +0300
> George Stark <gnstark@sberdevices.ru> wrote:
>
>> Enable core clock at probe stage and disable it at remove stage.
>> Core clock is responsible for turning on/off the entire SoC module so
>> it should be on before the first module register is touched and be off
>> at very last moment.
>>
>> Signed-off-by: George Stark <gnstark@sberdevices.ru>
>
> This sounds to me like this should perhaps have a fixes tag?
ack
>
> Given where it is in the new sequence you can also use
> devm_clk_get_enabled() though that makes a potential backport of
> the fix trickier...
>
> I'd go with it anyway as it will make this change quite a bit simpler.
ack
>
> More comments inline
>
> Jonathan
>
>> ---
>> drivers/iio/adc/meson_saradc.c | 20 ++++++++++----------
>> 1 file changed, 10 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
>> index fe066c9fab83..5a5bb5cc1320 100644
>> --- a/drivers/iio/adc/meson_saradc.c
>> +++ b/drivers/iio/adc/meson_saradc.c
>> @@ -1055,12 +1055,6 @@ static int meson_sar_adc_hw_enable(struct iio_dev *indio_dev)
>> goto err_vref;
>> }
>>
>> - ret = clk_prepare_enable(priv->core_clk);
>> - if (ret) {
>> - dev_err(dev, "failed to enable core clk\n");
>> - goto err_core_clk;
>> - }
>> -
>> regval = FIELD_PREP(MESON_SAR_ADC_REG0_FIFO_CNT_IRQ_MASK, 1);
>> regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG0,
>> MESON_SAR_ADC_REG0_FIFO_CNT_IRQ_MASK, regval);
>> @@ -1087,8 +1081,6 @@ static int meson_sar_adc_hw_enable(struct iio_dev *indio_dev)
>> regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3,
>> MESON_SAR_ADC_REG3_ADC_EN, 0);
>> meson_sar_adc_set_bandgap(indio_dev, false);
>> - clk_disable_unprepare(priv->core_clk);
>> -err_core_clk:
>> regulator_disable(priv->vref);
>> err_vref:
>> meson_sar_adc_unlock(indio_dev);
>> @@ -1116,8 +1108,6 @@ static void meson_sar_adc_hw_disable(struct iio_dev *indio_dev)
>>
>> meson_sar_adc_set_bandgap(indio_dev, false);
>>
>> - clk_disable_unprepare(priv->core_clk);
>> -
>> regulator_disable(priv->vref);
>>
>> if (!ret)
>> @@ -1420,6 +1410,12 @@ static int meson_sar_adc_probe(struct platform_device *pdev)
>> ARRAY_SIZE(meson_sar_adc_iio_channels);
>> }
>>
>> + ret = clk_prepare_enable(priv->core_clk);
>> + if (ret) {
>> + dev_err(dev, "failed to enable core clk\n");
>> + goto err;
>
> If clk_prepare_enable() failed, then you shoudl not call clk_disable_unprepare()
yes, but with devm_clk_get_enabled we dont't need this line anymore
>
>> + }
>> +
>> ret = meson_sar_adc_init(indio_dev);
>> if (ret)
>> goto err;
>> @@ -1445,17 +1441,21 @@ static int meson_sar_adc_probe(struct platform_device *pdev)
>> err_hw:
>> meson_sar_adc_hw_disable(indio_dev);
>> err:
>> + clk_disable_unprepare(priv->core_clk);
>
> Nothing to do with your patch, but this driver previously did some odd mixing
> of direct returns and going to an empty label which definitely doesn't help
> make this clear to follow.
I made additional patch adding log messages to all errors those can
break probe stage
>
>> return ret;
>> }
>>
>> static int meson_sar_adc_remove(struct platform_device *pdev)
>> {
>> struct iio_dev *indio_dev = platform_get_drvdata(pdev);
>> + struct meson_sar_adc_priv *priv = iio_priv(indio_dev);
>>
>> iio_device_unregister(indio_dev);
>>
>> meson_sar_adc_hw_disable(indio_dev);
>>
>> + clk_disable_unprepare(priv->core_clk);
>> +
>> return 0;
>> }
>>
>
--
Best regards
George
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
prev parent reply other threads:[~2023-07-21 10:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-14 19:03 [PATCH v1 0/1] " George Stark
2023-07-14 19:03 ` [PATCH v1 1/1] " George Stark
2023-07-15 17:21 ` Jonathan Cameron
2023-07-21 9:58 ` George Stark [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=e028c2dc-07e3-71d3-422d-08c6e3a4a99f@sberdevices.ru \
--to=gnstark@sberdevices.ru \
--cc=andriy.shevchenko@linux.intel.com \
--cc=jbrunet@baylibre.com \
--cc=jic23@kernel.org \
--cc=kernel@sberdevices.ru \
--cc=khilman@baylibre.com \
--cc=lars@metafoo.de \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=neil.armstrong@linaro.org \
--cc=nuno.sa@analog.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®