diff options
| -rw-r--r-- | drivers/spi/spi-s3c24xx.c | 67 |
1 files changed, 14 insertions, 53 deletions
diff --git a/drivers/spi/spi-s3c24xx.c b/drivers/spi/spi-s3c24xx.c index 0dc32a11bd3c..ebf80bbc93b3 100644 --- a/drivers/spi/spi-s3c24xx.c +++ b/drivers/spi/spi-s3c24xx.c | |||
| @@ -78,7 +78,6 @@ struct s3c24xx_spi { | |||
| 78 | unsigned char *rx; | 78 | unsigned char *rx; |
| 79 | 79 | ||
| 80 | struct clk *clk; | 80 | struct clk *clk; |
| 81 | struct resource *ioarea; | ||
| 82 | struct spi_master *master; | 81 | struct spi_master *master; |
| 83 | struct spi_device *curdev; | 82 | struct spi_device *curdev; |
| 84 | struct device *dev; | 83 | struct device *dev; |
| @@ -517,8 +516,7 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) | |||
| 517 | master = spi_alloc_master(&pdev->dev, sizeof(struct s3c24xx_spi)); | 516 | master = spi_alloc_master(&pdev->dev, sizeof(struct s3c24xx_spi)); |
| 518 | if (master == NULL) { | 517 | if (master == NULL) { |
| 519 | dev_err(&pdev->dev, "No memory for spi_master\n"); | 518 | dev_err(&pdev->dev, "No memory for spi_master\n"); |
| 520 | err = -ENOMEM; | 519 | return -ENOMEM; |
| 521 | goto err_nomem; | ||
| 522 | } | 520 | } |
| 523 | 521 | ||
| 524 | hw = spi_master_get_devdata(master); | 522 | hw = spi_master_get_devdata(master); |
| @@ -567,43 +565,34 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) | |||
| 567 | if (res == NULL) { | 565 | if (res == NULL) { |
| 568 | dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n"); | 566 | dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n"); |
| 569 | err = -ENOENT; | 567 | err = -ENOENT; |
| 570 | goto err_no_iores; | 568 | goto err_no_pdata; |
| 571 | } | ||
| 572 | |||
| 573 | hw->ioarea = request_mem_region(res->start, resource_size(res), | ||
| 574 | pdev->name); | ||
| 575 | |||
| 576 | if (hw->ioarea == NULL) { | ||
| 577 | dev_err(&pdev->dev, "Cannot reserve region\n"); | ||
| 578 | err = -ENXIO; | ||
| 579 | goto err_no_iores; | ||
| 580 | } | 569 | } |
| 581 | 570 | ||
| 582 | hw->regs = ioremap(res->start, resource_size(res)); | 571 | hw->regs = devm_ioremap_resource(&pdev->dev, res); |
| 583 | if (hw->regs == NULL) { | 572 | if (IS_ERR(hw->regs)) { |
| 584 | dev_err(&pdev->dev, "Cannot map IO\n"); | 573 | err = PTR_ERR(hw->regs); |
| 585 | err = -ENXIO; | 574 | goto err_no_pdata; |
| 586 | goto err_no_iomap; | ||
| 587 | } | 575 | } |
| 588 | 576 | ||
| 589 | hw->irq = platform_get_irq(pdev, 0); | 577 | hw->irq = platform_get_irq(pdev, 0); |
| 590 | if (hw->irq < 0) { | 578 | if (hw->irq < 0) { |
| 591 | dev_err(&pdev->dev, "No IRQ specified\n"); | 579 | dev_err(&pdev->dev, "No IRQ specified\n"); |
| 592 | err = -ENOENT; | 580 | err = -ENOENT; |
| 593 | goto err_no_irq; | 581 | goto err_no_pdata; |
| 594 | } | 582 | } |
| 595 | 583 | ||
| 596 | err = request_irq(hw->irq, s3c24xx_spi_irq, 0, pdev->name, hw); | 584 | err = devm_request_irq(&pdev->dev, hw->irq, s3c24xx_spi_irq, 0, |
| 585 | pdev->name, hw); | ||
| 597 | if (err) { | 586 | if (err) { |
| 598 | dev_err(&pdev->dev, "Cannot claim IRQ\n"); | 587 | dev_err(&pdev->dev, "Cannot claim IRQ\n"); |
| 599 | goto err_no_irq; | 588 | goto err_no_pdata; |
| 600 | } | 589 | } |
| 601 | 590 | ||
| 602 | hw->clk = clk_get(&pdev->dev, "spi"); | 591 | hw->clk = devm_clk_get(&pdev->dev, "spi"); |
| 603 | if (IS_ERR(hw->clk)) { | 592 | if (IS_ERR(hw->clk)) { |
| 604 | dev_err(&pdev->dev, "No clock for device\n"); | 593 | dev_err(&pdev->dev, "No clock for device\n"); |
| 605 | err = PTR_ERR(hw->clk); | 594 | err = PTR_ERR(hw->clk); |
| 606 | goto err_no_clk; | 595 | goto err_no_pdata; |
| 607 | } | 596 | } |
| 608 | 597 | ||
| 609 | /* setup any gpio we can */ | 598 | /* setup any gpio we can */ |
| @@ -615,7 +604,8 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) | |||
| 615 | goto err_register; | 604 | goto err_register; |
| 616 | } | 605 | } |
| 617 | 606 | ||
| 618 | err = gpio_request(pdata->pin_cs, dev_name(&pdev->dev)); | 607 | err = devm_gpio_request(&pdev->dev, pdata->pin_cs, |
| 608 | dev_name(&pdev->dev)); | ||
| 619 | if (err) { | 609 | if (err) { |
| 620 | dev_err(&pdev->dev, "Failed to get gpio for cs\n"); | 610 | dev_err(&pdev->dev, "Failed to get gpio for cs\n"); |
| 621 | goto err_register; | 611 | goto err_register; |
| @@ -639,27 +629,10 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) | |||
| 639 | return 0; | 629 | return 0; |
| 640 | 630 | ||
| 641 | err_register: | 631 | err_register: |
| 642 | if (hw->set_cs == s3c24xx_spi_gpiocs) | ||
| 643 | gpio_free(pdata->pin_cs); | ||
| 644 | |||
| 645 | clk_disable(hw->clk); | 632 | clk_disable(hw->clk); |
| 646 | clk_put(hw->clk); | ||
| 647 | 633 | ||
| 648 | err_no_clk: | ||
| 649 | free_irq(hw->irq, hw); | ||
| 650 | |||
| 651 | err_no_irq: | ||
| 652 | iounmap(hw->regs); | ||
| 653 | |||
| 654 | err_no_iomap: | ||
| 655 | release_resource(hw->ioarea); | ||
| 656 | kfree(hw->ioarea); | ||
| 657 | |||
| 658 | err_no_iores: | ||
| 659 | err_no_pdata: | 634 | err_no_pdata: |
| 660 | spi_master_put(hw->master); | 635 | spi_master_put(hw->master); |
| 661 | |||
| 662 | err_nomem: | ||
| 663 | return err; | 636 | return err; |
| 664 | } | 637 | } |
| 665 | 638 | ||
| @@ -668,19 +641,7 @@ static int s3c24xx_spi_remove(struct platform_device *dev) | |||
| 668 | struct s3c24xx_spi *hw = platform_get_drvdata(dev); | 641 | struct s3c24xx_spi *hw = platform_get_drvdata(dev); |
| 669 | 642 | ||
| 670 | spi_bitbang_stop(&hw->bitbang); | 643 | spi_bitbang_stop(&hw->bitbang); |
| 671 | |||
| 672 | clk_disable(hw->clk); | 644 | clk_disable(hw->clk); |
| 673 | clk_put(hw->clk); | ||
| 674 | |||
| 675 | free_irq(hw->irq, hw); | ||
| 676 | iounmap(hw->regs); | ||
| 677 | |||
| 678 | if (hw->set_cs == s3c24xx_spi_gpiocs) | ||
| 679 | gpio_free(hw->pdata->pin_cs); | ||
| 680 | |||
| 681 | release_resource(hw->ioarea); | ||
| 682 | kfree(hw->ioarea); | ||
| 683 | |||
| 684 | spi_master_put(hw->master); | 645 | spi_master_put(hw->master); |
| 685 | return 0; | 646 | return 0; |
| 686 | } | 647 | } |
