lkml.org 
[lkml]   [2019]   [Apr]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] hwmon: (ina3221) Add voltage conversion time settings
On Wed, Apr 17, 2019 at 01:12:34PM -0700, Guenter Roeck wrote:
> 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.

Okay. Will submit a change. Thanks

\
 
 \ /
  Last update: 2019-04-17 23:11    [W:0.049 / U:0.768 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site