aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-davinci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi-davinci.c')
-rw-r--r--drivers/spi/spi-davinci.c49
1 files changed, 13 insertions, 36 deletions
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index 50b2d88c8190..5e7389faa2a0 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -396,10 +396,6 @@ static int davinci_spi_setup(struct spi_device *spi)
396 dspi = spi_master_get_devdata(spi->master); 396 dspi = spi_master_get_devdata(spi->master);
397 pdata = &dspi->pdata; 397 pdata = &dspi->pdata;
398 398
399 /* if bits per word length is zero then set it default 8 */
400 if (!spi->bits_per_word)
401 spi->bits_per_word = 8;
402
403 if (!(spi->mode & SPI_NO_CS)) { 399 if (!(spi->mode & SPI_NO_CS)) {
404 if ((pdata->chip_sel == NULL) || 400 if ((pdata->chip_sel == NULL) ||
405 (pdata->chip_sel[spi->chip_select] == SPI_INTERN_CS)) 401 (pdata->chip_sel[spi->chip_select] == SPI_INTERN_CS))
@@ -853,7 +849,7 @@ static int davinci_spi_probe(struct platform_device *pdev)
853 struct spi_master *master; 849 struct spi_master *master;
854 struct davinci_spi *dspi; 850 struct davinci_spi *dspi;
855 struct davinci_spi_platform_data *pdata; 851 struct davinci_spi_platform_data *pdata;
856 struct resource *r, *mem; 852 struct resource *r;
857 resource_size_t dma_rx_chan = SPI_NO_RESOURCE; 853 resource_size_t dma_rx_chan = SPI_NO_RESOURCE;
858 resource_size_t dma_tx_chan = SPI_NO_RESOURCE; 854 resource_size_t dma_tx_chan = SPI_NO_RESOURCE;
859 int i = 0, ret = 0; 855 int i = 0, ret = 0;
@@ -894,39 +890,33 @@ static int davinci_spi_probe(struct platform_device *pdev)
894 890
895 dspi->pbase = r->start; 891 dspi->pbase = r->start;
896 892
897 mem = request_mem_region(r->start, resource_size(r), pdev->name); 893 dspi->base = devm_ioremap_resource(&pdev->dev, r);
898 if (mem == NULL) { 894 if (IS_ERR(dspi->base)) {
899 ret = -EBUSY; 895 ret = PTR_ERR(dspi->base);
900 goto free_master; 896 goto free_master;
901 } 897 }
902 898
903 dspi->base = ioremap(r->start, resource_size(r));
904 if (dspi->base == NULL) {
905 ret = -ENOMEM;
906 goto release_region;
907 }
908
909 dspi->irq = platform_get_irq(pdev, 0); 899 dspi->irq = platform_get_irq(pdev, 0);
910 if (dspi->irq <= 0) { 900 if (dspi->irq <= 0) {
911 ret = -EINVAL; 901 ret = -EINVAL;
912 goto unmap_io; 902 goto free_master;
913 } 903 }
914 904
915 ret = request_threaded_irq(dspi->irq, davinci_spi_irq, dummy_thread_fn, 905 ret = devm_request_threaded_irq(&pdev->dev, dspi->irq, davinci_spi_irq,
916 0, dev_name(&pdev->dev), dspi); 906 dummy_thread_fn, 0, dev_name(&pdev->dev), dspi);
917 if (ret) 907 if (ret)
918 goto unmap_io; 908 goto free_master;
919 909
920 dspi->bitbang.master = master; 910 dspi->bitbang.master = master;
921 if (dspi->bitbang.master == NULL) { 911 if (dspi->bitbang.master == NULL) {
922 ret = -ENODEV; 912 ret = -ENODEV;
923 goto irq_free; 913 goto free_master;
924 } 914 }
925 915
926 dspi->clk = clk_get(&pdev->dev, NULL); 916 dspi->clk = devm_clk_get(&pdev->dev, NULL);
927 if (IS_ERR(dspi->clk)) { 917 if (IS_ERR(dspi->clk)) {
928 ret = -ENODEV; 918 ret = -ENODEV;
929 goto irq_free; 919 goto free_master;
930 } 920 }
931 clk_prepare_enable(dspi->clk); 921 clk_prepare_enable(dspi->clk);
932 922
@@ -963,8 +953,8 @@ static int davinci_spi_probe(struct platform_device *pdev)
963 goto free_clk; 953 goto free_clk;
964 954
965 dev_info(&pdev->dev, "DMA: supported\n"); 955 dev_info(&pdev->dev, "DMA: supported\n");
966 dev_info(&pdev->dev, "DMA: RX channel: %d, TX channel: %d, " 956 dev_info(&pdev->dev, "DMA: RX channel: %pa, TX channel: %pa, "
967 "event queue: %d\n", dma_rx_chan, dma_tx_chan, 957 "event queue: %d\n", &dma_rx_chan, &dma_tx_chan,
968 pdata->dma_event_q); 958 pdata->dma_event_q);
969 } 959 }
970 960
@@ -1015,13 +1005,6 @@ free_dma:
1015 dma_release_channel(dspi->dma_tx); 1005 dma_release_channel(dspi->dma_tx);
1016free_clk: 1006free_clk:
1017 clk_disable_unprepare(dspi->clk); 1007 clk_disable_unprepare(dspi->clk);
1018 clk_put(dspi->clk);
1019irq_free:
1020 free_irq(dspi->irq, dspi);
1021unmap_io:
1022 iounmap(dspi->base);
1023release_region:
1024 release_mem_region(dspi->pbase, resource_size(r));
1025free_master: 1008free_master:
1026 spi_master_put(master); 1009 spi_master_put(master);
1027err: 1010err:
@@ -1041,7 +1024,6 @@ static int davinci_spi_remove(struct platform_device *pdev)
1041{ 1024{
1042 struct davinci_spi *dspi; 1025 struct davinci_spi *dspi;
1043 struct spi_master *master; 1026 struct spi_master *master;
1044 struct resource *r;
1045 1027
1046 master = platform_get_drvdata(pdev); 1028 master = platform_get_drvdata(pdev);
1047 dspi = spi_master_get_devdata(master); 1029 dspi = spi_master_get_devdata(master);
@@ -1049,11 +1031,6 @@ static int davinci_spi_remove(struct platform_device *pdev)
1049 spi_bitbang_stop(&dspi->bitbang); 1031 spi_bitbang_stop(&dspi->bitbang);
1050 1032
1051 clk_disable_unprepare(dspi->clk); 1033 clk_disable_unprepare(dspi->clk);
1052 clk_put(dspi->clk);
1053 free_irq(dspi->irq, dspi);
1054 iounmap(dspi->base);
1055 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1056 release_mem_region(dspi->pbase, resource_size(r));
1057 spi_master_put(master); 1034 spi_master_put(master);
1058 1035
1059 return 0; 1036 return 0;