staging:iio:accel:sca3000 Tidy up probe order to avoid a race.
Previously the device was exposed to userspace and in kernel consumers before the interrupts had been configured. As nothing stopped them being enabled in the interval this could cause unhandled interrupts. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
7ab9fa0052
commit
9a4936dc89
|
@ -1440,9 +1440,6 @@ static int sca3000_probe(struct spi_device *spi)
|
||||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||||
|
|
||||||
sca3000_configure_ring(indio_dev);
|
sca3000_configure_ring(indio_dev);
|
||||||
ret = iio_device_register(indio_dev);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (spi->irq) {
|
if (spi->irq) {
|
||||||
ret = request_threaded_irq(spi->irq,
|
ret = request_threaded_irq(spi->irq,
|
||||||
|
@ -1452,7 +1449,7 @@ static int sca3000_probe(struct spi_device *spi)
|
||||||
"sca3000",
|
"sca3000",
|
||||||
indio_dev);
|
indio_dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error_unregister_dev;
|
return ret;
|
||||||
}
|
}
|
||||||
indio_dev->setup_ops = &sca3000_ring_setup_ops;
|
indio_dev->setup_ops = &sca3000_ring_setup_ops;
|
||||||
ret = sca3000_clean_setup(st);
|
ret = sca3000_clean_setup(st);
|
||||||
|
@ -1463,13 +1460,12 @@ static int sca3000_probe(struct spi_device *spi)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error_free_irq;
|
goto error_free_irq;
|
||||||
|
|
||||||
return 0;
|
return iio_device_register(indio_dev);
|
||||||
|
|
||||||
error_free_irq:
|
error_free_irq:
|
||||||
if (spi->irq)
|
if (spi->irq)
|
||||||
free_irq(spi->irq, indio_dev);
|
free_irq(spi->irq, indio_dev);
|
||||||
error_unregister_dev:
|
|
||||||
iio_device_unregister(indio_dev);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1496,11 +1492,13 @@ static int sca3000_remove(struct spi_device *spi)
|
||||||
struct iio_dev *indio_dev = spi_get_drvdata(spi);
|
struct iio_dev *indio_dev = spi_get_drvdata(spi);
|
||||||
struct sca3000_state *st = iio_priv(indio_dev);
|
struct sca3000_state *st = iio_priv(indio_dev);
|
||||||
|
|
||||||
|
iio_device_unregister(indio_dev);
|
||||||
|
|
||||||
/* Must ensure no interrupts can be generated after this! */
|
/* Must ensure no interrupts can be generated after this! */
|
||||||
sca3000_stop_all_interrupts(st);
|
sca3000_stop_all_interrupts(st);
|
||||||
if (spi->irq)
|
if (spi->irq)
|
||||||
free_irq(spi->irq, indio_dev);
|
free_irq(spi->irq, indio_dev);
|
||||||
iio_device_unregister(indio_dev);
|
|
||||||
sca3000_unconfigure_ring(indio_dev);
|
sca3000_unconfigure_ring(indio_dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue