|
@@ -1135,11 +1135,9 @@ static int sca3000_probe(struct spi_device *spi)
|
|
|
struct sca3000_state *st;
|
|
|
struct iio_dev *indio_dev;
|
|
|
|
|
|
- indio_dev = iio_device_alloc(sizeof(*st));
|
|
|
- if (indio_dev == NULL) {
|
|
|
- ret = -ENOMEM;
|
|
|
- goto error_ret;
|
|
|
- }
|
|
|
+ indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
|
|
|
+ if (!indio_dev)
|
|
|
+ return -ENOMEM;
|
|
|
|
|
|
st = iio_priv(indio_dev);
|
|
|
spi_set_drvdata(spi, indio_dev);
|
|
@@ -1162,7 +1160,7 @@ static int sca3000_probe(struct spi_device *spi)
|
|
|
sca3000_configure_ring(indio_dev);
|
|
|
ret = iio_device_register(indio_dev);
|
|
|
if (ret < 0)
|
|
|
- goto error_free_dev;
|
|
|
+ return ret;
|
|
|
|
|
|
ret = iio_buffer_register(indio_dev,
|
|
|
sca3000_channels,
|
|
@@ -1198,10 +1196,6 @@ error_unregister_ring:
|
|
|
iio_buffer_unregister(indio_dev);
|
|
|
error_unregister_dev:
|
|
|
iio_device_unregister(indio_dev);
|
|
|
-error_free_dev:
|
|
|
- iio_device_free(indio_dev);
|
|
|
-
|
|
|
-error_ret:
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
@@ -1235,7 +1229,6 @@ static int sca3000_remove(struct spi_device *spi)
|
|
|
iio_device_unregister(indio_dev);
|
|
|
iio_buffer_unregister(indio_dev);
|
|
|
sca3000_unconfigure_ring(indio_dev);
|
|
|
- iio_device_free(indio_dev);
|
|
|
|
|
|
return 0;
|
|
|
}
|