From: Guenter Roeck <linux@roeck-us.net>
To: Nicolin Chen <nicoleotsuka@gmail.com>
Cc: jdelvare@suse.com, corbet@lwn.net, afd@ti.com,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org
Subject: Re: [PATCH 2/2] hwmon: ina3221: Add enable sysfs nodes
Date: Thu, 27 Sep 2018 15:52:00 -0700 [thread overview]
Message-ID: <20180927225200.GE9198@roeck-us.net> (raw)
In-Reply-To: <20180927222614.GA8430@Asurada-Nvidia.nvidia.com>
On Thu, Sep 27, 2018 at 03:26:14PM -0700, Nicolin Chen wrote:
> On Wed, Sep 26, 2018 at 06:06:32AM -0700, Guenter Roeck wrote:
> > > +static inline bool ina3221_is_enable(struct ina3221_data *ina, int channel)
> >
> > s/is_enable/is_enabled/, maybe ?
>
> Fixing.
>
> > > + return (config & INA3221_CONFIG_CHx_EN(channel)) > 0;
> >
> > The "> 0" is unnecessary. Conversion to bool is automatic. If you want to make
> > it explicit, please use
> >
> > return !!(config & INA3221_CONFIG_CHx_EN(channel));
>
> Removing "> 0".
>
> > It should not be necessary to re-read the value from the chip all the time.
> > I would suggest to cache the value in the 'disabled' variable.
>
> Regarding this part, I added a cache before sending this one. But
> I realized if the chip got powered off and rebooted during system
> suspend/resume, the cache would not reflect the actual status. As
> I mentioned earlier, this was enlightened by your comments about
> the BIOS. So I feel it'd be safer to read the register every time
> at this point, until I add the suspend/resume feature by syncing
> with regcache. What do you think about it?
>
The proper fix for this problem would be to add support for suspend /
resume to the driver. At resume time, all channels will have been
re-enabled if the chip was powered off, even if they were explicitly
disabled by devicetree (or via explicit configuration). This means
the driver just behaves badly across suspend/resume, period.
Displaying a raw value instead of a cached one doesn't solve that
problem. By using a cached value, at least the user would not notice
that the chip no longer does what it is supposed to be doing.
I guess we just have different priorities. If I think suspend/resume
is a problem for my use case, I would just go ahead and fix it.
I would not try to write code that doesn't fix the problem causing it,
much less argue for it.
Having said that, I didn't mention that part in my other reply,
meaning I'll accept the code as is.
Thanks,
Guenter
next prev parent reply other threads:[~2018-09-27 22:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-26 6:42 [PATCH 0/2] hwmon: ina3221: Add power and enable sysfs nodes Nicolin Chen
2018-09-26 6:42 ` [PATCH 1/2] hwmon: ina3221: Add power " Nicolin Chen
2018-09-26 12:34 ` Guenter Roeck
2018-09-26 18:20 ` Nicolin Chen
2018-09-26 19:45 ` Guenter Roeck
2018-09-26 19:49 ` Nicolin Chen
2018-09-26 6:42 ` [PATCH 2/2] hwmon: ina3221: Add enable " Nicolin Chen
2018-09-26 13:06 ` Guenter Roeck
2018-09-26 18:02 ` Nicolin Chen
2018-09-26 19:58 ` Guenter Roeck
2018-09-26 20:25 ` Nicolin Chen
2018-09-26 20:44 ` Guenter Roeck
2018-09-26 21:55 ` Nicolin Chen
2018-09-27 16:05 ` Guenter Roeck
2018-09-27 18:39 ` Nicolin Chen
2018-09-27 22:26 ` Nicolin Chen
2018-09-27 22:52 ` Guenter Roeck [this message]
2018-09-27 23:14 ` Nicolin Chen
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=20180927225200.GE9198@roeck-us.net \
--to=linux@roeck-us.net \
--cc=afd@ti.com \
--cc=corbet@lwn.net \
--cc=jdelvare@suse.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicoleotsuka@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).