Re: [PATCH 03/14] iio: adc: rzg2l_adc: Simplify the runtime PM code
From: Paul Barker
Date: Tue Dec 03 2024 - 09:21:22 EST
Hi Claudiu,
On 03/12/2024 13:40, Claudiu Beznea wrote:
> On 03.12.2024 14:53, Paul Barker wrote:
>> On 03/12/2024 11:13, Claudiu wrote:
>>> 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.
Ah, ok. The docs say that pm_runtime_resume_and_get() will "return the
result of pm_runtime_resume" (which can return 1), but it doesn't do
that exactly. I'll send a fix for the docs.
Thanks,
--
Paul BarkerAttachment:
OpenPGP_0x27F4B3459F002257.asc
Description: OpenPGP public key
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature