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

Commit 32b5eeca authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Greg Kroah-Hartman
Browse files

staging:iio: Switch the channel masks to bitmaps so as to allow for more channels.



This is as light as possible on changes to current drivers.
Some drivers make assumptions that their masks fit in a single
long.  Given they were previously working this is clearly valid if
not tidy.

The max1363 is an example where there should be no such assumptions.

V2: Add the new ad5933

Signed-off-by: default avatarJonathan Cameron <jic23@cam.ac.uk>
Acked-by: default avatarMichael Hennerich <Michael.Hennerich@analog.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent bd94c6a8
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -61,8 +61,9 @@ ssize_t lis3l02dq_read_accel_from_ring(struct iio_ring_buffer *ring,
	ret = ring->access->read_last(ring, (u8 *)data);
	if (ret)
		goto error_free_data;
	*val = data[bitmap_weight(&ring->scan_mask, index)];
	*val = data[bitmap_weight(ring->scan_mask, index)];
error_free_data:

	kfree(data);

	return ret;
@@ -99,7 +100,7 @@ static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array)
	mutex_lock(&st->buf_lock);

	for (i = 0; i < ARRAY_SIZE(read_all_tx_array)/4; i++)
		if (ring->scan_mask & (1 << i)) {
		if (test_bit(i, ring->scan_mask)) {
			/* lower byte */
			xfers[j].tx_buf = st->tx + 2*j;
			st->tx[2*j] = read_all_tx_array[i*4];
+3 −3
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ struct ad7192_state {
	u32				mode;
	u32				conf;
	u32				scale_avail[8][2];
	u32				available_scan_masks[9];
	long				available_scan_masks[9];
	u8				gpocon;
	u8				devid;
	/*
@@ -460,7 +460,7 @@ static int ad7192_scan_from_ring(struct ad7192_state *st, unsigned ch, int *val)
	s64 dat64[2];
	u32 *dat32 = (u32 *)dat64;

	if (!(ring->scan_mask & (1 << ch)))
	if (!(test_bit(ch, ring->scan_mask)))
		return  -EBUSY;

	ret = ring->access->read_last(ring, (u8 *) &dat64);
@@ -482,7 +482,7 @@ static int ad7192_ring_preenable(struct iio_dev *indio_dev)
	if (!ring->scan_count)
		return -EINVAL;

	channel = __ffs(ring->scan_mask);
	channel = find_first_bit(ring->scan_mask, indio_dev->masklength);

	d_size = ring->scan_count *
		 indio_dev->channels[0].scan_type.storagebits / 8;
+2 −2
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ int ad7298_scan_from_ring(struct iio_dev *dev_info, long ch)
	int ret;
	u16 *ring_data;

	if (!(ring->scan_mask & (1 << ch))) {
	if (!(test_bit(ch, ring->scan_mask))) {
		ret = -EBUSY;
		goto error_ret;
	}
@@ -79,7 +79,7 @@ static int ad7298_ring_preenable(struct iio_dev *indio_dev)
	command = AD7298_WRITE | st->ext_ref;

	for (i = 0, m = AD7298_CH(0); i < AD7298_MAX_CHAN; i++, m >>= 1)
		if (ring->scan_mask & (1 << i))
		if (test_bit(i, ring->scan_mask))
			command |= m;

	st->tx_buf[0] = cpu_to_be16(command);
+11 −7
Original line number Diff line number Diff line
@@ -51,7 +51,8 @@ struct ad7793_state {
	u16				mode;
	u16				conf;
	u32				scale_avail[8][2];
	u32				available_scan_masks[7];
	/* Note this uses fact that 8 the mask always fits in a long */
	unsigned long			available_scan_masks[7];
	/*
	 * DMA (thus cache coherency maintenance) requires the
	 * transfer buffers to live in their own cache lines.
@@ -321,7 +322,7 @@ static int ad7793_scan_from_ring(struct ad7793_state *st, unsigned ch, int *val)
	s64 dat64[2];
	u32 *dat32 = (u32 *)dat64;

	if (!(ring->scan_mask & (1 << ch)))
	if (!(test_bit(ch, ring->scan_mask)))
		return  -EBUSY;

	ret = ring->access->read_last(ring, (u8 *) &dat64);
@@ -343,7 +344,8 @@ static int ad7793_ring_preenable(struct iio_dev *indio_dev)
	if (!ring->scan_count)
		return -EINVAL;

	channel = __ffs(ring->scan_mask);
	channel = find_first_bit(ring->scan_mask,
				 indio_dev->masklength);

	d_size = ring->scan_count *
		 indio_dev->channels[0].scan_type.storagebits / 8;
@@ -875,10 +877,12 @@ static int __devinit ad7793_probe(struct spi_device *spi)
	indio_dev->num_channels = 7;
	indio_dev->info = &ad7793_info;

	for (i = 0; i < indio_dev->num_channels; i++)
		st->available_scan_masks[i] = (1 << i) | (1 <<
			indio_dev->channels[indio_dev->num_channels - 1].
			scan_index);
	for (i = 0; i < indio_dev->num_channels; i++) {
		set_bit(i, &st->available_scan_masks[i]);
		set_bit(indio_dev->
			channels[indio_dev->num_channels - 1].scan_index,
			&st->available_scan_masks[i]);
	}

	init_waitqueue_head(&st->wq_data_avail);

+2 −2
Original line number Diff line number Diff line
@@ -83,11 +83,11 @@ enum ad7887_supported_device_ids {
};

#ifdef CONFIG_IIO_RING_BUFFER
int ad7887_scan_from_ring(struct ad7887_state *st, long mask);
int ad7887_scan_from_ring(struct ad7887_state *st, int channum);
int ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev);
void ad7887_ring_cleanup(struct iio_dev *indio_dev);
#else /* CONFIG_IIO_RING_BUFFER */
static inline int ad7887_scan_from_ring(struct ad7887_state *st, long mask)
static inline int ad7887_scan_from_ring(struct ad7887_state *st, int channum)
{
	return 0;
}
Loading