From: Claudiu Beznea <claudiu.beznea@tuxon.dev>
To: Paul Barker <paul.barker.ct@bp.renesas.com>,
prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org,
lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, geert+renesas@glider.be,
magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org,
p.zabel@pengutronix.de
Cc: linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-clk@vger.kernel.org,
Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Subject: Re: [PATCH 03/14] iio: adc: rzg2l_adc: Simplify the runtime PM code
Date: Tue, 3 Dec 2024 15:40:15 +0200 [thread overview]
Message-ID: <3f2dc65c-61e9-4d4b-9610-4b106bb691cc@tuxon.dev> (raw)
In-Reply-To: <9fbf057c-164b-4451-85a8-cf4d5807b4c1@bp.renesas.com>
Hi, Paul,
On 03.12.2024 14:53, Paul Barker wrote:
> Hi Claudiu,
>
> On 03/12/2024 11:13, Claudiu wrote:
>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>
>> All Renesas SoCs using the rzg2l_adc driver manage ADC clocks through PM
>> domains. Calling pm_runtime_{resume_and_get, put_sync}() implicitly sets
>> the state of the clocks. As a result, the code in the rzg2l_adc driver that
>> explicitly manages ADC clocks can be removed, leading to simpler and
>> cleaner implementation.
>>
>> Additionally, replace the use of rzg2l_adc_set_power() with direct PM
>> runtime API calls to further simplify and clean up the code.
>>
>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>> ---
>> drivers/iio/adc/rzg2l_adc.c | 100 ++++++++----------------------------
>> 1 file changed, 20 insertions(+), 80 deletions(-)
>>
>> diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c
>> index 7039949a7554..a17690ecbdc3 100644
>> --- a/drivers/iio/adc/rzg2l_adc.c
>> +++ b/drivers/iio/adc/rzg2l_adc.c
>> @@ -8,7 +8,6 @@
>> */
>>
>> #include <linux/bitfield.h>
>> -#include <linux/clk.h>
>> #include <linux/completion.h>
>> #include <linux/delay.h>
>> #include <linux/iio/iio.h>
>> @@ -69,8 +68,6 @@ struct rzg2l_adc_data {
>>
>> struct rzg2l_adc {
>> void __iomem *base;
>> - struct clk *pclk;
>> - struct clk *adclk;
>> struct reset_control *presetn;
>> struct reset_control *adrstn;
>> struct completion completion;
>> @@ -188,29 +185,18 @@ static int rzg2l_adc_conversion_setup(struct rzg2l_adc *adc, u8 ch)
>> return 0;
>> }
>>
>> -static int rzg2l_adc_set_power(struct iio_dev *indio_dev, bool on)
>> -{
>> - struct device *dev = indio_dev->dev.parent;
>> -
>> - if (on)
>> - return pm_runtime_resume_and_get(dev);
>> -
>> - return pm_runtime_put_sync(dev);
>> -}
>> -
>> static int rzg2l_adc_conversion(struct iio_dev *indio_dev, struct rzg2l_adc *adc, u8 ch)
>> {
>> + struct device *dev = indio_dev->dev.parent;
>> int ret;
>>
>> - ret = rzg2l_adc_set_power(indio_dev, true);
>> + ret = pm_runtime_resume_and_get(dev);
>> if (ret)
>> return ret;
>
> Should we check (ret < 0) here instead of just (ret)? According to the
> docs [1], pm_runtime_resume_and_get() can return 1 if the device is
> already active.
The v6.13-rc1 implementation of pm_runtime_resume_and_get() is:
static inline int pm_runtime_resume_and_get(struct device *dev)
{
int ret;
ret = __pm_runtime_resume(dev, RPM_GET_PUT);
if (ret < 0) {
pm_runtime_put_noidle(dev);
return ret;
}
return 0;
}
It can return zero or negative error number.
Thank you,
Claudiu
>
> [1]: https://docs.kernel.org/power/runtime_pm.html#runtime-pm-device-helper-functions
>
> Thanks,
>
next prev parent reply other threads:[~2024-12-03 13:40 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-03 11:13 [PATCH 00/14] iio: adc: rzg2l_adc: Add support for RZ/G3S Claudiu
2024-12-03 11:13 ` [PATCH 01/14] clk: renesas: r9a08g045: Add clocks, resets and power domain support for the ADC IP Claudiu
2024-12-03 11:13 ` [PATCH 02/14] iio: adc: rzg2l_adc: Use devres helpers to request pre-deasserted reset controls Claudiu
2024-12-03 19:51 ` Jonathan Cameron
2024-12-03 11:13 ` [PATCH 03/14] iio: adc: rzg2l_adc: Simplify the runtime PM code Claudiu
2024-12-03 12:53 ` Paul Barker
2024-12-03 13:40 ` Claudiu Beznea [this message]
2024-12-03 14:20 ` Paul Barker
2024-12-03 11:13 ` [PATCH 04/14] iio: adc: rzg2l_adc: Switch to RUNTIME_PM_OPS() and pm_ptr() Claudiu
2024-12-03 11:13 ` [PATCH 05/14] iio: adc: rzg2l_adc: Use read_poll_timeout() Claudiu
2024-12-03 11:13 ` [PATCH 06/14] iio: adc: rzg2l_adc: Simplify the locking scheme in rzg2l_adc_read_raw() Claudiu
2024-12-03 13:03 ` Paul Barker
2024-12-03 18:07 ` Jonathan Cameron
2024-12-03 11:13 ` [PATCH 07/14] iio: adc: rzg2l_adc: Enable runtime PM autosuspend support Claudiu
2024-12-03 20:00 ` Jonathan Cameron
2024-12-04 8:31 ` Claudiu Beznea
2024-12-04 9:09 ` Biju Das
2024-12-03 11:13 ` [PATCH 08/14] iio: adc: rzg2l_adc: Prepare for the addition of RZ/G3S support Claudiu
2024-12-03 20:09 ` Jonathan Cameron
2024-12-04 9:40 ` Geert Uytterhoeven
2024-12-07 17:37 ` Jonathan Cameron
2024-12-03 11:13 ` [PATCH 09/14] iio: adc: rzg2l_adc: Add support for channel 8 Claudiu
2024-12-03 20:18 ` Jonathan Cameron
2024-12-04 8:50 ` Claudiu Beznea
2024-12-07 17:42 ` Jonathan Cameron
2024-12-03 11:13 ` [PATCH 10/14] iio: adc: rzg2l_adc: Add suspend/resume support Claudiu
2024-12-03 11:13 ` [PATCH 11/14] dt-bindings: iio: adc: renesas,rzg2l-adc: Document RZ/G3S SoC Claudiu
2024-12-03 16:04 ` Conor Dooley
2024-12-03 11:13 ` [PATCH 12/14] iio: adc: rzg2l_adc: Add support for Renesas RZ/G3S Claudiu
2024-12-03 22:08 ` Jonathan Cameron
2024-12-03 11:13 ` [PATCH 13/14] arm64: dts: renesas: r9a08g045: Add ADC node Claudiu
2024-12-03 11:13 ` [PATCH 14/14] arm64: dts: renesas: rzg3s-smarc-som: Enable ADC Claudiu
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=3f2dc65c-61e9-4d4b-9610-4b106bb691cc@tuxon.dev \
--to=claudiu.beznea@tuxon.dev \
--cc=claudiu.beznea.uj@bp.renesas.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-clk@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=mturquette@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=paul.barker.ct@bp.renesas.com \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
/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