mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-23 20:53:53 +08:00
staging:iio: scrap scan_count and ensure all drivers use active_scan_mask
Obviously drivers should only use this for pushing to buffers. They need buffer->scan_mask for pulling from them post demux. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
1612244f8a
commit
550268ca11
@ -74,11 +74,11 @@ static irqreturn_t adis16201_trigger_handler(int irq, void *p)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (ring->scan_count)
|
||||
if (adis16201_read_ring_data(indio_dev, st->rx) >= 0)
|
||||
for (; i < ring->scan_count; i++)
|
||||
data[i] = be16_to_cpup(
|
||||
(__be16 *)&(st->rx[i*2]));
|
||||
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)
|
||||
&& adis16201_read_ring_data(indio_dev, st->rx) >= 0)
|
||||
for (; i < bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength); i++)
|
||||
data[i] = be16_to_cpup((__be16 *)&(st->rx[i*2]));
|
||||
|
||||
/* Guaranteed to be aligned with 8 byte boundary */
|
||||
if (ring->scan_timestamp)
|
||||
|
@ -74,11 +74,11 @@ static irqreturn_t adis16203_trigger_handler(int irq, void *p)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (ring->scan_count)
|
||||
if (adis16203_read_ring_data(&indio_dev->dev, st->rx) >= 0)
|
||||
for (; i < ring->scan_count; i++)
|
||||
data[i] = be16_to_cpup(
|
||||
(__be16 *)&(st->rx[i*2]));
|
||||
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength) &&
|
||||
adis16203_read_ring_data(&indio_dev->dev, st->rx) >= 0)
|
||||
for (; i < bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength); i++)
|
||||
data[i] = be16_to_cpup((__be16 *)&(st->rx[i*2]));
|
||||
|
||||
/* Guaranteed to be aligned with 8 byte boundary */
|
||||
if (ring->scan_timestamp)
|
||||
|
@ -71,11 +71,11 @@ static irqreturn_t adis16204_trigger_handler(int irq, void *p)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (ring->scan_count)
|
||||
if (adis16204_read_ring_data(&indio_dev->dev, st->rx) >= 0)
|
||||
for (; i < ring->scan_count; i++)
|
||||
data[i] = be16_to_cpup(
|
||||
(__be16 *)&(st->rx[i*2]));
|
||||
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength) &&
|
||||
adis16204_read_ring_data(&indio_dev->dev, st->rx) >= 0)
|
||||
for (; i < bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength); i++)
|
||||
data[i] = be16_to_cpup((__be16 *)&(st->rx[i*2]));
|
||||
|
||||
/* Guaranteed to be aligned with 8 byte boundary */
|
||||
if (ring->scan_timestamp)
|
||||
|
@ -72,9 +72,10 @@ static irqreturn_t adis16209_trigger_handler(int irq, void *p)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (ring->scan_count &&
|
||||
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength) &&
|
||||
adis16209_read_ring_data(&indio_dev->dev, st->rx) >= 0)
|
||||
for (; i < ring->scan_count; i++)
|
||||
for (; i < bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength); i++)
|
||||
data[i] = be16_to_cpup((__be16 *)&(st->rx[i*2]));
|
||||
|
||||
/* Guaranteed to be aligned with 8 byte boundary */
|
||||
|
@ -69,9 +69,10 @@ static irqreturn_t adis16240_trigger_handler(int irq, void *p)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (ring->scan_count &&
|
||||
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength) &&
|
||||
adis16240_read_ring_data(&indio_dev->dev, st->rx) >= 0)
|
||||
for (; i < ring->scan_count; i++)
|
||||
for (; i < bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength); i++)
|
||||
data[i] = be16_to_cpup((__be16 *)&(st->rx[i*2]));
|
||||
|
||||
/* Guaranteed to be aligned with 8 byte boundary */
|
||||
|
@ -87,20 +87,21 @@ static const u8 read_all_tx_array[] = {
|
||||
**/
|
||||
static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array)
|
||||
{
|
||||
struct iio_buffer *buffer = indio_dev->buffer;
|
||||
struct lis3l02dq_state *st = iio_priv(indio_dev);
|
||||
struct spi_transfer *xfers;
|
||||
struct spi_message msg;
|
||||
int ret, i, j = 0;
|
||||
|
||||
xfers = kcalloc((buffer->scan_count) * 2, sizeof(*xfers), GFP_KERNEL);
|
||||
xfers = kcalloc(bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength) * 2,
|
||||
sizeof(*xfers), GFP_KERNEL);
|
||||
if (!xfers)
|
||||
return -ENOMEM;
|
||||
|
||||
mutex_lock(&st->buf_lock);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(read_all_tx_array)/4; i++)
|
||||
if (test_bit(i, buffer->scan_mask)) {
|
||||
if (test_bit(i, indio_dev->active_scan_mask)) {
|
||||
/* lower byte */
|
||||
xfers[j].tx_buf = st->tx + 2*j;
|
||||
st->tx[2*j] = read_all_tx_array[i*4];
|
||||
@ -128,7 +129,8 @@ static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array)
|
||||
* values in alternate bytes
|
||||
*/
|
||||
spi_message_init(&msg);
|
||||
for (j = 0; j < buffer->scan_count * 2; j++)
|
||||
for (j = 0; j < bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength) * 2; j++)
|
||||
spi_message_add_tail(&xfers[j], &msg);
|
||||
|
||||
ret = spi_sync(st->us, &msg);
|
||||
@ -144,14 +146,16 @@ static int lis3l02dq_get_buffer_element(struct iio_dev *indio_dev,
|
||||
int ret, i;
|
||||
u8 *rx_array ;
|
||||
s16 *data = (s16 *)buf;
|
||||
int scan_count = bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength);
|
||||
|
||||
rx_array = kzalloc(4 * (indio_dev->buffer->scan_count), GFP_KERNEL);
|
||||
rx_array = kzalloc(4 * scan_count, GFP_KERNEL);
|
||||
if (rx_array == NULL)
|
||||
return -ENOMEM;
|
||||
ret = lis3l02dq_read_all(indio_dev, rx_array);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
for (i = 0; i < indio_dev->buffer->scan_count; i++)
|
||||
for (i = 0; i < scan_count; i++)
|
||||
data[i] = combine_8_to_16(rx_array[i*4+1],
|
||||
rx_array[i*4+3]);
|
||||
kfree(rx_array);
|
||||
@ -174,7 +178,7 @@ static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (buffer->scan_count)
|
||||
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
|
||||
len = lis3l02dq_get_buffer_element(indio_dev, data);
|
||||
|
||||
/* Guaranteed to be aligned with 8 byte boundary */
|
||||
@ -362,17 +366,17 @@ static int lis3l02dq_buffer_postenable(struct iio_dev *indio_dev)
|
||||
if (ret)
|
||||
goto error_ret;
|
||||
|
||||
if (iio_scan_mask_query(indio_dev->buffer, 0)) {
|
||||
if (test_bit(0, indio_dev->active_scan_mask)) {
|
||||
t |= LIS3L02DQ_REG_CTRL_1_AXES_X_ENABLE;
|
||||
oneenabled = true;
|
||||
} else
|
||||
t &= ~LIS3L02DQ_REG_CTRL_1_AXES_X_ENABLE;
|
||||
if (iio_scan_mask_query(indio_dev->buffer, 1)) {
|
||||
if (test_bit(1, indio_dev->active_scan_mask)) {
|
||||
t |= LIS3L02DQ_REG_CTRL_1_AXES_Y_ENABLE;
|
||||
oneenabled = true;
|
||||
} else
|
||||
t &= ~LIS3L02DQ_REG_CTRL_1_AXES_Y_ENABLE;
|
||||
if (iio_scan_mask_query(indio_dev->buffer, 2)) {
|
||||
if (test_bit(2, indio_dev->active_scan_mask)) {
|
||||
t |= LIS3L02DQ_REG_CTRL_1_AXES_Z_ENABLE;
|
||||
oneenabled = true;
|
||||
} else
|
||||
|
@ -479,12 +479,14 @@ static int ad7192_ring_preenable(struct iio_dev *indio_dev)
|
||||
size_t d_size;
|
||||
unsigned channel;
|
||||
|
||||
if (!ring->scan_count)
|
||||
if (bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
|
||||
return -EINVAL;
|
||||
|
||||
channel = find_first_bit(ring->scan_mask, indio_dev->masklength);
|
||||
channel = find_first_bit(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength);
|
||||
|
||||
d_size = ring->scan_count *
|
||||
d_size = bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength) *
|
||||
indio_dev->channels[0].scan_type.storagebits / 8;
|
||||
|
||||
if (ring->scan_timestamp) {
|
||||
@ -544,7 +546,7 @@ static irqreturn_t ad7192_trigger_handler(int irq, void *p)
|
||||
s64 dat64[2];
|
||||
s32 *dat32 = (s32 *)dat64;
|
||||
|
||||
if (ring->scan_count)
|
||||
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
|
||||
__ad7192_read_reg(st, 1, 1, AD7192_REG_DATA,
|
||||
dat32,
|
||||
indio_dev->channels[0].scan_type.realbits/8);
|
||||
|
@ -61,8 +61,9 @@ static int ad7298_ring_preenable(struct iio_dev *indio_dev)
|
||||
size_t d_size;
|
||||
int i, m;
|
||||
unsigned short command;
|
||||
|
||||
d_size = ring->scan_count * (AD7298_STORAGE_BITS / 8);
|
||||
int scan_count = bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength);
|
||||
d_size = scan_count * (AD7298_STORAGE_BITS / 8);
|
||||
|
||||
if (ring->scan_timestamp) {
|
||||
d_size += sizeof(s64);
|
||||
@ -79,7 +80,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 (test_bit(i, ring->scan_mask))
|
||||
if (test_bit(i, indio_dev->active_scan_mask))
|
||||
command |= m;
|
||||
|
||||
st->tx_buf[0] = cpu_to_be16(command);
|
||||
@ -96,7 +97,7 @@ static int ad7298_ring_preenable(struct iio_dev *indio_dev)
|
||||
spi_message_add_tail(&st->ring_xfer[0], &st->ring_msg);
|
||||
spi_message_add_tail(&st->ring_xfer[1], &st->ring_msg);
|
||||
|
||||
for (i = 0; i < ring->scan_count; i++) {
|
||||
for (i = 0; i < scan_count; i++) {
|
||||
st->ring_xfer[i + 2].rx_buf = &st->rx_buf[i];
|
||||
st->ring_xfer[i + 2].len = 2;
|
||||
st->ring_xfer[i + 2].cs_change = 1;
|
||||
@ -134,7 +135,8 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)
|
||||
&time_ns, sizeof(time_ns));
|
||||
}
|
||||
|
||||
for (i = 0; i < ring->scan_count; i++)
|
||||
for (i = 0; i < bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength); i++)
|
||||
buf[i] = be16_to_cpu(st->rx_buf[i]);
|
||||
|
||||
indio_dev->buffer->access->store_to(ring, (u8 *)buf, time_ns);
|
||||
|
@ -56,7 +56,8 @@ static int ad7476_ring_preenable(struct iio_dev *indio_dev)
|
||||
struct ad7476_state *st = iio_priv(indio_dev);
|
||||
struct iio_buffer *ring = indio_dev->buffer;
|
||||
|
||||
st->d_size = ring->scan_count *
|
||||
st->d_size = bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength) *
|
||||
st->chip_info->channel[0].scan_type.storagebits / 8;
|
||||
|
||||
if (ring->scan_timestamp) {
|
||||
|
@ -342,14 +342,15 @@ static int ad7793_ring_preenable(struct iio_dev *indio_dev)
|
||||
size_t d_size;
|
||||
unsigned channel;
|
||||
|
||||
if (!ring->scan_count)
|
||||
if (bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
|
||||
return -EINVAL;
|
||||
|
||||
channel = find_first_bit(ring->scan_mask,
|
||||
channel = find_first_bit(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength);
|
||||
|
||||
d_size = ring->scan_count *
|
||||
indio_dev->channels[0].scan_type.storagebits / 8;
|
||||
d_size = bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength) *
|
||||
indio_dev->channels[0].scan_type.storagebits / 8;
|
||||
|
||||
if (ring->scan_timestamp) {
|
||||
d_size += sizeof(s64);
|
||||
@ -411,7 +412,7 @@ static irqreturn_t ad7793_trigger_handler(int irq, void *p)
|
||||
s64 dat64[2];
|
||||
s32 *dat32 = (s32 *)dat64;
|
||||
|
||||
if (ring->scan_count)
|
||||
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
|
||||
__ad7793_read_reg(st, 1, 1, AD7793_REG_DATA,
|
||||
dat32,
|
||||
indio_dev->channels[0].scan_type.realbits/8);
|
||||
|
@ -65,7 +65,8 @@ static int ad7887_ring_preenable(struct iio_dev *indio_dev)
|
||||
struct ad7887_state *st = iio_priv(indio_dev);
|
||||
struct iio_buffer *ring = indio_dev->buffer;
|
||||
|
||||
st->d_size = ring->scan_count *
|
||||
st->d_size = bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength) *
|
||||
st->chip_info->channel[0].scan_type.storagebits / 8;
|
||||
|
||||
if (ring->scan_timestamp) {
|
||||
@ -80,7 +81,7 @@ static int ad7887_ring_preenable(struct iio_dev *indio_dev)
|
||||
set_bytes_per_datum(indio_dev->buffer, st->d_size);
|
||||
|
||||
/* We know this is a single long so can 'cheat' */
|
||||
switch (*ring->scan_mask) {
|
||||
switch (*indio_dev->active_scan_mask) {
|
||||
case (1 << 0):
|
||||
st->ring_msg = &st->msg[AD7887_CH0];
|
||||
break;
|
||||
@ -121,7 +122,8 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p)
|
||||
__u8 *buf;
|
||||
int b_sent;
|
||||
|
||||
unsigned int bytes = ring->scan_count *
|
||||
unsigned int bytes = bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength) *
|
||||
st->chip_info->channel[0].scan_type.storagebits / 8;
|
||||
|
||||
buf = kzalloc(st->d_size, GFP_KERNEL);
|
||||
|
@ -71,9 +71,10 @@ static int ad799x_ring_preenable(struct iio_dev *indio_dev)
|
||||
*/
|
||||
|
||||
if (st->id == ad7997 || st->id == ad7998)
|
||||
ad7997_8_set_scan_mode(st, *ring->scan_mask);
|
||||
ad7997_8_set_scan_mode(st, *indio_dev->active_scan_mask);
|
||||
|
||||
st->d_size = ring->scan_count * 2;
|
||||
st->d_size = bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength) * 2;
|
||||
|
||||
if (ring->scan_timestamp) {
|
||||
st->d_size += sizeof(s64);
|
||||
@ -115,12 +116,13 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p)
|
||||
case ad7991:
|
||||
case ad7995:
|
||||
case ad7999:
|
||||
cmd = st->config | (*ring->scan_mask << AD799X_CHANNEL_SHIFT);
|
||||
cmd = st->config |
|
||||
(*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT);
|
||||
break;
|
||||
case ad7992:
|
||||
case ad7993:
|
||||
case ad7994:
|
||||
cmd = (*ring->scan_mask << AD799X_CHANNEL_SHIFT) |
|
||||
cmd = (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT) |
|
||||
AD7998_CONV_RES_REG;
|
||||
break;
|
||||
case ad7997:
|
||||
@ -132,7 +134,8 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p)
|
||||
}
|
||||
|
||||
b_sent = i2c_smbus_read_i2c_block_data(st->client,
|
||||
cmd, ring->scan_count * 2, rxbuf);
|
||||
cmd, bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength) * 2, rxbuf);
|
||||
if (b_sent < 0)
|
||||
goto done;
|
||||
|
||||
|
@ -73,7 +73,6 @@ struct iio_buffer_access_funcs {
|
||||
* @bytes_per_datum: [DEVICE] size of individual datum including timestamp
|
||||
* @scan_el_attrs: [DRIVER] control of scan elements if that scan mode
|
||||
* control method is used
|
||||
* @scan_count: [INTERN] the number of elements in the current scan mode
|
||||
* @scan_mask: [INTERN] bitmask used in masking scan mode elements
|
||||
* @scan_timestamp: [INTERN] does the scan mode include a timestamp
|
||||
* @access: [DRIVER] buffer access functions associated with the
|
||||
@ -88,7 +87,6 @@ struct iio_buffer {
|
||||
int length;
|
||||
int bytes_per_datum;
|
||||
struct attribute_group *scan_el_attrs;
|
||||
int scan_count;
|
||||
long *scan_mask;
|
||||
bool scan_timestamp;
|
||||
unsigned scan_index_timestamp;
|
||||
|
@ -74,9 +74,10 @@ static irqreturn_t adis16260_trigger_handler(int irq, void *p)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (ring->scan_count &&
|
||||
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength) &&
|
||||
adis16260_read_ring_data(&indio_dev->dev, st->rx) >= 0)
|
||||
for (; i < ring->scan_count; i++)
|
||||
for (; i < bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength); i++)
|
||||
data[i] = be16_to_cpup((__be16 *)&(st->rx[i*2]));
|
||||
|
||||
/* Guaranteed to be aligned with 8 byte boundary */
|
||||
|
@ -57,7 +57,7 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)
|
||||
if (data == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
if (buffer->scan_count) {
|
||||
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)) {
|
||||
/*
|
||||
* Three common options here:
|
||||
* hardware scans: certain combinations of channels make
|
||||
@ -75,7 +75,10 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)
|
||||
* in the constant table fakedata.
|
||||
*/
|
||||
int i, j;
|
||||
for (i = 0, j = 0; i < buffer->scan_count; i++) {
|
||||
for (i = 0, j = 0;
|
||||
i < bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength);
|
||||
i++) {
|
||||
j = find_next_bit(buffer->scan_mask,
|
||||
indio_dev->masklength, j + 1);
|
||||
/* random access read form the 'device' */
|
||||
|
@ -537,14 +537,14 @@ static const struct iio_info ad5933_info = {
|
||||
static int ad5933_ring_preenable(struct iio_dev *indio_dev)
|
||||
{
|
||||
struct ad5933_state *st = iio_priv(indio_dev);
|
||||
struct iio_buffer *ring = indio_dev->buffer;
|
||||
size_t d_size;
|
||||
int ret;
|
||||
|
||||
if (!ring->scan_count)
|
||||
if (bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
|
||||
return -EINVAL;
|
||||
|
||||
d_size = ring->scan_count *
|
||||
d_size = bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength) *
|
||||
ad5933_channels[1].scan_type.storagebits / 8;
|
||||
|
||||
if (indio_dev->buffer->access->set_bytes_per_datum)
|
||||
@ -640,12 +640,14 @@ static void ad5933_work(struct work_struct *work)
|
||||
ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status);
|
||||
|
||||
if (status & AD5933_STAT_DATA_VALID) {
|
||||
int scan_count = bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength);
|
||||
ad5933_i2c_read(st->client,
|
||||
test_bit(1, ring->scan_mask) ?
|
||||
test_bit(1, indio_dev->active_scan_mask) ?
|
||||
AD5933_REG_REAL_DATA : AD5933_REG_IMAG_DATA,
|
||||
ring->scan_count * 2, (u8 *)buf);
|
||||
scan_count * 2, (u8 *)buf);
|
||||
|
||||
if (ring->scan_count == 2) {
|
||||
if (scan_count == 2) {
|
||||
buf[0] = be16_to_cpu(buf[0]);
|
||||
buf[1] = be16_to_cpu(buf[1]);
|
||||
} else {
|
||||
|
@ -79,14 +79,16 @@ static int adis16350_spi_read_all(struct device *dev, u8 *rx)
|
||||
struct spi_message msg;
|
||||
int i, j = 0, ret;
|
||||
struct spi_transfer *xfers;
|
||||
int scan_count = bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength);
|
||||
|
||||
xfers = kzalloc(sizeof(*xfers)*indio_dev->buffer->scan_count + 1,
|
||||
xfers = kzalloc(sizeof(*xfers)*(scan_count + 1),
|
||||
GFP_KERNEL);
|
||||
if (xfers == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(read_all_tx_array); i++)
|
||||
if (test_bit(i, indio_dev->buffer->scan_mask)) {
|
||||
if (test_bit(i, indio_dev->active_scan_mask)) {
|
||||
xfers[j].tx_buf = &read_all_tx_array[i];
|
||||
xfers[j].bits_per_word = 16;
|
||||
xfers[j].len = 2;
|
||||
@ -97,7 +99,7 @@ static int adis16350_spi_read_all(struct device *dev, u8 *rx)
|
||||
xfers[j].len = 2;
|
||||
|
||||
spi_message_init(&msg);
|
||||
for (j = 0; j < indio_dev->buffer->scan_count + 1; j++)
|
||||
for (j = 0; j < scan_count + 1; j++)
|
||||
spi_message_add_tail(&xfers[j], &msg);
|
||||
|
||||
ret = spi_sync(st->us, &msg);
|
||||
@ -119,26 +121,27 @@ static irqreturn_t adis16400_trigger_handler(int irq, void *p)
|
||||
s16 *data;
|
||||
size_t datasize = ring->access->get_bytes_per_datum(ring);
|
||||
/* Asumption that long is enough for maximum channels */
|
||||
unsigned long mask = *ring->scan_mask;
|
||||
|
||||
unsigned long mask = *indio_dev->active_scan_mask;
|
||||
int scan_count = bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength);
|
||||
data = kmalloc(datasize , GFP_KERNEL);
|
||||
if (data == NULL) {
|
||||
dev_err(&st->us->dev, "memory alloc failed in ring bh");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (ring->scan_count) {
|
||||
if (scan_count) {
|
||||
if (st->variant->flags & ADIS16400_NO_BURST) {
|
||||
ret = adis16350_spi_read_all(&indio_dev->dev, st->rx);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
for (; i < ring->scan_count; i++)
|
||||
for (; i < scan_count; i++)
|
||||
data[i] = *(s16 *)(st->rx + i*2);
|
||||
} else {
|
||||
ret = adis16400_spi_read_burst(&indio_dev->dev, st->rx);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
for (; i < indio_dev->buffer->scan_count; i++) {
|
||||
for (; i < scan_count; i++) {
|
||||
j = __ffs(mask);
|
||||
mask &= ~(1 << j);
|
||||
data[i] = be16_to_cpup(
|
||||
|
@ -138,7 +138,6 @@ static ssize_t iio_scan_el_show(struct device *dev,
|
||||
static int iio_scan_mask_clear(struct iio_buffer *buffer, int bit)
|
||||
{
|
||||
clear_bit(bit, buffer->scan_mask);
|
||||
buffer->scan_count--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -609,7 +608,6 @@ int iio_scan_mask_set(struct iio_buffer *buffer, int bit)
|
||||
}
|
||||
}
|
||||
bitmap_copy(buffer->scan_mask, trialmask, indio_dev->masklength);
|
||||
buffer->scan_count++;
|
||||
|
||||
kfree(trialmask);
|
||||
|
||||
|
@ -67,7 +67,7 @@ static irqreturn_t ade7758_trigger_handler(int irq, void *p)
|
||||
s64 dat64[2];
|
||||
u32 *dat32 = (u32 *)dat64;
|
||||
|
||||
if (ring->scan_count)
|
||||
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
|
||||
if (ade7758_spi_read_burst(&indio_dev->dev) >= 0)
|
||||
*dat32 = get_unaligned_be32(&st->rx_buf[5]) & 0xFFFFFF;
|
||||
|
||||
@ -96,10 +96,11 @@ static int ade7758_ring_preenable(struct iio_dev *indio_dev)
|
||||
size_t d_size;
|
||||
unsigned channel;
|
||||
|
||||
if (!ring->scan_count)
|
||||
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
|
||||
return -EINVAL;
|
||||
|
||||
channel = find_first_bit(ring->scan_mask, indio_dev->masklength);
|
||||
channel = find_first_bit(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength);
|
||||
|
||||
d_size = st->ade7758_ring_channels[channel].scan_type.storagebits / 8;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user