linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: da9052: Synchronize access with mfd
@ 2020-05-11 11:02 Sebastian Reichel
  2020-05-11 16:51 ` Guenter Roeck
  0 siblings, 1 reply; 7+ messages in thread
From: Sebastian Reichel @ 2020-05-11 11:02 UTC (permalink / raw)
  To: Support Opensource, Jean Delvare, Guenter Roeck
  Cc: Lee Jones, linux-hwmon, linux-kernel, kernel, Samu Nuutamo,
	Sebastian Reichel

From: Samu Nuutamo <samu.nuutamo@vincit.fi>

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: 4f16cab19a3d5 ("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>
---
 drivers/hwmon/da9052-hwmon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/da9052-hwmon.c b/drivers/hwmon/da9052-hwmon.c
index 53b517dbe7e6..4af2fc309c28 100644
--- a/drivers/hwmon/da9052-hwmon.c
+++ b/drivers/hwmon/da9052-hwmon.c
@@ -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;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread
* Re: [PATCH] hwmon: da9052: Synchronize access with mfd
@ 2020-05-13 17:07 Guenter Roeck
  0 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2020-05-13 17:07 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Support Opensource, Jean Delvare, Lee Jones, linux-hwmon,
	linux-kernel, kernel, Samu Nuutamo

On Mon, May 11, 2020 at 01:02:19PM +0200, Sebastian Reichel wrote:
> From: Samu Nuutamo <samu.nuutamo@vincit.fi>
> 
> 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: 4f16cab19a3d5 ("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>

Applied.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH] hwmon: (da9052) Synchronize access with mfd
@ 2019-03-18 14:29 Samu Nuutamo
  2019-03-18 14:51 ` Guenter Roeck
  0 siblings, 1 reply; 7+ messages in thread
From: Samu Nuutamo @ 2019-03-18 14:29 UTC (permalink / raw)
  To: linux-hwmon; +Cc: Support Opensource, Jean Delvare, Guenter Roeck

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 likely 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: 4f16cab19a3d5 ("hwmon: da9052: Add support for TSI channel")
Signed-off-by: Samu Nuutamo <samu.nuutamo@vincit.fi>
---
 drivers/hwmon/da9052-hwmon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/da9052-hwmon.c b/drivers/hwmon/da9052-hwmon.c
index 8ec5bf4ce392..af136a638065 100644
--- a/drivers/hwmon/da9052-hwmon.c
+++ b/drivers/hwmon/da9052-hwmon.c
@@ -249,9 +249,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;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-05-13 17:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-11 11:02 [PATCH] hwmon: da9052: Synchronize access with mfd Sebastian Reichel
2020-05-11 16:51 ` Guenter Roeck
2020-05-12 11:31   ` Sebastian Reichel
  -- strict thread matches above, loose matches on Subject: below --
2020-05-13 17:07 Guenter Roeck
2019-03-18 14:29 [PATCH] hwmon: (da9052) " Samu Nuutamo
2019-03-18 14:51 ` Guenter Roeck
2019-03-19 13:38   ` Samu Nuutamo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).