aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-dw.c
diff options
context:
space:
mode:
authorBaruch Siach <baruch@tkos.co.il>2013-12-30 13:30:44 -0500
committerMark Brown <broonie@linaro.org>2013-12-31 07:30:18 -0500
commit04f421e7b0b10de3fae543dac4d324b449a1db6b (patch)
treecdbb475e66a2ac6bc755d83f04eeabaf43569cbb /drivers/spi/spi-dw.c
parent0a47d3c40428fb8174ea36ede35267ddc7042f34 (diff)
spi: dw: use managed resources
Migrate mmio code and core driver to managed resources to reduce boilerplate error handling code. Also, handle clk_enable() failure while at it, and drop unused dw_spi iolen field. Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Mark Brown <broonie@linaro.org>
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