staging: iio: ad2s1210: Use devm_iio_device_alloc
devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Cc: Graff Yang <graff.yang@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
a20df3fe46
commit
50711572c6
@ -669,16 +669,14 @@ static int ad2s1210_probe(struct spi_device *spi)
|
||||
if (spi->dev.platform_data == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
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);
|
||||
st->pdata = spi->dev.platform_data;
|
||||
ret = ad2s1210_setup_gpios(st);
|
||||
if (ret < 0)
|
||||
goto error_free_dev;
|
||||
return ret;
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
|
||||
@ -709,9 +707,6 @@ static int ad2s1210_probe(struct spi_device *spi)
|
||||
|
||||
error_free_gpios:
|
||||
ad2s1210_free_gpios(st);
|
||||
error_free_dev:
|
||||
iio_device_free(indio_dev);
|
||||
error_ret:
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -721,7 +716,6 @@ static int ad2s1210_remove(struct spi_device *spi)
|
||||
|
||||
iio_device_unregister(indio_dev);
|
||||
ad2s1210_free_gpios(iio_priv(indio_dev));
|
||||
iio_device_free(indio_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user