From: Guenter Roeck <linux@roeck-us.net>
To: Nicolin Chen <nicoleotsuka@gmail.com>
Cc: jdelvare@suse.com, linux-hwmon@vger.kernel.org,
linux-kernel@vger.kernel.org, corbet@lwn.net,
linux-doc@vger.kernel.org
Subject: Re: [PATCH] hwmon: (ina3221) Add voltage conversion time settings
Date: Wed, 17 Apr 2019 13:12:34 -0700 [thread overview]
Message-ID: <20190417201234.GA6223@roeck-us.net> (raw)
In-Reply-To: <20190417194817.GA22652@Asurada-Nvidia.nvidia.com>
On Wed, Apr 17, 2019 at 12:48:18PM -0700, Nicolin Chen wrote:
> On Wed, Apr 17, 2019 at 11:39:49AM -0700, Nicolin Chen wrote:
>
> > > Thinking about it ... does it even make sense to cache reg_config twice,
> > > or would it be better to just update the local copy and use regmap_write()
> > > to send it to the chip ?
> >
> > I remember the reason of adding the read-back was to prevent race
> > condition. But now we have mutex protections for all sysfs nodes,
> > maybe it's not necessary anymore. I will read the code carefully
> > and see if it's safe to remove it -- will do in a separate patch.
>
> I just recalled a second thought for the reason why I left them
> there as it'd logically require a copy to restore upon failure
> of regmap_write, that might not look so neat as the read-back:
>
> old_config = reg_config;
> reg_config &= mask;
> reg_config |= val;
> ret = regmap_write(reg_config);
> if (ret) {
> reg_config = old_config;
> return ret;
> }
reg = (reg_config & mask) | val;
ret = regmap_write(reg);
if (ret)
return ret;
reg_config = reg;
doesn't look that bad to me, and is much less costly.
Guenter
next prev parent reply other threads:[~2019-04-17 20:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-16 23:55 [PATCH] hwmon: (ina3221) Add voltage conversion time settings Nicolin Chen
2019-04-17 13:46 ` Guenter Roeck
2019-04-17 14:04 ` Guenter Roeck
2019-04-17 18:39 ` Nicolin Chen
2019-04-17 19:48 ` Nicolin Chen
2019-04-17 20:12 ` Guenter Roeck [this message]
2019-04-17 21:10 ` 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=20190417201234.GA6223@roeck-us.net \
--to=linux@roeck-us.net \
--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