Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ef8bbb0 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "drivers: iio: imu: Fixed null pointer issue when early buffer disabled"

parents 9b68f264 b3ecfb8c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -301,6 +301,7 @@ 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;
	st->timestamp.tv64 = t;
@@ -328,11 +329,13 @@ static void store_acc_boot_sample(struct inv_mpu_state *st, u64 t,
					st->acc_bufsample_cnt);
		st->acc_buffer_inv_samples = false;
	}
	mutex_unlock(&st->acc_sensor_buff);
}
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;
	st->timestamp.tv64 = t;
@@ -360,6 +363,7 @@ static void store_gyro_boot_sample(struct inv_mpu_state *st, u64 t,
					st->gyro_bufsample_cnt);
		st->gyro_buffer_inv_samples = false;
	}
	mutex_unlock(&st->gyro_sensor_buff);
}
#else
static void store_acc_boot_sample(struct inv_mpu_state *st, u64 t,
@@ -383,9 +387,7 @@ int inv_push_special_8bytes_buffer(struct inv_mpu_state *st,
	memcpy(&buf[2], &d[0], sizeof(d[0]));
	for (j = 0; j < 2; j++)
		memcpy(&buf[4 + j * 2], &d[j + 1], sizeof(d[j]));
	mutex_lock(&st->gyro_sensor_buff);
	store_gyro_boot_sample(st, t, d[0], d[1], d[2]);
	mutex_unlock(&st->gyro_sensor_buff);
	iio_push_to_buffers(indio_dev, buf);
	inv_push_timestamp(indio_dev, t);

@@ -476,9 +478,7 @@ int inv_push_8bytes_buffer(struct inv_mpu_state *st, u16 sensor, u64 t, s16 *d)
				for (j = 0; j < 2; j++)
					memcpy(&buf[4 + j * 2], &d[j + 1],
					       sizeof(d[j]));
				mutex_lock(&st->acc_sensor_buff);
				store_acc_boot_sample(st, t, d[0], d[1], d[2]);
				mutex_unlock(&st->acc_sensor_buff);
				iio_push_to_buffers(indio_dev, buf);
				inv_push_timestamp(indio_dev, t);
				st->sensor_l[ii].counter = 0;
+1 −1
Original line number Diff line number Diff line
@@ -181,7 +181,6 @@ struct st_asm330lhh_sensor {
	u16 watermark;
	u8 batch_mask;
	u8 batch_addr;
	struct mutex sensor_buff;
#ifdef CONFIG_ENABLE_ASM_ACC_GYRO_BUFFERING
	bool read_boot_sample;
	int bufsample_cnt;
@@ -192,6 +191,7 @@ struct st_asm330lhh_sensor {
	int max_buffer_time;
	struct input_dev *buf_dev;
	int report_evt_cnt;
	struct mutex sensor_buff;
#endif
};

+2 −2
Original line number Diff line number Diff line
@@ -200,6 +200,7 @@ 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;

@@ -225,6 +226,7 @@ static void store_acc_gyro_boot_sample(struct st_asm330lhh_sensor *sensor,
				sensor->id, sensor->bufsample_cnt);
		sensor->buffer_asm_samples = false;
	}
	mutex_unlock(&sensor->sensor_buff);
}
#else
static void store_acc_gyro_boot_sample(struct st_asm330lhh_sensor *sensor,
@@ -337,10 +339,8 @@ static int st_asm330lhh_read_fifo(struct st_asm330lhh_hw *hw)
				iio_push_to_buffers_with_timestamp(iio_dev,
								   iio_buf,
								   hw->tsample);
				mutex_lock(&sensor->sensor_buff);
				store_acc_gyro_boot_sample(sensor,
						iio_buf, hw->tsample);
				mutex_unlock(&sensor->sensor_buff);
			}
		}
		read_len += word_len;
+2 −2
Original line number Diff line number Diff line
@@ -6965,6 +6965,7 @@ 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;
	if (ts.tv_sec <  client_data->max_buffer_time) {
@@ -6989,6 +6990,7 @@ static void store_acc_boot_sample(struct smi130_acc_data *client_data,
			smi130_acc_set_mode(client_data->smi130_acc_client,
					SMI_ACC2X2_MODE_SUSPEND, 1);
	}
	mutex_unlock(&client_data->acc_sensor_buff);
}
#else
static void store_acc_boot_sample(struct smi130_acc_data *client_data,
@@ -7145,9 +7147,7 @@ static irqreturn_t smi130_acc_irq_work_func(int irq, void *handle)
		smi130_acc->value = acc;
		mutex_unlock(&smi130_acc->value_mutex);
	}
	mutex_lock(&smi130_acc->acc_sensor_buff);
	store_acc_boot_sample(smi130_acc, acc.x, acc.y, acc.z, ts);
	mutex_unlock(&smi130_acc->acc_sensor_buff);

	smi130_set_cpu_idle_state(false);
	return IRQ_HANDLED;
+2 −2
Original line number Diff line number Diff line
@@ -1741,6 +1741,7 @@ 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;
	if (ts.tv_sec <  client_data->max_buffer_time) {
@@ -1766,6 +1767,7 @@ static void store_gyro_boot_sample(struct smi_gyro_client_data *client_data,
			smi130_gyro_delay(5);
		}
	}
	mutex_unlock(&client_data->gyro_sensor_buff);
}
#else
static void store_gyro_boot_sample(struct smi_gyro_client_data *client_data,
@@ -1918,10 +1920,8 @@ static irqreturn_t smi130_gyro_irq_work_func(int irq, void *handle)
	input_event(client_data->input, EV_MSC,
		MSC_SCAN, gyro_data.dataz);
	input_sync(client_data->input);
	mutex_lock(&client_data->gyro_sensor_buff);
	store_gyro_boot_sample(client_data, gyro_data.datax,
			gyro_data.datay, gyro_data.dataz, ts);
	mutex_unlock(&client_data->gyro_sensor_buff);
	return IRQ_HANDLED;
}