Commit 62a308a6 authored by Sachin Kamat's avatar Sachin Kamat Committed by Jonathan Cameron

iio: dac: ad5421: Use devm_* APIs

devm_* APIs are device managed and make code simpler.
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent c815ad37
...@@ -451,7 +451,7 @@ static int ad5421_probe(struct spi_device *spi) ...@@ -451,7 +451,7 @@ static int ad5421_probe(struct spi_device *spi)
struct ad5421_state *st; struct ad5421_state *st;
int ret; int ret;
indio_dev = iio_device_alloc(sizeof(*st)); indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (indio_dev == NULL) { if (indio_dev == NULL) {
dev_err(&spi->dev, "Failed to allocate iio device\n"); dev_err(&spi->dev, "Failed to allocate iio device\n");
return -ENOMEM; return -ENOMEM;
...@@ -484,31 +484,23 @@ static int ad5421_probe(struct spi_device *spi) ...@@ -484,31 +484,23 @@ static int ad5421_probe(struct spi_device *spi)
ad5421_update_ctrl(indio_dev, 0, 0); ad5421_update_ctrl(indio_dev, 0, 0);
if (spi->irq) { if (spi->irq) {
ret = request_threaded_irq(spi->irq, ret = devm_request_threaded_irq(&spi->dev, spi->irq,
NULL, NULL,
ad5421_fault_handler, ad5421_fault_handler,
IRQF_TRIGGER_HIGH | IRQF_ONESHOT, IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
"ad5421 fault", "ad5421 fault",
indio_dev); indio_dev);
if (ret) if (ret)
goto error_free; return ret;
} }
ret = iio_device_register(indio_dev); ret = iio_device_register(indio_dev);
if (ret) { if (ret) {
dev_err(&spi->dev, "Failed to register iio device: %d\n", ret); dev_err(&spi->dev, "Failed to register iio device: %d\n", ret);
goto error_free_irq; return ret;
} }
return 0; return 0;
error_free_irq:
if (spi->irq)
free_irq(spi->irq, indio_dev);
error_free:
iio_device_free(indio_dev);
return ret;
} }
static int ad5421_remove(struct spi_device *spi) static int ad5421_remove(struct spi_device *spi)
...@@ -516,9 +508,6 @@ static int ad5421_remove(struct spi_device *spi) ...@@ -516,9 +508,6 @@ static int ad5421_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi); struct iio_dev *indio_dev = spi_get_drvdata(spi);
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
if (spi->irq)
free_irq(spi->irq, indio_dev);
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