Commit 4fea86da authored by Angelo Compagnucci's avatar Angelo Compagnucci Committed by Greg Kroah-Hartman

iio: adc: mcp3422: fix locking on error path

[ Upstream commit a139ffa4 ]

Reading from the chip should be unlocked on error path else the lock
could never being released.

Fixes: 07914c84 ("iio: adc: Add driver for Microchip MCP3422/3/4 high resolution ADC")
Fixes: 3f1093d8 ("iio: adc: mcp3422: fix locking scope")
Acked-by: default avatarJonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: default avatarAngelo Compagnucci <angelo.compagnucci@gmail.com>
Link: https://lore.kernel.org/r/20200901093218.1500845-1-angelo.compagnucci@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 4e8bf9d2
...@@ -146,8 +146,10 @@ static int mcp3422_read_channel(struct mcp3422 *adc, ...@@ -146,8 +146,10 @@ static int mcp3422_read_channel(struct mcp3422 *adc,
config &= ~MCP3422_PGA_MASK; config &= ~MCP3422_PGA_MASK;
config |= MCP3422_PGA_VALUE(adc->pga[req_channel]); config |= MCP3422_PGA_VALUE(adc->pga[req_channel]);
ret = mcp3422_update_config(adc, config); ret = mcp3422_update_config(adc, config);
if (ret < 0) if (ret < 0) {
mutex_unlock(&adc->lock);
return ret; return ret;
}
msleep(mcp3422_read_times[MCP3422_SAMPLE_RATE(adc->config)]); msleep(mcp3422_read_times[MCP3422_SAMPLE_RATE(adc->config)]);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment