hwmon: (ina3221) Serialize sysfs ABI accesses
authorNicolin Chen <nicoleotsuka@gmail.com>
Mon, 5 Nov 2018 20:48:41 +0000 (12:48 -0800)
committerGuenter Roeck <linux@roeck-us.net>
Sun, 16 Dec 2018 23:13:11 +0000 (15:13 -0800)
commit87625b24986bc2aeea20cf8a795b01a799a471b0
tree0ecb77de1ace9053b85d771d24d6e152fbb67b18
parentefb0489ea8fa12c6a5b51c0b3e35f4f3d5d54939
hwmon: (ina3221) Serialize sysfs ABI accesses

This change adds a mutex to serialize accesses of sysfs attributes.

This is required when polling CVRF bit of the MASK/ENABLE register
because this bit is cleared on a read of this MASK/ENABLE register
or a write to CONFIG register, which means that this bit might be
accidentally cleared by reading other fields like alert flags.

So this patch adds a mutex lock to protect the write() and read()
callbacks. The read_string() callback won't need the lock since it
just returns the label without touching any hardware register.

Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/ina3221.c