struct ad5421_state *st;
int ret;
- indio_dev = iio_device_alloc(sizeof(*st));
+ indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (indio_dev == NULL) {
dev_err(&spi->dev, "Failed to allocate iio device\n");
return -ENOMEM;
ad5421_update_ctrl(indio_dev, 0, 0);
if (spi->irq) {
- ret = request_threaded_irq(spi->irq,
+ ret = devm_request_threaded_irq(&spi->dev, spi->irq,
NULL,
ad5421_fault_handler,
IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
"ad5421 fault",
indio_dev);
if (ret)
- goto error_free;
+ return ret;
}
ret = iio_device_register(indio_dev);
if (ret) {
dev_err(&spi->dev, "Failed to register iio device: %d\n", ret);
- goto error_free_irq;
+ return ret;
}
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)
struct iio_dev *indio_dev = spi_get_drvdata(spi);
iio_device_unregister(indio_dev);
- if (spi->irq)
- free_irq(spi->irq, indio_dev);
- iio_device_free(indio_dev);
return 0;
}