Skip to content

Commit

Permalink
staging:iio: Fix scan mask update
Browse files Browse the repository at this point in the history
When updating the scan mask we have to check the actual scan mask for if the
channel is already enabled, not the matching scan mask from the available
scan masks. The bit will already be set there and as a result the actual
scan mask will not get updated and the channel stays disabled.

Also fix the return value of iio_scan_el_store which would return 1 instead of
the number of bytes written if the channel was already active in the scan mask.

Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Lars-Peter Clausen authored and Greg Kroah-Hartman committed Dec 8, 2011
1 parent a1e44d6 commit 5a2a6e1
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions drivers/staging/iio/industrialio-buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static ssize_t iio_scan_el_store(struct device *dev,
error_ret:
mutex_unlock(&indio_dev->mlock);

return ret ? ret : len;
return ret < 0 ? ret : len;

}

Expand Down Expand Up @@ -625,16 +625,8 @@ int iio_scan_mask_query(struct iio_buffer *buffer, int bit)

if (!buffer->scan_mask)
return 0;
if (indio_dev->available_scan_masks)
mask = iio_scan_mask_match(indio_dev->available_scan_masks,
indio_dev->masklength,
buffer->scan_mask);
else
mask = buffer->scan_mask;
if (!mask)
return 0;

return test_bit(bit, mask);
return test_bit(bit, buffer->scan_mask);
};
EXPORT_SYMBOL_GPL(iio_scan_mask_query);

Expand Down

0 comments on commit 5a2a6e1

Please sign in to comment.