]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
iio: amplifiers: ad8366: move channel init before iio_device_register()
authorAlexandru Ardelean <alexandru.ardelean@analog.com>
Mon, 21 May 2018 06:40:05 +0000 (09:40 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 22 May 2018 17:13:45 +0000 (18:13 +0100)
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>
drivers/iio/amplifiers/ad8366.c

index 43667866321e3470d76ad8ada94fff7dada63a5f..0138337aedd10d52660a42fdcc333dfe9ac169dd 100644 (file)
@@ -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: