aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-dw.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi-dw.c')
-rw-r--r--drivers/spi/spi-dw.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index abf4fd5a2a25..48ec161d6eed 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -775,18 +775,16 @@ static void spi_hw_init(struct dw_spi *dws)
775 } 775 }
776} 776}
777 777
778int dw_spi_add_host(struct dw_spi *dws) 778int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
779{ 779{
780 struct spi_master *master; 780 struct spi_master *master;
781 int ret; 781 int ret;
782 782
783 BUG_ON(dws == NULL); 783 BUG_ON(dws == NULL);
784 784
785 master = spi_alloc_master(dws->parent_dev, 0); 785 master = spi_alloc_master(dev, 0);
786 if (!master) { 786 if (!master)
787 ret = -ENOMEM; 787 return -ENOMEM;
788 goto exit;
789 }
790 788
791 dws->master = master; 789 dws->master = master;
792 dws->type = SSI_MOTO_SPI; 790 dws->type = SSI_MOTO_SPI;
@@ -796,7 +794,7 @@ int dw_spi_add_host(struct dw_spi *dws)
796 snprintf(dws->name, sizeof(dws->name), "dw_spi%d", 794 snprintf(dws->name, sizeof(dws->name), "dw_spi%d",
797 dws->bus_num); 795 dws->bus_num);
798 796
799 ret = request_irq(dws->irq, dw_spi_irq, IRQF_SHARED, 797 ret = devm_request_irq(dev, dws->irq, dw_spi_irq, IRQF_SHARED,
800 dws->name, dws); 798 dws->name, dws);
801 if (ret < 0) { 799 if (ret < 0) {
802 dev_err(&master->dev, "can not get IRQ\n"); 800 dev_err(&master->dev, "can not get IRQ\n");
@@ -835,7 +833,7 @@ int dw_spi_add_host(struct dw_spi *dws)
835 } 833 }
836 834
837 spi_master_set_devdata(master, dws); 835 spi_master_set_devdata(master, dws);
838 ret = spi_register_master(master); 836 ret = devm_spi_register_master(dev, master);
839 if (ret) { 837 if (ret) {
840 dev_err(&master->dev, "problem registering spi master\n"); 838 dev_err(&master->dev, "problem registering spi master\n");
841 goto err_queue_alloc; 839 goto err_queue_alloc;
@@ -850,10 +848,8 @@ err_queue_alloc:
850 dws->dma_ops->dma_exit(dws); 848 dws->dma_ops->dma_exit(dws);
851err_diable_hw: 849err_diable_hw:
852 spi_enable_chip(dws, 0); 850 spi_enable_chip(dws, 0);
853 free_irq(dws->irq, dws);
854err_free_master: 851err_free_master:
855 spi_master_put(master); 852 spi_master_put(master);
856exit:
857 return ret; 853 return ret;
858} 854}
859EXPORT_SYMBOL_GPL(dw_spi_add_host); 855EXPORT_SYMBOL_GPL(dw_spi_add_host);
@@ -877,10 +873,6 @@ void dw_spi_remove_host(struct dw_spi *dws)
877 spi_enable_chip(dws, 0); 873 spi_enable_chip(dws, 0);
878 /* Disable clk */ 874 /* Disable clk */
879 spi_set_clk(dws, 0); 875 spi_set_clk(dws, 0);
880 free_irq(dws->irq, dws);
881
882 /* Disconnect from the SPI framework */
883 spi_unregister_master(dws->master);
884} 876}
885EXPORT_SYMBOL_GPL(dw_spi_remove_host); 877EXPORT_SYMBOL_GPL(dw_spi_remove_host);
886 878