diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2012-08-26 12:00:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2012-09-03 15:26:42 -0400 |
commit | 00062a9c2e772345388cd352695790f00a95b934 (patch) | |
tree | a88b88efcec84f2f6b4089b8eac37dab0015de6a /drivers/iio | |
parent | f5ed9c35bd2af6d9d171290d3dc45004f4f79bcf (diff) |
drivers/iio/adc/at91_adc.c: use clk_prepare_enable and clk_disable_unprepare
Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare. They make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.
A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
expression e;
@@
- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);
@@
expression e;
@@
- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/adc/at91_adc.c | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 98c96f90c88b..c1e4690f188d 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c | |||
@@ -589,18 +589,13 @@ static int __devinit at91_adc_probe(struct platform_device *pdev) | |||
589 | goto error_free_irq; | 589 | goto error_free_irq; |
590 | } | 590 | } |
591 | 591 | ||
592 | ret = clk_prepare(st->clk); | 592 | ret = clk_prepare_enable(st->clk); |
593 | if (ret) { | 593 | if (ret) { |
594 | dev_err(&pdev->dev, "Could not prepare the clock.\n"); | 594 | dev_err(&pdev->dev, |
595 | "Could not prepare or enable the clock.\n"); | ||
595 | goto error_free_irq; | 596 | goto error_free_irq; |
596 | } | 597 | } |
597 | 598 | ||
598 | ret = clk_enable(st->clk); | ||
599 | if (ret) { | ||
600 | dev_err(&pdev->dev, "Could not enable the clock.\n"); | ||
601 | goto error_unprepare_clk; | ||
602 | } | ||
603 | |||
604 | st->adc_clk = devm_clk_get(&pdev->dev, "adc_op_clk"); | 599 | st->adc_clk = devm_clk_get(&pdev->dev, "adc_op_clk"); |
605 | if (IS_ERR(st->adc_clk)) { | 600 | if (IS_ERR(st->adc_clk)) { |
606 | dev_err(&pdev->dev, "Failed to get the ADC clock.\n"); | 601 | dev_err(&pdev->dev, "Failed to get the ADC clock.\n"); |
@@ -608,18 +603,13 @@ static int __devinit at91_adc_probe(struct platform_device *pdev) | |||
608 | goto error_disable_clk; | 603 | goto error_disable_clk; |
609 | } | 604 | } |
610 | 605 | ||
611 | ret = clk_prepare(st->adc_clk); | 606 | ret = clk_prepare_enable(st->adc_clk); |
612 | if (ret) { | 607 | if (ret) { |
613 | dev_err(&pdev->dev, "Could not prepare the ADC clock.\n"); | 608 | dev_err(&pdev->dev, |
609 | "Could not prepare or enable the ADC clock.\n"); | ||
614 | goto error_disable_clk; | 610 | goto error_disable_clk; |
615 | } | 611 | } |
616 | 612 | ||
617 | ret = clk_enable(st->adc_clk); | ||
618 | if (ret) { | ||
619 | dev_err(&pdev->dev, "Could not enable the ADC clock.\n"); | ||
620 | goto error_unprepare_adc_clk; | ||
621 | } | ||
622 | |||
623 | /* | 613 | /* |
624 | * Prescaler rate computation using the formula from the Atmel's | 614 | * Prescaler rate computation using the formula from the Atmel's |
625 | * datasheet : ADC Clock = MCK / ((Prescaler + 1) * 2), ADC Clock being | 615 | * datasheet : ADC Clock = MCK / ((Prescaler + 1) * 2), ADC Clock being |
@@ -681,13 +671,9 @@ error_remove_triggers: | |||
681 | error_unregister_buffer: | 671 | error_unregister_buffer: |
682 | at91_adc_buffer_remove(idev); | 672 | at91_adc_buffer_remove(idev); |
683 | error_disable_adc_clk: | 673 | error_disable_adc_clk: |
684 | clk_disable(st->adc_clk); | 674 | clk_disable_unprepare(st->adc_clk); |
685 | error_unprepare_adc_clk: | ||
686 | clk_unprepare(st->adc_clk); | ||
687 | error_disable_clk: | 675 | error_disable_clk: |
688 | clk_disable(st->clk); | 676 | clk_disable_unprepare(st->clk); |
689 | error_unprepare_clk: | ||
690 | clk_unprepare(st->clk); | ||
691 | error_free_irq: | 677 | error_free_irq: |
692 | free_irq(st->irq, idev); | 678 | free_irq(st->irq, idev); |
693 | error_free_device: | 679 | error_free_device: |
@@ -705,8 +691,7 @@ static int __devexit at91_adc_remove(struct platform_device *pdev) | |||
705 | at91_adc_trigger_remove(idev); | 691 | at91_adc_trigger_remove(idev); |
706 | at91_adc_buffer_remove(idev); | 692 | at91_adc_buffer_remove(idev); |
707 | clk_disable_unprepare(st->adc_clk); | 693 | clk_disable_unprepare(st->adc_clk); |
708 | clk_disable(st->clk); | 694 | clk_disable_unprepare(st->clk); |
709 | clk_unprepare(st->clk); | ||
710 | free_irq(st->irq, idev); | 695 | free_irq(st->irq, idev); |
711 | iio_device_free(idev); | 696 | iio_device_free(idev); |
712 | 697 | ||