Commit 80ffc54d authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Merge tag 'iio-fixes-for-7.0c' of...

Merge tag 'iio-fixes-for-7.0c' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-linus

Jonathan writes:

IIO: 3rd set of fixes for the 7.0 cycle.

Note that this pull is in addition to the 2nd set of such fixes that are
waiting to be picked up. Absolutely fine to queue these for the merge
window if that makes more sense.

Usual mixed back of ancient issues surfacing and newer problems.

adi,ad57770r
- Stop eating an error in read_raw.
adi,adxl313
- Check return of regmap_write() instead of ignoring it in one place.
adi,adxl355
- Fix the description of the temperature channel to be unsigned rather
  than signed.
bosch,bmi160
- Avoid use of uninitialized data.
- Fix validation of small reference voltages.
hid-sensor-rotation:
- The timestamp location in this driver has unfortunately been broken for
  a long time. Given it was correct for 6 years and then broken for the
  next 6 years, use a one off hack to duplicate it in both locations.
  The issue was as a result of the unique nature of quaternion
  representation combined with large precision resulting in an
  128 bit aligned channel.
nxp,sar-adc
- Avoid leaking a dma channel.
rfdigital,rfd77402
- Close a race between reinit_completion() and the irq happening.
ti,adc161s626
- Fix up buffer handling on big endian hosts which was broken due to
  casting of pointers to different sized integers.
- Ensure a DMA safe buffer is used.
vishay,vcnl4035
- Fix up buffer handling on big endian hosts which was broken due to
  casting of pointers to different sized integers.
vishay,veml6070
- Fix return value mess up that occurred when doing a guard() conversion.

* tag 'iio-fixes-for-7.0c' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  iio: light: veml6070: fix veml6070_read() return value
  iio: adc: nxp-sar-adc: Fix DMA channel leak in trigger mode
  iio: accel: adxl313: add missing error check in predisable
  iio: dac: ad5770r: fix error return in ad5770r_read_raw()
  iio: accel: fix ADXL355 temperature signature value
  iio: light: vcnl4035: fix scan buffer on big-endian
  iio: adc: ti-adc161s626: use DMA-safe memory for spi_read()
  iio: adc: ti-adc161s626: fix buffer read on big-endian
  iio: dac: mcp47feb02: Fix Vref validation [1-999] case
  iio: imu: bmi160: Remove potential undefined behavior in bmi160_config_pin()
  iio: orientation: hid-sensor-rotation: add timestamp hack to not break userspace
  iio: proximity: rfd77402: Fix completion race condition in IRQ mode
parents 37276dd6 d0b224cf
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -998,6 +998,8 @@ static int adxl313_buffer_predisable(struct iio_dev *indio_dev)

	ret = regmap_write(data->regmap, ADXL313_REG_FIFO_CTL,
			   FIELD_PREP(ADXL313_REG_FIFO_CTL_MODE_MSK, ADXL313_FIFO_BYPASS));
	if (ret)
		return ret;

	ret = regmap_write(data->regmap, ADXL313_REG_INT_ENABLE, 0);
	if (ret)
+1 −1
Original line number Diff line number Diff line
@@ -745,7 +745,7 @@ static const struct iio_chan_spec adxl355_channels[] = {
				      BIT(IIO_CHAN_INFO_OFFSET),
		.scan_index = 3,
		.scan_type = {
			.sign = 's',
			.sign = 'u',
			.realbits = 12,
			.storagebits = 16,
			.endianness = IIO_BE,
+5 −4
Original line number Diff line number Diff line
@@ -718,6 +718,10 @@ static int nxp_sar_adc_buffer_software_do_postenable(struct iio_dev *indio_dev)
	struct nxp_sar_adc *info = iio_priv(indio_dev);
	int ret;

	info->dma_chan = dma_request_chan(indio_dev->dev.parent, "rx");
	if (IS_ERR(info->dma_chan))
		return PTR_ERR(info->dma_chan);

	nxp_sar_adc_dma_channels_enable(info, *indio_dev->active_scan_mask);

	nxp_sar_adc_dma_cfg(info, true);
@@ -738,6 +742,7 @@ static int nxp_sar_adc_buffer_software_do_postenable(struct iio_dev *indio_dev)
out_dma_channels_disable:
	nxp_sar_adc_dma_cfg(info, false);
	nxp_sar_adc_dma_channels_disable(info, *indio_dev->active_scan_mask);
	dma_release_channel(info->dma_chan);

	return ret;
}
@@ -765,10 +770,6 @@ static int nxp_sar_adc_buffer_postenable(struct iio_dev *indio_dev)
	unsigned long channel;
	int ret;

	info->dma_chan = dma_request_chan(indio_dev->dev.parent, "rx");
	if (IS_ERR(info->dma_chan))
		return PTR_ERR(info->dma_chan);

	info->channels_used = 0;

	/*
+20 −21
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include <linux/init.h>
#include <linux/err.h>
#include <linux/spi/spi.h>
#include <linux/unaligned.h>
#include <linux/iio/iio.h>
#include <linux/iio/trigger.h>
#include <linux/iio/buffer.h>
@@ -70,8 +71,7 @@ struct ti_adc_data {

	u8 read_size;
	u8 shift;

	u8 buffer[16] __aligned(IIO_DMA_MINALIGN);
	u8 buf[3] __aligned(IIO_DMA_MINALIGN);
};

static int ti_adc_read_measurement(struct ti_adc_data *data,
@@ -80,26 +80,20 @@ static int ti_adc_read_measurement(struct ti_adc_data *data,
	int ret;

	switch (data->read_size) {
	case 2: {
		__be16 buf;

		ret = spi_read(data->spi, (void *) &buf, 2);
	case 2:
		ret = spi_read(data->spi, data->buf, 2);
		if (ret)
			return ret;

		*val = be16_to_cpu(buf);
		*val = get_unaligned_be16(data->buf);
		break;
	}
	case 3: {
		__be32 buf;

		ret = spi_read(data->spi, (void *) &buf, 3);
	case 3:
		ret = spi_read(data->spi, data->buf, 3);
		if (ret)
			return ret;

		*val = be32_to_cpu(buf) >> 8;
		*val = get_unaligned_be24(data->buf);
		break;
	}
	default:
		return -EINVAL;
	}
@@ -114,15 +108,20 @@ static irqreturn_t ti_adc_trigger_handler(int irq, void *private)
	struct iio_poll_func *pf = private;
	struct iio_dev *indio_dev = pf->indio_dev;
	struct ti_adc_data *data = iio_priv(indio_dev);
	int ret;
	struct {
		s16 data;
		aligned_s64 timestamp;
	} scan = { };
	int ret, val;

	ret = ti_adc_read_measurement(data, &indio_dev->channels[0], &val);
	if (ret)
		goto exit_notify_done;

	ret = ti_adc_read_measurement(data, &indio_dev->channels[0],
				     (int *) &data->buffer);
	if (!ret)
		iio_push_to_buffers_with_timestamp(indio_dev,
					data->buffer,
					iio_get_time_ns(indio_dev));
	scan.data = val;
	iio_push_to_buffers_with_timestamp(indio_dev, &scan, iio_get_time_ns(indio_dev));

 exit_notify_done:
	iio_trigger_notify_done(indio_dev->trig);

	return IRQ_HANDLED;
+1 −1
Original line number Diff line number Diff line
@@ -322,7 +322,7 @@ static int ad5770r_read_raw(struct iio_dev *indio_dev,
				       chan->address,
				       st->transf_buf, 2);
		if (ret)
			return 0;
			return ret;

		buf16 = get_unaligned_le16(st->transf_buf);
		*val = buf16 >> 2;
Loading