diff options
author | Alexandru Ardelean | 2018-05-21 08:40:05 +0200 |
---|---|---|
committer | Jonathan Cameron | 2018-05-22 19:13:45 +0200 |
commit | 2636d005758928c2884ac610589f383c73919bcf (patch) | |
tree | 7326f2112232daeb0235f1453b0c4247c6af32b8 /drivers/iio/amplifiers | |
parent | tools: iio: iio_generic_buffer: allow continuous looping (diff) | |
download | kernel-qcow2-linux-2636d005758928c2884ac610589f383c73919bcf.tar.gz kernel-qcow2-linux-2636d005758928c2884ac610589f383c73919bcf.tar.xz kernel-qcow2-linux-2636d005758928c2884ac610589f383c73919bcf.zip |
iio: amplifiers: ad8366: move channel init before iio_device_register()
Otherwise a race condition can occur, where userspace can start operations
before the channels have been properly initialized.
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/amplifiers')
-rw-r--r-- | drivers/iio/amplifiers/ad8366.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c index 43667866321e..0138337aedd1 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -161,12 +161,14 @@ static int ad8366_probe(struct spi_device *spi) indio_dev->channels = ad8366_channels; indio_dev->num_channels = ARRAY_SIZE(ad8366_channels); + ret = ad8366_write(indio_dev, 0 , 0); + if (ret < 0) + goto error_disable_reg; + ret = iio_device_register(indio_dev); if (ret) goto error_disable_reg; - ad8366_write(indio_dev, 0, 0); - return 0; error_disable_reg: |