aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelo Compagnucci <[email protected]>2020-09-01 11:32:18 +0200
committerGreg Kroah-Hartman <[email protected]>2020-09-01 16:08:07 +0200
commita139ffa40f0c24b753838b8ef3dcf6ad10eb7854 (patch)
tree69c32eccfa282473ca3d067aa16a8b6cdbb9f45a
parentc96711e138444d37d6d8b3f0fa7f09e4917cd326 (diff)
iio: adc: mcp3422: fix locking on error path
Reading from the chip should be unlocked on error path else the lock could never being released. Fixes: 07914c84ba30 ("iio: adc: Add driver for Microchip MCP3422/3/4 high resolution ADC") Fixes: 3f1093d83d71 ("iio: adc: mcp3422: fix locking scope") Acked-by: Jonathan Cameron <[email protected]> Signed-off-by: Angelo Compagnucci <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r--drivers/iio/adc/mcp3422.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c
index 219adac2384b..da353dcb1e9d 100644
--- a/drivers/iio/adc/mcp3422.c
+++ b/drivers/iio/adc/mcp3422.c
@@ -143,8 +143,10 @@ static int mcp3422_read_channel(struct mcp3422 *adc,
config &= ~MCP3422_PGA_MASK;
config |= MCP3422_PGA_VALUE(adc->pga[req_channel]);
ret = mcp3422_update_config(adc, config);
- if (ret < 0)
+ if (ret < 0) {
+ mutex_unlock(&adc->lock);
return ret;
+ }
msleep(mcp3422_read_times[MCP3422_SAMPLE_RATE(adc->config)]);
}