drivers: iio: imu: Moved mutex lock after return function

The mutex lock will be in dead lock condition if early buffer flag
is true , to avoid that moved mutex lock after return function.

Change-Id: Ie043091533cf670494418467af5d3770e4f2471d
Signed-off-by: Puneet Yatnal <puneet@codeaurora.org>
This commit is contained in:
Puneet Yatnal 2020-04-08 21:43:34 +05:30 • committed by Gerrit - the friendly Code Review server
commit 8c27384c58
4 changed files with 5 additions and 6 deletions

View file

@ -301,9 +301,9 @@ void inv_convert_and_push_8bytes(struct inv_mpu_state *st, u16 hdr,
static void store_acc_boot_sample(struct inv_mpu_state *st, u64 t,
s16 x, s16 y, s16 z)
{
mutex_lock(&st->acc_sensor_buff);
if (false == st->acc_buffer_inv_samples)
return;
mutex_lock(&st->acc_sensor_buff);
st->timestamp.tv64 = t;
if (ktime_to_timespec(st->timestamp).tv_sec
< st->max_buffer_time) {
@ -334,10 +334,9 @@ static void store_acc_boot_sample(struct inv_mpu_state *st, u64 t,
static void store_gyro_boot_sample(struct inv_mpu_state *st, u64 t,
s16 x, s16 y, s16 z)
{
mutex_lock(&st->gyro_sensor_buff);
if (false == st->gyro_buffer_inv_samples)
return;
mutex_lock(&st->gyro_sensor_buff);
st->timestamp.tv64 = t;
if (ktime_to_timespec(st->timestamp).tv_sec
< st->max_buffer_time) {

View file

@ -200,10 +200,10 @@ static void store_acc_gyro_boot_sample(struct st_asm330lhh_sensor *sensor,
{
int x, y, z;
mutex_lock(&sensor->sensor_buff);
if (false == sensor->buffer_asm_samples)
return;
mutex_lock(&sensor->sensor_buff);
sensor->timestamp = (ktime_t)tsample;
x = iio_buf[1]<<8|iio_buf[0];
y = iio_buf[3]<<8|iio_buf[2];

View file

@ -6965,9 +6965,9 @@ static void smi130_acc_slope_interrupt_handle(struct smi130_acc_data *smi130_acc
static void store_acc_boot_sample(struct smi130_acc_data *client_data,
int x, int y, int z, struct timespec ts)
{
mutex_lock(&client_data->acc_sensor_buff);
if (false == client_data->acc_buffer_smi130_samples)
return;
mutex_lock(&client_data->acc_sensor_buff);
if (ts.tv_sec < client_data->max_buffer_time) {
if (client_data->acc_bufsample_cnt < SMI_ACC_MAXSAMPLE) {
client_data->smi130_acc_samplist[client_data->

View file

@ -1741,9 +1741,9 @@ static void smi_gyro_input_destroy(struct smi_gyro_client_data *client_data)
static void store_gyro_boot_sample(struct smi_gyro_client_data *client_data,
int x, int y, int z, struct timespec ts)
{
mutex_lock(&client_data->gyro_sensor_buff);
if (false == client_data->gyro_buffer_smi130_samples)
return;
mutex_lock(&client_data->gyro_sensor_buff);
if (ts.tv_sec < client_data->max_buffer_time) {
if (client_data->gyro_bufsample_cnt < SMI_GYRO_MAXSAMPLE) {
client_data->smi130_gyro_samplist[client_data->