diff options
Diffstat (limited to 'drivers/iio/frequency')
-rw-r--r-- | drivers/iio/frequency/Kconfig | 1 | ||||
-rw-r--r-- | drivers/iio/frequency/Makefile | 1 | ||||
-rw-r--r-- | drivers/iio/frequency/ad9523.c | 17 | ||||
-rw-r--r-- | drivers/iio/frequency/adf4350.c | 31 |
4 files changed, 15 insertions, 35 deletions
diff --git a/drivers/iio/frequency/Kconfig b/drivers/iio/frequency/Kconfig index 6aaa33ef4544..dc5e0b72882f 100644 --- a/drivers/iio/frequency/Kconfig +++ b/drivers/iio/frequency/Kconfig | |||
@@ -4,6 +4,7 @@ | |||
4 | # Clock Distribution device drivers | 4 | # Clock Distribution device drivers |
5 | # Phase-Locked Loop (PLL) frequency synthesizers | 5 | # Phase-Locked Loop (PLL) frequency synthesizers |
6 | # | 6 | # |
7 | # When adding new entries keep the list in alphabetical order | ||
7 | 8 | ||
8 | menu "Frequency Synthesizers DDS/PLL" | 9 | menu "Frequency Synthesizers DDS/PLL" |
9 | 10 | ||
diff --git a/drivers/iio/frequency/Makefile b/drivers/iio/frequency/Makefile index 00d26e5d1dc2..2bca03f3e2e3 100644 --- a/drivers/iio/frequency/Makefile +++ b/drivers/iio/frequency/Makefile | |||
@@ -2,5 +2,6 @@ | |||
2 | # Makefile iio/frequency | 2 | # Makefile iio/frequency |
3 | # | 3 | # |
4 | 4 | ||
5 | # When adding new entries keep the list in alphabetical order | ||
5 | obj-$(CONFIG_AD9523) += ad9523.o | 6 | obj-$(CONFIG_AD9523) += ad9523.o |
6 | obj-$(CONFIG_ADF4350) += adf4350.o | 7 | obj-$(CONFIG_ADF4350) += adf4350.o |
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c index 92276deeb026..7c5245d9f99c 100644 --- a/drivers/iio/frequency/ad9523.c +++ b/drivers/iio/frequency/ad9523.c | |||
@@ -961,17 +961,17 @@ static int ad9523_probe(struct spi_device *spi) | |||
961 | return -EINVAL; | 961 | return -EINVAL; |
962 | } | 962 | } |
963 | 963 | ||
964 | indio_dev = iio_device_alloc(sizeof(*st)); | 964 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); |
965 | if (indio_dev == NULL) | 965 | if (indio_dev == NULL) |
966 | return -ENOMEM; | 966 | return -ENOMEM; |
967 | 967 | ||
968 | st = iio_priv(indio_dev); | 968 | st = iio_priv(indio_dev); |
969 | 969 | ||
970 | st->reg = regulator_get(&spi->dev, "vcc"); | 970 | st->reg = devm_regulator_get(&spi->dev, "vcc"); |
971 | if (!IS_ERR(st->reg)) { | 971 | if (!IS_ERR(st->reg)) { |
972 | ret = regulator_enable(st->reg); | 972 | ret = regulator_enable(st->reg); |
973 | if (ret) | 973 | if (ret) |
974 | goto error_put_reg; | 974 | return ret; |
975 | } | 975 | } |
976 | 976 | ||
977 | spi_set_drvdata(spi, indio_dev); | 977 | spi_set_drvdata(spi, indio_dev); |
@@ -1001,11 +1001,6 @@ static int ad9523_probe(struct spi_device *spi) | |||
1001 | error_disable_reg: | 1001 | error_disable_reg: |
1002 | if (!IS_ERR(st->reg)) | 1002 | if (!IS_ERR(st->reg)) |
1003 | regulator_disable(st->reg); | 1003 | regulator_disable(st->reg); |
1004 | error_put_reg: | ||
1005 | if (!IS_ERR(st->reg)) | ||
1006 | regulator_put(st->reg); | ||
1007 | |||
1008 | iio_device_free(indio_dev); | ||
1009 | 1004 | ||
1010 | return ret; | 1005 | return ret; |
1011 | } | 1006 | } |
@@ -1017,12 +1012,8 @@ static int ad9523_remove(struct spi_device *spi) | |||
1017 | 1012 | ||
1018 | iio_device_unregister(indio_dev); | 1013 | iio_device_unregister(indio_dev); |
1019 | 1014 | ||
1020 | if (!IS_ERR(st->reg)) { | 1015 | if (!IS_ERR(st->reg)) |
1021 | regulator_disable(st->reg); | 1016 | regulator_disable(st->reg); |
1022 | regulator_put(st->reg); | ||
1023 | } | ||
1024 | |||
1025 | iio_device_free(indio_dev); | ||
1026 | 1017 | ||
1027 | return 0; | 1018 | return 0; |
1028 | } | 1019 | } |
diff --git a/drivers/iio/frequency/adf4350.c b/drivers/iio/frequency/adf4350.c index a4157cdb314d..a7b30be86ae0 100644 --- a/drivers/iio/frequency/adf4350.c +++ b/drivers/iio/frequency/adf4350.c | |||
@@ -515,7 +515,7 @@ static int adf4350_probe(struct spi_device *spi) | |||
515 | } | 515 | } |
516 | 516 | ||
517 | if (!pdata->clkin) { | 517 | if (!pdata->clkin) { |
518 | clk = clk_get(&spi->dev, "clkin"); | 518 | clk = devm_clk_get(&spi->dev, "clkin"); |
519 | if (IS_ERR(clk)) | 519 | if (IS_ERR(clk)) |
520 | return -EPROBE_DEFER; | 520 | return -EPROBE_DEFER; |
521 | 521 | ||
@@ -524,17 +524,17 @@ static int adf4350_probe(struct spi_device *spi) | |||
524 | return ret; | 524 | return ret; |
525 | } | 525 | } |
526 | 526 | ||
527 | indio_dev = iio_device_alloc(sizeof(*st)); | 527 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); |
528 | if (indio_dev == NULL) | 528 | if (indio_dev == NULL) |
529 | return -ENOMEM; | 529 | return -ENOMEM; |
530 | 530 | ||
531 | st = iio_priv(indio_dev); | 531 | st = iio_priv(indio_dev); |
532 | 532 | ||
533 | st->reg = regulator_get(&spi->dev, "vcc"); | 533 | st->reg = devm_regulator_get(&spi->dev, "vcc"); |
534 | if (!IS_ERR(st->reg)) { | 534 | if (!IS_ERR(st->reg)) { |
535 | ret = regulator_enable(st->reg); | 535 | ret = regulator_enable(st->reg); |
536 | if (ret) | 536 | if (ret) |
537 | goto error_put_reg; | 537 | goto error_disable_clk; |
538 | } | 538 | } |
539 | 539 | ||
540 | spi_set_drvdata(spi, indio_dev); | 540 | spi_set_drvdata(spi, indio_dev); |
@@ -564,7 +564,8 @@ static int adf4350_probe(struct spi_device *spi) | |||
564 | memset(st->regs_hw, 0xFF, sizeof(st->regs_hw)); | 564 | memset(st->regs_hw, 0xFF, sizeof(st->regs_hw)); |
565 | 565 | ||
566 | if (gpio_is_valid(pdata->gpio_lock_detect)) { | 566 | if (gpio_is_valid(pdata->gpio_lock_detect)) { |
567 | ret = gpio_request(pdata->gpio_lock_detect, indio_dev->name); | 567 | ret = devm_gpio_request(&spi->dev, pdata->gpio_lock_detect, |
568 | indio_dev->name); | ||
568 | if (ret) { | 569 | if (ret) { |
569 | dev_err(&spi->dev, "fail to request lock detect GPIO-%d", | 570 | dev_err(&spi->dev, "fail to request lock detect GPIO-%d", |
570 | pdata->gpio_lock_detect); | 571 | pdata->gpio_lock_detect); |
@@ -576,29 +577,21 @@ static int adf4350_probe(struct spi_device *spi) | |||
576 | if (pdata->power_up_frequency) { | 577 | if (pdata->power_up_frequency) { |
577 | ret = adf4350_set_freq(st, pdata->power_up_frequency); | 578 | ret = adf4350_set_freq(st, pdata->power_up_frequency); |
578 | if (ret) | 579 | if (ret) |
579 | goto error_free_gpio; | 580 | goto error_disable_reg; |
580 | } | 581 | } |
581 | 582 | ||
582 | ret = iio_device_register(indio_dev); | 583 | ret = iio_device_register(indio_dev); |
583 | if (ret) | 584 | if (ret) |
584 | goto error_free_gpio; | 585 | goto error_disable_reg; |
585 | 586 | ||
586 | return 0; | 587 | return 0; |
587 | 588 | ||
588 | error_free_gpio: | ||
589 | if (gpio_is_valid(pdata->gpio_lock_detect)) | ||
590 | gpio_free(pdata->gpio_lock_detect); | ||
591 | |||
592 | error_disable_reg: | 589 | error_disable_reg: |
593 | if (!IS_ERR(st->reg)) | 590 | if (!IS_ERR(st->reg)) |
594 | regulator_disable(st->reg); | 591 | regulator_disable(st->reg); |
595 | error_put_reg: | 592 | error_disable_clk: |
596 | if (!IS_ERR(st->reg)) | ||
597 | regulator_put(st->reg); | ||
598 | |||
599 | if (clk) | 593 | if (clk) |
600 | clk_disable_unprepare(clk); | 594 | clk_disable_unprepare(clk); |
601 | iio_device_free(indio_dev); | ||
602 | 595 | ||
603 | return ret; | 596 | return ret; |
604 | } | 597 | } |
@@ -619,14 +612,8 @@ static int adf4350_remove(struct spi_device *spi) | |||
619 | 612 | ||
620 | if (!IS_ERR(reg)) { | 613 | if (!IS_ERR(reg)) { |
621 | regulator_disable(reg); | 614 | regulator_disable(reg); |
622 | regulator_put(reg); | ||
623 | } | 615 | } |
624 | 616 | ||
625 | if (gpio_is_valid(st->pdata->gpio_lock_detect)) | ||
626 | gpio_free(st->pdata->gpio_lock_detect); | ||
627 | |||
628 | iio_device_free(indio_dev); | ||
629 | |||
630 | return 0; | 617 | return 0; |
631 | } | 618 | } |
632 | 619 | ||