Skip to content

Commit

Permalink
hwmon: (da9052) Synchronize access with mfd
Browse files Browse the repository at this point in the history
When tsi-as-adc is configured it is possible for in7[0123]_input read to
return an incorrect value if a concurrent read to in[456]_input is
performed. This is caused by a concurrent manipulation of the mux
channel without proper locking as hwmon and mfd use different locks for
synchronization.

Switch hwmon to use the same lock as mfd when accessing the TSI channel.

Fixes: 4f16cab ("hwmon: da9052: Add support for TSI channel")
Signed-off-by: Samu Nuutamo <samu.nuutamo@vincit.fi>
[rebase to current master, reword commit message slightly]
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
Samu Nuutamo authored and Guenter Roeck committed May 13, 2020
1 parent 7b2fd27 commit 333e22d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/hwmon/da9052-hwmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ static ssize_t da9052_tsi_show(struct device *dev,
int channel = to_sensor_dev_attr(devattr)->index;
int ret;

mutex_lock(&hwmon->hwmon_lock);
mutex_lock(&hwmon->da9052->auxadc_lock);
ret = __da9052_read_tsi(dev, channel);
mutex_unlock(&hwmon->hwmon_lock);
mutex_unlock(&hwmon->da9052->auxadc_lock);

if (ret < 0)
return ret;
Expand Down

0 comments on commit 333e22d

Please sign in to comment.