On Mon, Nov 12, 2018 at 08:31:22PM -0800, Guenter Roeck wrote: > On Mon, Nov 12, 2018 at 08:23:24PM -0800, Nicolin Chen wrote: > > The shunt resistor values are used to calculate shunt voltages > > and currents. As a part of sysfs nodes, it would be better to > > get protected with the same mutex too as other sysfs ABI nodes, > > although this is not very critical because the mutex was added > > to mainly protect register access. > > > > So this patch adds the mutex lock to protect the shunt node. > > > > I am missing something here. I don't see the point of this mutex. > It just reads a variable and reports the result. When setting, > it just writes a value. Protecting the conversion of the passed > value with a mutex is pointless. Protecting writing the value > against reading it is just as pointless. The penalty here is that the resistor value would be mismatched between here and the ongoing calculation when a race happens to the sysfs accesses. But I feel it might not be really that hurt to allow it happen. Let's just drop it then: the mutex was used to protect register read/writes any way. Thanks Nicolin