Message ID | 20180521064005.17637-1-alexandru.ardelean@analog.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Patch looks good, but remember to put the maintainer and reviewers on the recipient list. Otherwise there is a risk that the patch gets lost. On 05/21/2018 08:40 AM, Alexandru Ardelean wrote: > 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> > --- > drivers/iio/amplifiers/ad8366.c | 6 ++++-- > 1 file 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: > -- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Mon, 21 May 2018 17:10:00 +0200 Lars-Peter Clausen <lars@metafoo.de> wrote: > Patch looks good, but remember to put the maintainer and reviewers on the > recipient list. Otherwise there is a risk that the patch gets lost. > > On 05/21/2018 08:40 AM, Alexandru Ardelean wrote: > > 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> Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > > --- > > drivers/iio/amplifiers/ad8366.c | 6 ++++-- > > 1 file 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: > > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-iio" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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:
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> --- drivers/iio/amplifiers/ad8366.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)