diff options
Diffstat (limited to 'drivers/iio/dac/ad5421.c')
-rw-r--r-- | drivers/iio/dac/ad5421.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/drivers/iio/dac/ad5421.c b/drivers/iio/dac/ad5421.c index 98f24407c3ce..1f78b14abb7d 100644 --- a/drivers/iio/dac/ad5421.c +++ b/drivers/iio/dac/ad5421.c | |||
@@ -451,7 +451,7 @@ static int ad5421_probe(struct spi_device *spi) | |||
451 | struct ad5421_state *st; | 451 | struct ad5421_state *st; |
452 | int ret; | 452 | int ret; |
453 | 453 | ||
454 | indio_dev = iio_device_alloc(sizeof(*st)); | 454 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); |
455 | if (indio_dev == NULL) { | 455 | if (indio_dev == NULL) { |
456 | dev_err(&spi->dev, "Failed to allocate iio device\n"); | 456 | dev_err(&spi->dev, "Failed to allocate iio device\n"); |
457 | return -ENOMEM; | 457 | return -ENOMEM; |
@@ -484,31 +484,23 @@ static int ad5421_probe(struct spi_device *spi) | |||
484 | ad5421_update_ctrl(indio_dev, 0, 0); | 484 | ad5421_update_ctrl(indio_dev, 0, 0); |
485 | 485 | ||
486 | if (spi->irq) { | 486 | if (spi->irq) { |
487 | ret = request_threaded_irq(spi->irq, | 487 | ret = devm_request_threaded_irq(&spi->dev, spi->irq, |
488 | NULL, | 488 | NULL, |
489 | ad5421_fault_handler, | 489 | ad5421_fault_handler, |
490 | IRQF_TRIGGER_HIGH | IRQF_ONESHOT, | 490 | IRQF_TRIGGER_HIGH | IRQF_ONESHOT, |
491 | "ad5421 fault", | 491 | "ad5421 fault", |
492 | indio_dev); | 492 | indio_dev); |
493 | if (ret) | 493 | if (ret) |
494 | goto error_free; | 494 | return ret; |
495 | } | 495 | } |
496 | 496 | ||
497 | ret = iio_device_register(indio_dev); | 497 | ret = iio_device_register(indio_dev); |
498 | if (ret) { | 498 | if (ret) { |
499 | dev_err(&spi->dev, "Failed to register iio device: %d\n", ret); | 499 | dev_err(&spi->dev, "Failed to register iio device: %d\n", ret); |
500 | goto error_free_irq; | 500 | return ret; |
501 | } | 501 | } |
502 | 502 | ||
503 | return 0; | 503 | return 0; |
504 | |||
505 | error_free_irq: | ||
506 | if (spi->irq) | ||
507 | free_irq(spi->irq, indio_dev); | ||
508 | error_free: | ||
509 | iio_device_free(indio_dev); | ||
510 | |||
511 | return ret; | ||
512 | } | 504 | } |
513 | 505 | ||
514 | static int ad5421_remove(struct spi_device *spi) | 506 | static int ad5421_remove(struct spi_device *spi) |
@@ -516,9 +508,6 @@ static int ad5421_remove(struct spi_device *spi) | |||
516 | struct iio_dev *indio_dev = spi_get_drvdata(spi); | 508 | struct iio_dev *indio_dev = spi_get_drvdata(spi); |
517 | 509 | ||
518 | iio_device_unregister(indio_dev); | 510 | iio_device_unregister(indio_dev); |
519 | if (spi->irq) | ||
520 | free_irq(spi->irq, indio_dev); | ||
521 | iio_device_free(indio_dev); | ||
522 | 511 | ||
523 | return 0; | 512 | return 0; |
524 | } | 513 | } |