Commit 0a2f0265 authored by Sachin Kamat's avatar Sachin Kamat Committed by Jonathan Cameron

staging: iio: ad7280a: Use devm_iio_device_alloc

devm_iio_device_alloc makes code simpler.
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 1e319cec
...@@ -835,8 +835,9 @@ static int ad7280_probe(struct spi_device *spi) ...@@ -835,8 +835,9 @@ static int ad7280_probe(struct spi_device *spi)
int ret; int ret;
const unsigned short tACQ_ns[4] = {465, 1010, 1460, 1890}; const unsigned short tACQ_ns[4] = {465, 1010, 1460, 1890};
const unsigned short nAVG[4] = {1, 2, 4, 8}; const unsigned short nAVG[4] = {1, 2, 4, 8};
struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st)); struct iio_dev *indio_dev;
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (indio_dev == NULL) if (indio_dev == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -860,7 +861,7 @@ static int ad7280_probe(struct spi_device *spi) ...@@ -860,7 +861,7 @@ static int ad7280_probe(struct spi_device *spi)
ret = ad7280_chain_setup(st); ret = ad7280_chain_setup(st);
if (ret < 0) if (ret < 0)
goto error_free_device; return ret;
st->slave_num = ret; st->slave_num = ret;
st->scan_cnt = (st->slave_num + 1) * AD7280A_NUM_CH; st->scan_cnt = (st->slave_num + 1) * AD7280A_NUM_CH;
...@@ -891,7 +892,7 @@ static int ad7280_probe(struct spi_device *spi) ...@@ -891,7 +892,7 @@ static int ad7280_probe(struct spi_device *spi)
ret = ad7280_channel_init(st); ret = ad7280_channel_init(st);
if (ret < 0) if (ret < 0)
goto error_free_device; return ret;
indio_dev->num_channels = ret; indio_dev->num_channels = ret;
indio_dev->channels = st->channels; indio_dev->channels = st->channels;
...@@ -940,9 +941,6 @@ static int ad7280_probe(struct spi_device *spi) ...@@ -940,9 +941,6 @@ static int ad7280_probe(struct spi_device *spi)
error_free_channels: error_free_channels:
kfree(st->channels); kfree(st->channels);
error_free_device:
iio_device_free(indio_dev);
return ret; return ret;
} }
...@@ -960,7 +958,6 @@ static int ad7280_remove(struct spi_device *spi) ...@@ -960,7 +958,6 @@ static int ad7280_remove(struct spi_device *spi)
kfree(st->channels); kfree(st->channels);
kfree(st->iio_attr); kfree(st->iio_attr);
iio_device_free(indio_dev);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment