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

Commit e3e6f9f6 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 minor bugs of IAM20680 sensor"

parents 719cee5d 021ce6da
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -608,6 +608,9 @@ static ssize_t inv_basic_attr_store(struct device *dev,
	struct iio_dev *indio_dev = dev_get_drvdata(dev);
	int result;

	if (inv_check_acc_gyro_early_buff_enable_flag(indio_dev))
		return count;

	mutex_lock(&indio_dev->mlock);
	result = _basic_attr_store(dev, attr, buf, count);

+15 −14
Original line number Diff line number Diff line
@@ -348,7 +348,7 @@ static int inv_acc_gyro_early_buff_init(struct iio_dev *indio_dev)
	if (!st->inv_acc_cachepool) {
		pr_err("inv_acc_cachepool cache create failed\n");
		err = -ENOMEM;
		goto clean_exit1;
		return 0;
	}

	for (i = 0; i < INV_ACC_MAXSAMPLE; i++) {
@@ -357,7 +357,7 @@ static int inv_acc_gyro_early_buff_init(struct iio_dev *indio_dev)
					GFP_KERNEL);
		if (!st->inv_acc_samplist[i]) {
			err = -ENOMEM;
			goto clean_exit2;
			goto clean_exit1;
		}
	}

@@ -367,7 +367,7 @@ static int inv_acc_gyro_early_buff_init(struct iio_dev *indio_dev)
	if (!st->inv_gyro_cachepool) {
		pr_err("inv_gyro_cachepool cache create failed\n");
		err = -ENOMEM;
		goto clean_exit3;
		goto clean_exit1;
	}

	for (i = 0; i < INV_GYRO_MAXSAMPLE; i++) {
@@ -376,7 +376,7 @@ static int inv_acc_gyro_early_buff_init(struct iio_dev *indio_dev)
					GFP_KERNEL);
		if (!st->inv_gyro_samplist[i]) {
			err = -ENOMEM;
			goto clean_exit4;
			goto clean_exit2;
		}
	}

@@ -384,7 +384,7 @@ static int inv_acc_gyro_early_buff_init(struct iio_dev *indio_dev)
	if (!st->accbuf_dev) {
		err = -ENOMEM;
		pr_err("input device allocation failed\n");
		goto clean_exit5;
		goto clean_exit2;
	}
	st->accbuf_dev->name = "inv_accbuf";
	st->accbuf_dev->id.bustype = BUS_I2C;
@@ -405,14 +405,14 @@ static int inv_acc_gyro_early_buff_init(struct iio_dev *indio_dev)
	if (err) {
		pr_err("unable to register input device %s\n",
				st->accbuf_dev->name);
		goto clean_exit5;
		goto clean_exit3;
	}

	st->gyrobuf_dev = input_allocate_device();
	if (!st->gyrobuf_dev) {
		err = -ENOMEM;
		pr_err("input device allocation failed\n");
		goto clean_exit6;
		goto clean_exit4;
	}
	st->gyrobuf_dev->name = "inv_gyrobuf";
	st->gyrobuf_dev->id.bustype = BUS_I2C;
@@ -433,7 +433,7 @@ static int inv_acc_gyro_early_buff_init(struct iio_dev *indio_dev)
	if (err) {
		pr_err("unable to register input device %s\n",
				st->gyrobuf_dev->name);
		goto clean_exit6;
		goto clean_exit5;
	}

	st->acc_buffer_inv_samples = true;
@@ -442,23 +442,24 @@ static int inv_acc_gyro_early_buff_init(struct iio_dev *indio_dev)
	inv_enable_acc_gyro(st);

	return 1;
clean_exit6:

clean_exit5:
	input_free_device(st->gyrobuf_dev);
clean_exit4:
	input_unregister_device(st->accbuf_dev);
clean_exit5:
clean_exit3:
	input_free_device(st->accbuf_dev);
clean_exit4:
clean_exit2:
	for (i = 0; i < INV_GYRO_MAXSAMPLE; i++)
		kmem_cache_free(st->inv_gyro_cachepool,
				st->inv_gyro_samplist[i]);
clean_exit3:
	kmem_cache_destroy(st->inv_gyro_cachepool);
clean_exit2:
clean_exit1:
	for (i = 0; i < INV_ACC_MAXSAMPLE; i++)
		kmem_cache_free(st->inv_acc_cachepool,
				st->inv_acc_samplist[i]);
clean_exit1:
	kmem_cache_destroy(st->inv_acc_cachepool);

	return 0;
}
static void inv_acc_gyro_input_cleanup(
+4 −6
Original line number Diff line number Diff line
@@ -249,7 +249,7 @@ static void store_acc_gyro_boot_sample(struct st_asm330lhh_sensor *sensor,
static int st_asm330lhh_read_fifo(struct st_asm330lhh_hw *hw)
{
	u8 iio_buf[ALIGN(ST_ASM330LHH_SAMPLE_SIZE, sizeof(s64)) + sizeof(s64)];
	u8 buf[6 * ST_ASM330LHH_FIFO_SAMPLE_SIZE], tag, *ptr;
	u8 buf[30 * ST_ASM330LHH_FIFO_SAMPLE_SIZE], tag, *ptr;
	s64 ts_delta_hw_ts = 0, ts_irq;
	s64 ts_delta_offs;
	int i, err, read_len, word_len, fifo_len;
@@ -374,7 +374,7 @@ ssize_t st_asm330lhh_set_watermark(struct device *dev,
	int err, val;

	if (asm330_check_acc_gyro_early_buff_enable_flag(sensor))
		return 0;
		return -EBUSY;

	mutex_lock(&iio_dev->mlock);
	if (iio_buffer_enabled(iio_dev)) {
@@ -504,10 +504,9 @@ static irqreturn_t st_asm330lhh_handler_thread(int irq, void *private)
static int st_asm330lhh_buffer_preenable(struct iio_dev *iio_dev)
{
	struct st_asm330lhh_sensor *sensor = iio_priv(iio_dev);
	int err = -1;

	if (asm330_check_acc_gyro_early_buff_enable_flag(sensor))
		return err;
		return 0;
	else
		return st_asm330lhh_update_fifo(iio_dev, true);
}
@@ -515,10 +514,9 @@ static int st_asm330lhh_buffer_preenable(struct iio_dev *iio_dev)
static int st_asm330lhh_buffer_postdisable(struct iio_dev *iio_dev)
{
	struct st_asm330lhh_sensor *sensor = iio_priv(iio_dev);
	int err = -1;

	if (asm330_check_acc_gyro_early_buff_enable_flag(sensor))
		return err;
		return 0;
	else
		return st_asm330lhh_update_fifo(iio_dev, false);
}
+36 −22
Original line number Diff line number Diff line
@@ -324,7 +324,7 @@ static int st_asm330lhh_read_oneshot(struct st_asm330lhh_sensor *sensor,
				     u8 addr, int *val)
{
	int err, delay;
	__le16 data;
	__le16 data = 0;

	if (sensor->id == ST_ASM330LHH_ID_TEMP) {
		u8 status;
@@ -841,6 +841,7 @@ static void st_asm330lhh_enable_acc_gyro(struct st_asm330lhh_hw *hw)
	struct st_asm330lhh_sensor *sensor;
	int  acc_gain = ST_ASM330LHH_ACC_FS_2G_GAIN;
	int  gyro_gain = ST_ASM330LHH_GYRO_FS_125_GAIN;
	int  delay;

	for (i = 0; i < ST_ASM330LHH_ID_MAX; i++) {
		if (!hw->iio_devs[i])
@@ -848,16 +849,29 @@ static void st_asm330lhh_enable_acc_gyro(struct st_asm330lhh_hw *hw)
		sensor = iio_priv(hw->iio_devs[i]);
		sensor->odr = 104;
		sensor->watermark = 30;
		st_asm330lhh_update_fifo(hw->iio_devs[i], false);
		delay = 1000000 / sensor->odr;

		if (sensor->id == ST_ASM330LHH_ID_ACC)
		if (sensor->id == ST_ASM330LHH_ID_ACC) {
			st_asm330lhh_set_full_scale(sensor, acc_gain);
		else if (sensor->id == ST_ASM330LHH_ID_GYRO)
			usleep_range(delay, 2 * delay);
			st_asm330lhh_set_odr(sensor, sensor->odr);
			usleep_range(delay, 2 * delay);
			st_asm330lhh_update_watermark(sensor,
					sensor->watermark);
			usleep_range(delay, 2 * delay);
			st_asm330lhh_update_fifo(hw->iio_devs[i], true);
			usleep_range(delay, 2 * delay);
		} else if (sensor->id == ST_ASM330LHH_ID_GYRO) {
			st_asm330lhh_set_full_scale(sensor, gyro_gain);

		st_asm330lhh_update_watermark(sensor, sensor->watermark);

			usleep_range(delay, 2 * delay);
			st_asm330lhh_set_odr(sensor, sensor->odr);
			usleep_range(delay, 2 * delay);
			st_asm330lhh_update_watermark(sensor,
					sensor->watermark);
			usleep_range(delay, 2 * delay);
			st_asm330lhh_update_fifo(hw->iio_devs[i], true);
			usleep_range(delay, 2 * delay);
		}
	}
}

@@ -885,7 +899,7 @@ static int asm330_acc_gyro_early_buff_init(struct st_asm330lhh_hw *hw)
		dev_err(hw->dev,
				"asm_acc_cachepool cache create failed\n");
		err = -ENOMEM;
		goto clean_exit1;
		return 0;
	}

	for (i = 0; i < ASM_MAXSAMPLE; i++) {
@@ -894,7 +908,7 @@ static int asm330_acc_gyro_early_buff_init(struct st_asm330lhh_hw *hw)
					GFP_KERNEL);
		if (!acc->asm_samplist[i]) {
			err = -ENOMEM;
			goto clean_exit2;
			goto clean_exit1;
		}
	}

@@ -905,7 +919,7 @@ static int asm330_acc_gyro_early_buff_init(struct st_asm330lhh_hw *hw)
		dev_err(hw->dev,
				"asm_gyro_cachepool cache create failed\n");
		err = -ENOMEM;
		goto clean_exit3;
		goto clean_exit1;
	}

	for (i = 0; i < ASM_MAXSAMPLE; i++) {
@@ -914,7 +928,7 @@ static int asm330_acc_gyro_early_buff_init(struct st_asm330lhh_hw *hw)
					GFP_KERNEL);
		if (!gyro->asm_samplist[i]) {
			err = -ENOMEM;
			goto clean_exit4;
			goto clean_exit2;
		}
	}

@@ -922,7 +936,7 @@ static int asm330_acc_gyro_early_buff_init(struct st_asm330lhh_hw *hw)
	if (!acc->buf_dev) {
		err = -ENOMEM;
		dev_err(hw->dev, "input device allocation failed\n");
		goto clean_exit5;
		goto clean_exit2;
	}
	acc->buf_dev->name = "asm_accbuf";
	acc->buf_dev->id.bustype = BUS_I2C;
@@ -944,14 +958,14 @@ static int asm330_acc_gyro_early_buff_init(struct st_asm330lhh_hw *hw)
		dev_err(hw->dev,
				"unable to register input device %s\n",
				acc->buf_dev->name);
		goto clean_exit5;
		goto clean_exit3;
	}

	gyro->buf_dev = input_allocate_device();
	if (!gyro->buf_dev) {
		err = -ENOMEM;
		dev_err(hw->dev, "input device allocation failed\n");
		goto clean_exit6;
		goto clean_exit4;
	}
	gyro->buf_dev->name = "asm_gyrobuf";
	gyro->buf_dev->id.bustype = BUS_I2C;
@@ -973,30 +987,30 @@ static int asm330_acc_gyro_early_buff_init(struct st_asm330lhh_hw *hw)
		dev_err(hw->dev,
				"unable to register input device %s\n",
				gyro->buf_dev->name);
		goto clean_exit6;
		goto clean_exit5;
	}

	acc->buffer_asm_samples = true;
	gyro->buffer_asm_samples = true;

	return 1;
clean_exit6:
clean_exit5:
	input_free_device(gyro->buf_dev);
clean_exit4:
	input_unregister_device(acc->buf_dev);
clean_exit5:
clean_exit3:
	input_free_device(acc->buf_dev);
clean_exit4:
clean_exit2:
	for (i = 0; i < ASM_MAXSAMPLE; i++)
		kmem_cache_free(gyro->asm_cachepool,
				gyro->asm_samplist[i]);
clean_exit3:
	kmem_cache_destroy(gyro->asm_cachepool);
clean_exit2:
clean_exit1:
	for (i = 0; i < ASM_MAXSAMPLE; i++)
		kmem_cache_free(acc->asm_cachepool,
				acc->asm_samplist[i]);
clean_exit1:
	kmem_cache_destroy(acc->asm_cachepool);

	return 0;
}
#else