Commit a71654af authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Jonathan Cameron
Browse files

iio: inv_mpu6050: Make interrupt optional



The inv_mpu6050 driver requires an interrupt for buffered capture. But non
buffered reading for measurements works just fine without an interrupt
connected.

Make the interrupt optional to support this case.

Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Acked-by: default avatarJean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20210325131046.13383-2-lars@metafoo.de


Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 0d41da03
Loading
Loading
Loading
Loading
+32 −19
Original line number Diff line number Diff line
@@ -1458,6 +1458,7 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
		st->plat_data = *pdata;
	}

	if (irq > 0) {
		desc = irq_get_irq_data(irq);
		if (!desc) {
			dev_err(dev, "Could not find IRQ %d\n", irq);
@@ -1467,6 +1468,11 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
		irq_type = irqd_get_trigger_type(desc);
		if (!irq_type)
			irq_type = IRQF_TRIGGER_RISING;
	} else {
		/* Doesn't really matter, use the default */
		irq_type = IRQF_TRIGGER_RISING;
	}

	if (irq_type & IRQF_TRIGGER_RISING)	// rising or both-edge
		st->irq_mask = INV_MPU6050_ACTIVE_HIGH;
	else if (irq_type == IRQF_TRIGGER_FALLING)
@@ -1592,6 +1598,11 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,

	indio_dev->info = &mpu_info;

	if (irq > 0) {
		/*
		 * The driver currently only supports buffered capture with its
		 * own trigger. So no IRQ, no trigger, no buffer
		 */
		result = devm_iio_triggered_buffer_setup(dev, indio_dev,
							 iio_pollfunc_store_time,
							 inv_mpu6050_read_fifo,
@@ -1600,11 +1611,13 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
			dev_err(dev, "configure buffer fail %d\n", result);
			return result;
		}

		result = inv_mpu6050_probe_trigger(indio_dev, irq_type);
		if (result) {
			dev_err(dev, "trigger probe fail %d\n", result);
			return result;
		}
	}

	result = devm_iio_device_register(dev, indio_dev);
	if (result) {