Re: [PATCH v2 5/5] hwmon: (ina3221) Add PM runtime support
From: Nicolin Chen
Date: Wed Oct 24 2018 - 13:57:08 EST
On Wed, Oct 24, 2018 at 09:24:18AM +0000, linux@xxxxxxxxxxxx wrote:
> > +fail:
> > + if (enable) {
> > + dev_err(dev, "Reverting channel%d enabling: %d\n",
> > + channel, ret);
>
> This message is confusing. Something like "Failed to enable channel %d:
> error %d" would be much better.
Will fix in v3.
> > +fail_pm:
> > + pm_runtime_disable(ina->hdev);
> > + pm_runtime_set_suspended(ina->hdev);
> > + for (i = 0; i < INA3221_NUM_CHANNELS; i++)
> > + pm_runtime_put_noidle(ina->hdev);
>
> The count here doesn't match the count above if some channels
> are disabled, or if the enable loop above aborted.
>
> > + /* Decrease the PM refcount */
> > + for (i = 0; i < INA3221_NUM_CHANNELS; i++)
> > + pm_runtime_put_noidle(ina->hdev);
> >
> As above, this doesn't take disabled channels into account. Maybe that
> doesn't matter; if so, there needs to be a comment indicating that
> negative use counts don't matter. If that is the case, make sure that
> this is acceptable use of the pm API (if it works but is not documented,
> the PM core may change and complain about it at a later time).
The API will stop decrease at 0. But I will see if I can explicitly
loop a matched number, or at lest will mention this in comments.
Thanks
Nicolin