diff options
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/adc/at91_adc.c | 42 |
1 files changed, 8 insertions, 34 deletions
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index f61780a02374..98c96f90c88b 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c | |||
@@ -545,13 +545,6 @@ static int __devinit at91_adc_probe(struct platform_device *pdev) | |||
545 | goto error_free_device; | 545 | goto error_free_device; |
546 | } | 546 | } |
547 | 547 | ||
548 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
549 | if (!res) { | ||
550 | dev_err(&pdev->dev, "No resource defined\n"); | ||
551 | ret = -ENXIO; | ||
552 | goto error_ret; | ||
553 | } | ||
554 | |||
555 | platform_set_drvdata(pdev, idev); | 548 | platform_set_drvdata(pdev, idev); |
556 | 549 | ||
557 | idev->dev.parent = &pdev->dev; | 550 | idev->dev.parent = &pdev->dev; |
@@ -566,18 +559,12 @@ static int __devinit at91_adc_probe(struct platform_device *pdev) | |||
566 | goto error_free_device; | 559 | goto error_free_device; |
567 | } | 560 | } |
568 | 561 | ||
569 | if (!request_mem_region(res->start, resource_size(res), | 562 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
570 | "AT91 adc registers")) { | ||
571 | dev_err(&pdev->dev, "Resources are unavailable.\n"); | ||
572 | ret = -EBUSY; | ||
573 | goto error_free_device; | ||
574 | } | ||
575 | 563 | ||
576 | st->reg_base = ioremap(res->start, resource_size(res)); | 564 | st->reg_base = devm_request_and_ioremap(&pdev->dev, res); |
577 | if (!st->reg_base) { | 565 | if (!st->reg_base) { |
578 | dev_err(&pdev->dev, "Failed to map registers.\n"); | ||
579 | ret = -ENOMEM; | 566 | ret = -ENOMEM; |
580 | goto error_release_mem; | 567 | goto error_free_device; |
581 | } | 568 | } |
582 | 569 | ||
583 | /* | 570 | /* |
@@ -592,10 +579,10 @@ static int __devinit at91_adc_probe(struct platform_device *pdev) | |||
592 | idev); | 579 | idev); |
593 | if (ret) { | 580 | if (ret) { |
594 | dev_err(&pdev->dev, "Failed to allocate IRQ.\n"); | 581 | dev_err(&pdev->dev, "Failed to allocate IRQ.\n"); |
595 | goto error_unmap_reg; | 582 | goto error_free_device; |
596 | } | 583 | } |
597 | 584 | ||
598 | st->clk = clk_get(&pdev->dev, "adc_clk"); | 585 | st->clk = devm_clk_get(&pdev->dev, "adc_clk"); |
599 | if (IS_ERR(st->clk)) { | 586 | if (IS_ERR(st->clk)) { |
600 | dev_err(&pdev->dev, "Failed to get the clock.\n"); | 587 | dev_err(&pdev->dev, "Failed to get the clock.\n"); |
601 | ret = PTR_ERR(st->clk); | 588 | ret = PTR_ERR(st->clk); |
@@ -605,7 +592,7 @@ static int __devinit at91_adc_probe(struct platform_device *pdev) | |||
605 | ret = clk_prepare(st->clk); | 592 | ret = clk_prepare(st->clk); |
606 | if (ret) { | 593 | if (ret) { |
607 | dev_err(&pdev->dev, "Could not prepare the clock.\n"); | 594 | dev_err(&pdev->dev, "Could not prepare the clock.\n"); |
608 | goto error_free_clk; | 595 | goto error_free_irq; |
609 | } | 596 | } |
610 | 597 | ||
611 | ret = clk_enable(st->clk); | 598 | ret = clk_enable(st->clk); |
@@ -614,7 +601,7 @@ static int __devinit at91_adc_probe(struct platform_device *pdev) | |||
614 | goto error_unprepare_clk; | 601 | goto error_unprepare_clk; |
615 | } | 602 | } |
616 | 603 | ||
617 | st->adc_clk = clk_get(&pdev->dev, "adc_op_clk"); | 604 | st->adc_clk = devm_clk_get(&pdev->dev, "adc_op_clk"); |
618 | if (IS_ERR(st->adc_clk)) { | 605 | if (IS_ERR(st->adc_clk)) { |
619 | dev_err(&pdev->dev, "Failed to get the ADC clock.\n"); | 606 | dev_err(&pdev->dev, "Failed to get the ADC clock.\n"); |
620 | ret = PTR_ERR(st->clk); | 607 | ret = PTR_ERR(st->clk); |
@@ -624,7 +611,7 @@ static int __devinit at91_adc_probe(struct platform_device *pdev) | |||
624 | ret = clk_prepare(st->adc_clk); | 611 | ret = clk_prepare(st->adc_clk); |
625 | if (ret) { | 612 | if (ret) { |
626 | dev_err(&pdev->dev, "Could not prepare the ADC clock.\n"); | 613 | dev_err(&pdev->dev, "Could not prepare the ADC clock.\n"); |
627 | goto error_free_adc_clk; | 614 | goto error_disable_clk; |
628 | } | 615 | } |
629 | 616 | ||
630 | ret = clk_enable(st->adc_clk); | 617 | ret = clk_enable(st->adc_clk); |
@@ -697,20 +684,12 @@ error_disable_adc_clk: | |||
697 | clk_disable(st->adc_clk); | 684 | clk_disable(st->adc_clk); |
698 | error_unprepare_adc_clk: | 685 | error_unprepare_adc_clk: |
699 | clk_unprepare(st->adc_clk); | 686 | clk_unprepare(st->adc_clk); |
700 | error_free_adc_clk: | ||
701 | clk_put(st->adc_clk); | ||
702 | error_disable_clk: | 687 | error_disable_clk: |
703 | clk_disable(st->clk); | 688 | clk_disable(st->clk); |
704 | error_unprepare_clk: | 689 | error_unprepare_clk: |
705 | clk_unprepare(st->clk); | 690 | clk_unprepare(st->clk); |
706 | error_free_clk: | ||
707 | clk_put(st->clk); | ||
708 | error_free_irq: | 691 | error_free_irq: |
709 | free_irq(st->irq, idev); | 692 | free_irq(st->irq, idev); |
710 | error_unmap_reg: | ||
711 | iounmap(st->reg_base); | ||
712 | error_release_mem: | ||
713 | release_mem_region(res->start, resource_size(res)); | ||
714 | error_free_device: | 693 | error_free_device: |
715 | iio_device_free(idev); | 694 | iio_device_free(idev); |
716 | error_ret: | 695 | error_ret: |
@@ -720,20 +699,15 @@ error_ret: | |||
720 | static int __devexit at91_adc_remove(struct platform_device *pdev) | 699 | static int __devexit at91_adc_remove(struct platform_device *pdev) |
721 | { | 700 | { |
722 | struct iio_dev *idev = platform_get_drvdata(pdev); | 701 | struct iio_dev *idev = platform_get_drvdata(pdev); |
723 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
724 | struct at91_adc_state *st = iio_priv(idev); | 702 | struct at91_adc_state *st = iio_priv(idev); |
725 | 703 | ||
726 | iio_device_unregister(idev); | 704 | iio_device_unregister(idev); |
727 | at91_adc_trigger_remove(idev); | 705 | at91_adc_trigger_remove(idev); |
728 | at91_adc_buffer_remove(idev); | 706 | at91_adc_buffer_remove(idev); |
729 | clk_disable_unprepare(st->adc_clk); | 707 | clk_disable_unprepare(st->adc_clk); |
730 | clk_put(st->adc_clk); | ||
731 | clk_disable(st->clk); | 708 | clk_disable(st->clk); |
732 | clk_unprepare(st->clk); | 709 | clk_unprepare(st->clk); |
733 | clk_put(st->clk); | ||
734 | free_irq(st->irq, idev); | 710 | free_irq(st->irq, idev); |
735 | iounmap(st->reg_base); | ||
736 | release_mem_region(res->start, resource_size(res)); | ||
737 | iio_device_free(idev); | 711 | iio_device_free(idev); |
738 | 712 | ||
739 | return 0; | 713 | return 0; |