Commit c562ccbf authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Greg Kroah-Hartman

staging:iio:meter:ad7758 use iio_sw_buffer_preenable to avoid code repition

Using this generic function adds a little overhead to a slow path but
reduces the amount of code repitition in exchange.
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
Acked-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c1633187
...@@ -92,29 +92,19 @@ static irqreturn_t ade7758_trigger_handler(int irq, void *p) ...@@ -92,29 +92,19 @@ static irqreturn_t ade7758_trigger_handler(int irq, void *p)
static int ade7758_ring_preenable(struct iio_dev *indio_dev) static int ade7758_ring_preenable(struct iio_dev *indio_dev)
{ {
struct ade7758_state *st = iio_priv(indio_dev); struct ade7758_state *st = iio_priv(indio_dev);
struct iio_buffer *ring = indio_dev->buffer;
size_t d_size;
unsigned channel; unsigned channel;
int ret;
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)) if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
return -EINVAL; return -EINVAL;
ret = iio_sw_buffer_preenable(indio_dev);
if (ret < 0)
return ret;
channel = find_first_bit(indio_dev->active_scan_mask, channel = find_first_bit(indio_dev->active_scan_mask,
indio_dev->masklength); indio_dev->masklength);
d_size = st->ade7758_ring_channels[channel].scan_type.storagebits / 8;
if (ring->scan_timestamp) {
d_size += sizeof(s64);
if (d_size % sizeof(s64))
d_size += sizeof(s64) - (d_size % sizeof(s64));
}
if (indio_dev->buffer->access->set_bytes_per_datum)
indio_dev->buffer->access->
set_bytes_per_datum(indio_dev->buffer, d_size);
ade7758_write_waveform_type(&indio_dev->dev, ade7758_write_waveform_type(&indio_dev->dev,
st->ade7758_ring_channels[channel].address); st->ade7758_ring_channels[channel].address);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment