Commit 54732a53 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Merge tag 'iio-fixes-5.13b-take2' of...

Merge tag 'iio-fixes-5.13b-take2' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus

Jonathan writes:

Second set of IIO fixes for the 5.13 cycle

A mixed bag of fixes for various drivers.
Changes since take 1: Fixed a ; in a tag.

adi,ad7124
 - Fix miss balanced regulator enable / disable in error path
 - Fix potential overflow with non sequential channel numbers from dt.
adi,ad7192
 - Avoid disabling clock that was never enabled in error path + remove
 - Avoid nasty corner case if regulator voltage is 0 that would result
   in a good return half way through probe.
adi,ad7746
 - Avoid overwriting num_channels just after setting it correctly.
adi,ad7768
 - Buffer passed to iio_push_to_buffers_with_timestamp() too small and
   not aligned appropriately.
adi,ad7793
 - Missing return code setting in an error path.
adi,ad7923
 - Buffer too small after support for more channels added.
adi,ad5770r
 - Missing fwnode_handle_put in error paths.
fsl,fxa21002c
 - Missing runtime pm put in error path.

* tag 'iio-fixes-5.13b-take2' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  iio: adc: ad7793: Add missing error code in ad7793_setup()
  iio: adc: ad7923: Fix undersized rx buffer.
  iio: adc: ad7768-1: Fix too small buffer passed to iio_push_to_buffers_with_timestamp()
  iio: dac: ad5770r: Put fwnode in error case during ->probe()
  iio: gyro: fxas21002c: balance runtime power in error path
  staging: iio: cdc: ad7746: avoid overwrite of num_channels
  iio: adc: ad7192: handle regulator voltage error first
  iio: adc: ad7192: Avoid disabling a clock that was never enabled.
  iio: adc: ad7124: Fix potential overflow due to non sequential channel numbers
  iio: adc: ad7124: Fix missbalanced regulator enable / disable on error.
parents e0112a7c 4ed243b1
Loading
Loading
Loading
Loading
+20 −16
Original line number Diff line number Diff line
@@ -771,6 +771,13 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
		if (ret)
			goto err;

		if (channel >= indio_dev->num_channels) {
			dev_err(indio_dev->dev.parent,
				"Channel index >= number of channels\n");
			ret = -EINVAL;
			goto err;
		}

		ret = of_property_read_u32_array(child, "diff-channels",
						 ain, 2);
		if (ret)
@@ -850,6 +857,11 @@ static int ad7124_setup(struct ad7124_state *st)
	return ret;
}

static void ad7124_reg_disable(void *r)
{
	regulator_disable(r);
}

static int ad7124_probe(struct spi_device *spi)
{
	const struct ad7124_chip_info *info;
@@ -895,17 +907,20 @@ static int ad7124_probe(struct spi_device *spi)
		ret = regulator_enable(st->vref[i]);
		if (ret)
			return ret;

		ret = devm_add_action_or_reset(&spi->dev, ad7124_reg_disable,
					       st->vref[i]);
		if (ret)
			return ret;
	}

	st->mclk = devm_clk_get(&spi->dev, "mclk");
	if (IS_ERR(st->mclk)) {
		ret = PTR_ERR(st->mclk);
		goto error_regulator_disable;
	}
	if (IS_ERR(st->mclk))
		return PTR_ERR(st->mclk);

	ret = clk_prepare_enable(st->mclk);
	if (ret < 0)
		goto error_regulator_disable;
		return ret;

	ret = ad7124_soft_reset(st);
	if (ret < 0)
@@ -935,11 +950,6 @@ static int ad7124_probe(struct spi_device *spi)
	ad_sd_cleanup_buffer_and_trigger(indio_dev);
error_clk_disable_unprepare:
	clk_disable_unprepare(st->mclk);
error_regulator_disable:
	for (i = ARRAY_SIZE(st->vref) - 1; i >= 0; i--) {
		if (!IS_ERR_OR_NULL(st->vref[i]))
			regulator_disable(st->vref[i]);
	}

	return ret;
}
@@ -948,17 +958,11 @@ static int ad7124_remove(struct spi_device *spi)
{
	struct iio_dev *indio_dev = spi_get_drvdata(spi);
	struct ad7124_state *st = iio_priv(indio_dev);
	int i;

	iio_device_unregister(indio_dev);
	ad_sd_cleanup_buffer_and_trigger(indio_dev);
	clk_disable_unprepare(st->mclk);

	for (i = ARRAY_SIZE(st->vref) - 1; i >= 0; i--) {
		if (!IS_ERR_OR_NULL(st->vref[i]))
			regulator_disable(st->vref[i]);
	}

	return 0;
}

+10 −9
Original line number Diff line number Diff line
@@ -912,7 +912,7 @@ static int ad7192_probe(struct spi_device *spi)
{
	struct ad7192_state *st;
	struct iio_dev *indio_dev;
	int ret, voltage_uv = 0;
	int ret;

	if (!spi->irq) {
		dev_err(&spi->dev, "no IRQ?\n");
@@ -949,15 +949,12 @@ static int ad7192_probe(struct spi_device *spi)
		goto error_disable_avdd;
	}

	voltage_uv = regulator_get_voltage(st->avdd);

	if (voltage_uv > 0) {
		st->int_vref_mv = voltage_uv / 1000;
	} else {
		ret = voltage_uv;
	ret = regulator_get_voltage(st->avdd);
	if (ret < 0) {
		dev_err(&spi->dev, "Device tree error, reference voltage undefined\n");
		goto error_disable_avdd;
	}
	st->int_vref_mv = ret / 1000;

	spi_set_drvdata(spi, indio_dev);
	st->chip_info = of_device_get_match_data(&spi->dev);
@@ -1014,6 +1011,8 @@ static int ad7192_probe(struct spi_device *spi)
	return 0;

error_disable_clk:
	if (st->clock_sel == AD7192_CLK_EXT_MCLK1_2 ||
	    st->clock_sel == AD7192_CLK_EXT_MCLK2)
		clk_disable_unprepare(st->mclk);
error_remove_trigger:
	ad_sd_cleanup_buffer_and_trigger(indio_dev);
@@ -1031,6 +1030,8 @@ static int ad7192_remove(struct spi_device *spi)
	struct ad7192_state *st = iio_priv(indio_dev);

	iio_device_unregister(indio_dev);
	if (st->clock_sel == AD7192_CLK_EXT_MCLK1_2 ||
	    st->clock_sel == AD7192_CLK_EXT_MCLK2)
		clk_disable_unprepare(st->mclk);
	ad_sd_cleanup_buffer_and_trigger(indio_dev);

+6 −2
Original line number Diff line number Diff line
@@ -167,6 +167,10 @@ struct ad7768_state {
	 * transfer buffers to live in their own cache lines.
	 */
	union {
		struct {
			__be32 chan;
			s64 timestamp;
		} scan;
		__be32 d32;
		u8 d8[2];
	} data ____cacheline_aligned;
@@ -469,11 +473,11 @@ static irqreturn_t ad7768_trigger_handler(int irq, void *p)

	mutex_lock(&st->lock);

	ret = spi_read(st->spi, &st->data.d32, 3);
	ret = spi_read(st->spi, &st->data.scan.chan, 3);
	if (ret < 0)
		goto err_unlock;

	iio_push_to_buffers_with_timestamp(indio_dev, &st->data.d32,
	iio_push_to_buffers_with_timestamp(indio_dev, &st->data.scan,
					   iio_get_time_ns(indio_dev));

	iio_trigger_notify_done(indio_dev->trig);
+1 −0
Original line number Diff line number Diff line
@@ -279,6 +279,7 @@ static int ad7793_setup(struct iio_dev *indio_dev,
	id &= AD7793_ID_MASK;

	if (id != st->chip_info->id) {
		ret = -ENODEV;
		dev_err(&st->sd.spi->dev, "device ID query failed\n");
		goto out;
	}
+3 −1
Original line number Diff line number Diff line
@@ -59,8 +59,10 @@ struct ad7923_state {
	/*
	 * DMA (thus cache coherency maintenance) requires the
	 * transfer buffers to live in their own cache lines.
	 * Ensure rx_buf can be directly used in iio_push_to_buffers_with_timetamp
	 * Length = 8 channels + 4 extra for 8 byte timestamp
	 */
	__be16				rx_buf[4] ____cacheline_aligned;
	__be16				rx_buf[12] ____cacheline_aligned;
	__be16				tx_buf[4];
};

Loading