diff options
author | Alec Berg <alecaberg@chromium.org> | 2014-03-19 14:50:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2014-03-22 08:19:07 -0400 |
commit | 2076a20fc1a06f7b0333c62a2bb4eeeac7ed1bcb (patch) | |
tree | b408163617acbff018322b11e39bc11def11f87c /drivers/iio/industrialio-buffer.c | |
parent | 6b9da2e77249bd62bb0902319cfa22398f32c538 (diff) |
iio: querying buffer scan_mask should return 0/1
Ensure that querying the IIO buffer scan_mask returns a value of
0 or 1. Currently querying the scan mask has the value returned
by test_bit(), which returns either true or false. For some
architectures test_bit() may return -1 for true, which will appear
to return an error when returning from iio_scan_mask_query().
Additionally, it's important for the sysfs interface to consistently
return the same thing when querying the scan_mask.
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/industrialio-buffer.c')
-rw-r--r-- | drivers/iio/industrialio-buffer.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index c67d83bdc8f0..fe25042f056a 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c | |||
@@ -165,7 +165,8 @@ static ssize_t iio_scan_el_show(struct device *dev, | |||
165 | int ret; | 165 | int ret; |
166 | struct iio_dev *indio_dev = dev_to_iio_dev(dev); | 166 | struct iio_dev *indio_dev = dev_to_iio_dev(dev); |
167 | 167 | ||
168 | ret = test_bit(to_iio_dev_attr(attr)->address, | 168 | /* Ensure ret is 0 or 1. */ |
169 | ret = !!test_bit(to_iio_dev_attr(attr)->address, | ||
169 | indio_dev->buffer->scan_mask); | 170 | indio_dev->buffer->scan_mask); |
170 | 171 | ||
171 | return sprintf(buf, "%d\n", ret); | 172 | return sprintf(buf, "%d\n", ret); |
@@ -866,7 +867,8 @@ int iio_scan_mask_query(struct iio_dev *indio_dev, | |||
866 | if (!buffer->scan_mask) | 867 | if (!buffer->scan_mask) |
867 | return 0; | 868 | return 0; |
868 | 869 | ||
869 | return test_bit(bit, buffer->scan_mask); | 870 | /* Ensure return value is 0 or 1. */ |
871 | return !!test_bit(bit, buffer->scan_mask); | ||
870 | }; | 872 | }; |
871 | EXPORT_SYMBOL_GPL(iio_scan_mask_query); | 873 | EXPORT_SYMBOL_GPL(iio_scan_mask_query); |
872 | 874 | ||