mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-05-24 10:39:52 +00:00
staging: iio: sca3000: Use devm_iio_device_alloc
Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
4c24747053
commit
0189d93fdf
1 changed files with 4 additions and 11 deletions
|
@ -1135,11 +1135,9 @@ static int sca3000_probe(struct spi_device *spi)
|
||||||
struct sca3000_state *st;
|
struct sca3000_state *st;
|
||||||
struct iio_dev *indio_dev;
|
struct iio_dev *indio_dev;
|
||||||
|
|
||||||
indio_dev = iio_device_alloc(sizeof(*st));
|
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
|
||||||
if (indio_dev == NULL) {
|
if (!indio_dev)
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto error_ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
st = iio_priv(indio_dev);
|
st = iio_priv(indio_dev);
|
||||||
spi_set_drvdata(spi, 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);
|
sca3000_configure_ring(indio_dev);
|
||||||
ret = iio_device_register(indio_dev);
|
ret = iio_device_register(indio_dev);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error_free_dev;
|
return ret;
|
||||||
|
|
||||||
ret = iio_buffer_register(indio_dev,
|
ret = iio_buffer_register(indio_dev,
|
||||||
sca3000_channels,
|
sca3000_channels,
|
||||||
|
@ -1198,10 +1196,6 @@ error_unregister_ring:
|
||||||
iio_buffer_unregister(indio_dev);
|
iio_buffer_unregister(indio_dev);
|
||||||
error_unregister_dev:
|
error_unregister_dev:
|
||||||
iio_device_unregister(indio_dev);
|
iio_device_unregister(indio_dev);
|
||||||
error_free_dev:
|
|
||||||
iio_device_free(indio_dev);
|
|
||||||
|
|
||||||
error_ret:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1235,7 +1229,6 @@ static int sca3000_remove(struct spi_device *spi)
|
||||||
iio_device_unregister(indio_dev);
|
iio_device_unregister(indio_dev);
|
||||||
iio_buffer_unregister(indio_dev);
|
iio_buffer_unregister(indio_dev);
|
||||||
sca3000_unconfigure_ring(indio_dev);
|
sca3000_unconfigure_ring(indio_dev);
|
||||||
iio_device_free(indio_dev);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue