Hi Sylwester,
On Fri, May 12, 2017 at 10:57:39AM +0200, Sylwester Nawrocki wrote:
> On 05/11/2017 04:59 PM, Sakari Ailus wrote:
> >>On 05/11/2017 08:30 AM, Tomasz Figa wrote:
> [...]
> >>> rval = pm_runtime_get_sync(dev);
> >>> if (rval < 0) {
> >>> pm_runtime_put(dev);
> >>> return rval;
> >>> }
> >>Aren't we supposed to call pm_runtime_put() only when corresponding
> >>pm_runtime_get() succeeds? I think the pm_runtime_put() call above
> >>is not needed.
> >
> >pm_runtime_get() increments the usage_count independently of whether it
> >succeeded. See __pm_runtime_resume().
>
> You're right, sorry. I'd expect such things to be better covered in
> the API documentation. Probably pm_runtime_put_noidle() is a better
Well, the documentation tells what the function does. It'd be good if it
pointed that the usage count needs to be decremented if the function fails.
I guess the reason is that it's just a synchronous variant of
pm_runtime_get(), which could not handle the error anyway.
> match for just decreasing usage_count. Now many drivers appear to not
> be balancing usage_count when when pm_runtime_get_sync() fails.
Ah, quite a few drivers seem to be using pm_runtime_put_noidle() which seems
to be the correct thing to do as the device won't be on then anyway.
--
Regards,
Sakari Ailus
e-mail: [email protected] XMPP: [email protected]