aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-dw-pci.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-pci.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-pci.c')
-rw-r--r--drivers/spi/spi-dw-pci.c40
1 files changed, 10 insertions, 30 deletions
diff --git a/drivers/spi/spi-dw-pci.c b/drivers/spi/spi-dw-pci.c
index 66fa9955ea14..760dc0017a33 100644
--- a/drivers/spi/spi-dw-pci.c
+++ b/drivers/spi/spi-dw-pci.c
@@ -43,35 +43,24 @@ static int spi_pci_probe(struct pci_dev *pdev,
43 dev_info(&pdev->dev, "found PCI SPI controller(ID: %04x:%04x)\n", 43 dev_info(&pdev->dev, "found PCI SPI controller(ID: %04x:%04x)\n",
44 pdev->vendor, pdev->device); 44 pdev->vendor, pdev->device);
45 45
46 ret = pci_enable_device(pdev); 46 ret = pcim_enable_device(pdev);
47 if (ret) 47 if (ret)
48 return ret; 48 return ret;
49 49
50 dwpci = kzalloc(sizeof(struct dw_spi_pci), GFP_KERNEL); 50 dwpci = devm_kzalloc(&pdev-dev, sizeof(struct dw_spi_pci), GFP_KERNEL);
51 if (!dwpci) { 51 if (!dwpci)
52 ret = -ENOMEM; 52 return -ENOMEM;
53 goto err_disable;
54 }
55 53
56 dwpci->pdev = pdev; 54 dwpci->pdev = pdev;
57 dws = &dwpci->dws; 55 dws = &dwpci->dws;
58 56
59 /* Get basic io resource and map it */ 57 /* Get basic io resource and map it */
60 dws->paddr = pci_resource_start(pdev, pci_bar); 58 dws->paddr = pci_resource_start(pdev, pci_bar);
61 dws->iolen = pci_resource_len(pdev, pci_bar);
62 59
63 ret = pci_request_region(pdev, pci_bar, dev_name(&pdev->dev)); 60 ret = pcim_iomap_regions(pdev, 1, dev_name(&pdev->dev));
64 if (ret) 61 if (ret)
65 goto err_kfree; 62 return ret;
66
67 dws->regs = ioremap_nocache((unsigned long)dws->paddr,
68 pci_resource_len(pdev, pci_bar));
69 if (!dws->regs) {
70 ret = -ENOMEM;
71 goto err_release_reg;
72 }
73 63
74 dws->parent_dev = &pdev->dev;
75 dws->bus_num = 0; 64 dws->bus_num = 0;
76 dws->num_cs = 4; 65 dws->num_cs = 4;
77 dws->irq = pdev->irq; 66 dws->irq = pdev->irq;
@@ -83,26 +72,17 @@ static int spi_pci_probe(struct pci_dev *pdev,
83 if (pdev->device == 0x0800) { 72 if (pdev->device == 0x0800) {
84 ret = dw_spi_mid_init(dws); 73 ret = dw_spi_mid_init(dws);
85 if (ret) 74 if (ret)
86 goto err_unmap; 75 return ret;
87 } 76 }
88 77
89 ret = dw_spi_add_host(dws); 78 ret = dw_spi_add_host(&pdev->dev, dws);
90 if (ret) 79 if (ret)
91 goto err_unmap; 80 return ret;
92 81
93 /* PCI hook and SPI hook use the same drv data */ 82 /* PCI hook and SPI hook use the same drv data */
94 pci_set_drvdata(pdev, dwpci); 83 pci_set_drvdata(pdev, dwpci);
95 return 0;
96 84
97err_unmap: 85 return 0;
98 iounmap(dws->regs);
99err_release_reg:
100 pci_release_region(pdev, pci_bar);
101err_kfree:
102 kfree(dwpci);
103err_disable:
104 pci_disable_device(pdev);
105 return ret;
106} 86}
107 87
108static void spi_pci_remove(struct pci_dev *pdev) 88static void spi_pci_remove(struct pci_dev *pdev)