diff options
Diffstat (limited to 'drivers/iio/frequency/adf4350.c')
-rw-r--r-- | drivers/iio/frequency/adf4350.c | 31 |
1 files changed, 9 insertions, 22 deletions
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 | ||