mirror of
https://github.com/torvalds/linux.git
synced 2026-05-26 16:12:59 +02:00
iio: accel: adxl313: convert to guard(mutex)
Replace manual mutex_lock/mutex_unlock pair with guard(mutex) in adxl313_read_axis(). This ensures the mutex is released on all return paths and allows returning directly without a goto label. Signed-off-by: Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
9a2e1233d3
commit
c4e7372862
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
|
||||
#include <linux/bitfield.h>
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/overflow.h>
|
||||
|
|
@ -356,19 +357,15 @@ static int adxl313_read_axis(struct adxl313_data *data,
|
|||
{
|
||||
int ret;
|
||||
|
||||
mutex_lock(&data->lock);
|
||||
guard(mutex)(&data->lock);
|
||||
|
||||
ret = regmap_bulk_read(data->regmap,
|
||||
ADXL313_REG_DATA_AXIS(chan->address),
|
||||
&data->transf_buf, sizeof(data->transf_buf));
|
||||
if (ret)
|
||||
goto unlock_ret;
|
||||
return ret;
|
||||
|
||||
ret = le16_to_cpu(data->transf_buf);
|
||||
|
||||
unlock_ret:
|
||||
mutex_unlock(&data->lock);
|
||||
return ret;
|
||||
return le16_to_cpu(data->transf_buf);
|
||||
}
|
||||
|
||||
static int adxl313_read_freq_avail(struct iio_dev *indio_dev,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user