提交 6b2e7589 编写于 作者: A Alison Schofield 提交者: Jonathan Cameron

iio: proximity: sx9500: claim direct mode during raw proximity reads

Driver was checking for direct mode but not locking it.  Use the
claim/release helper functions to guarantee the device stays in
direct mode during raw reads of proximity data.
Signed-off-by: NAlison Schofield <amsfield22@gmail.com>
Reviewed-by: NVlad Dogaru <ddvlad@gmail.com>
Signed-off-by: NJonathan Cameron <jic23@kernel.org>
上级 80dea21f
...@@ -387,14 +387,18 @@ static int sx9500_read_raw(struct iio_dev *indio_dev, ...@@ -387,14 +387,18 @@ static int sx9500_read_raw(struct iio_dev *indio_dev,
int *val, int *val2, long mask) int *val, int *val2, long mask)
{ {
struct sx9500_data *data = iio_priv(indio_dev); struct sx9500_data *data = iio_priv(indio_dev);
int ret;
switch (chan->type) { switch (chan->type) {
case IIO_PROXIMITY: case IIO_PROXIMITY:
switch (mask) { switch (mask) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
if (iio_buffer_enabled(indio_dev)) ret = iio_device_claim_direct_mode(indio_dev);
return -EBUSY; if (ret)
return sx9500_read_proximity(data, chan, val); return ret;
ret = sx9500_read_proximity(data, chan, val);
iio_device_release_direct_mode(indio_dev);
return ret;
case IIO_CHAN_INFO_SAMP_FREQ: case IIO_CHAN_INFO_SAMP_FREQ:
return sx9500_read_samp_freq(data, val, val2); return sx9500_read_samp_freq(data, val, val2);
default: default:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册