Re: [PATCH 03/14] iio: adc: rzg2l_adc: Simplify the runtime PM code

Paul Barker
2024-12-03T14:21:11Z

[-- Attachment #1.1.1: Type: text/plain, Size: 1203 bytes --]

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 Barker

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3577 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]