diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2015-05-29 18:14:20 +0200 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-06-01 11:24:57 +0100 |
commit | 629bc02331f7aae6ef775fb4c15e6d8aa58722f1 (patch) | |
tree | afc7edfc68216d3e69e66b5280af99f793c489c0 /drivers/iio/industrialio-buffer.c | |
parent | 4dcaa5f75473271ea83545eb5a95db8d7a152362 (diff) | |
download | linux-629bc02331f7aae6ef775fb4c15e6d8aa58722f1.tar.gz linux-629bc02331f7aae6ef775fb4c15e6d8aa58722f1.tar.bz2 linux-629bc02331f7aae6ef775fb4c15e6d8aa58722f1.zip |
iio: Always compute masklength
Even if no userspace consumer buffer is attached to the IIO device at
registration we still need to compute the masklength, since it is possible
that a in-kernel consumer buffer is going to get attached to the device at
a later point.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/industrialio-buffer.c')
-rw-r--r-- | drivers/iio/industrialio-buffer.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index dad61ab9b36f..209c7ad793c5 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -966,6 +966,15 @@ int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev) int ret, i, attrn, attrcount, attrcount_orig = 0; const struct iio_chan_spec *channels; + channels = indio_dev->channels; + if (channels) { + int ml = indio_dev->masklength; + + for (i = 0; i < indio_dev->num_channels; i++) + ml = max(ml, channels[i].scan_index + 1); + indio_dev->masklength = ml; + } + if (!buffer) return 0; @@ -1009,12 +1018,6 @@ int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev) if (channels[i].scan_index < 0) continue; - /* Establish necessary mask length */ - if (channels[i].scan_index > - (int)indio_dev->masklength - 1) - indio_dev->masklength - = channels[i].scan_index + 1; - ret = iio_buffer_add_channel_sysfs(indio_dev, &channels[i]); if (ret < 0) |