aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2011-03-12 03:25:53 -0500
committerGrant Likely <grant.likely@secretlab.ca>2011-03-12 03:25:53 -0500
commit9c3c8afccb6a163fd2be739f511e863eab668702 (patch)
treee587a5377ada98fed8cfa6c8ee63125361f2818a /drivers/spi
parent290293eda2c6dd368476d71433bdef07c39a6829 (diff)
parenta5abba989deceb731047425812d268daf7536575 (diff)
Merge commit 'v2.6.38-rc8' into spi/next
Conflicts: drivers/spi/pxa2xx_spi_pci.c
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/pxa2xx_spi_pci.c61
-rw-r--r--drivers/spi/spi_sh_msiof.c6
2 files changed, 25 insertions, 42 deletions
diff --git a/drivers/spi/pxa2xx_spi_pci.c b/drivers/spi/pxa2xx_spi_pci.c
index b6589bb3a6c3..378e504f89eb 100644
--- a/drivers/spi/pxa2xx_spi_pci.c
+++ b/drivers/spi/pxa2xx_spi_pci.c
@@ -7,10 +7,9 @@
7#include <linux/of_device.h> 7#include <linux/of_device.h>
8#include <linux/spi/pxa2xx_spi.h> 8#include <linux/spi/pxa2xx_spi.h>
9 9
10struct awesome_struct { 10struct ce4100_info {
11 struct ssp_device ssp; 11 struct ssp_device ssp;
12 struct platform_device spi_pdev; 12 struct platform_device *spi_pdev;
13 struct pxa2xx_spi_master spi_pdata;
14}; 13};
15 14
16static DEFINE_MUTEX(ssp_lock); 15static DEFINE_MUTEX(ssp_lock);
@@ -51,23 +50,15 @@ void pxa_ssp_free(struct ssp_device *ssp)
51} 50}
52EXPORT_SYMBOL_GPL(pxa_ssp_free); 51EXPORT_SYMBOL_GPL(pxa_ssp_free);
53 52
54static void plat_dev_release(struct device *dev)
55{
56 struct awesome_struct *as = container_of(dev,
57 struct awesome_struct, spi_pdev.dev);
58
59 of_device_node_put(&as->spi_pdev.dev);
60}
61
62static int __devinit ce4100_spi_probe(struct pci_dev *dev, 53static int __devinit ce4100_spi_probe(struct pci_dev *dev,
63 const struct pci_device_id *ent) 54 const struct pci_device_id *ent)
64{ 55{
65 int ret; 56 int ret;
66 resource_size_t phys_beg; 57 resource_size_t phys_beg;
67 resource_size_t phys_len; 58 resource_size_t phys_len;
68 struct awesome_struct *spi_info; 59 struct ce4100_info *spi_info;
69 struct platform_device *pdev; 60 struct platform_device *pdev;
70 struct pxa2xx_spi_master *spi_pdata; 61 struct pxa2xx_spi_master spi_pdata;
71 struct ssp_device *ssp; 62 struct ssp_device *ssp;
72 63
73 ret = pci_enable_device(dev); 64 ret = pci_enable_device(dev);
@@ -84,31 +75,28 @@ static int __devinit ce4100_spi_probe(struct pci_dev *dev,
84 return ret; 75 return ret;
85 } 76 }
86 77
78 pdev = platform_device_alloc("pxa2xx-spi", dev->devfn);
87 spi_info = kzalloc(sizeof(*spi_info), GFP_KERNEL); 79 spi_info = kzalloc(sizeof(*spi_info), GFP_KERNEL);
88 if (!spi_info) { 80 if (!pdev || !spi_info ) {
89 ret = -ENOMEM; 81 ret = -ENOMEM;
90 goto err_kz; 82 goto err_nomem;
91 } 83 }
92 ssp = &spi_info->ssp; 84 memset(&spi_pdata, 0, sizeof(spi_pdata));
93 pdev = &spi_info->spi_pdev; 85 spi_pdata.num_chipselect = dev->devfn;
94 spi_pdata = &spi_info->spi_pdata;
95 86
96 pdev->name = "pxa2xx-spi"; 87 ret = platform_device_add_data(pdev, &spi_pdata, sizeof(spi_pdata));
97 pdev->id = dev->devfn; 88 if (ret)
98 pdev->dev.parent = &dev->dev; 89 goto err_nomem;
99 pdev->dev.platform_data = &spi_info->spi_pdata;
100 90
91 pdev->dev.parent = &dev->dev;
101 pdev->dev.of_node = dev->dev.of_node; 92 pdev->dev.of_node = dev->dev.of_node;
102 pdev->dev.release = plat_dev_release; 93 ssp = &spi_info->ssp;
103
104 spi_pdata->num_chipselect = dev->devfn;
105
106 ssp->phys_base = pci_resource_start(dev, 0); 94 ssp->phys_base = pci_resource_start(dev, 0);
107 ssp->mmio_base = ioremap(phys_beg, phys_len); 95 ssp->mmio_base = ioremap(phys_beg, phys_len);
108 if (!ssp->mmio_base) { 96 if (!ssp->mmio_base) {
109 dev_err(&pdev->dev, "failed to ioremap() registers\n"); 97 dev_err(&pdev->dev, "failed to ioremap() registers\n");
110 ret = -EIO; 98 ret = -EIO;
111 goto err_remap; 99 goto err_nomem;
112 } 100 }
113 ssp->irq = dev->irq; 101 ssp->irq = dev->irq;
114 ssp->port_id = pdev->id; 102 ssp->port_id = pdev->id;
@@ -120,7 +108,7 @@ static int __devinit ce4100_spi_probe(struct pci_dev *dev,
120 108
121 pci_set_drvdata(dev, spi_info); 109 pci_set_drvdata(dev, spi_info);
122 110
123 ret = platform_device_register(pdev); 111 ret = platform_device_add(pdev);
124 if (ret) 112 if (ret)
125 goto err_dev_add; 113 goto err_dev_add;
126 114
@@ -133,27 +121,21 @@ err_dev_add:
133 mutex_unlock(&ssp_lock); 121 mutex_unlock(&ssp_lock);
134 iounmap(ssp->mmio_base); 122 iounmap(ssp->mmio_base);
135 123
136err_remap: 124err_nomem:
137 kfree(spi_info);
138
139err_kz:
140 release_mem_region(phys_beg, phys_len); 125 release_mem_region(phys_beg, phys_len);
141 126 platform_device_put(pdev);
127 kfree(spi_info);
142 return ret; 128 return ret;
143} 129}
144 130
145static void __devexit ce4100_spi_remove(struct pci_dev *dev) 131static void __devexit ce4100_spi_remove(struct pci_dev *dev)
146{ 132{
147 struct awesome_struct *spi_info; 133 struct ce4100_info *spi_info;
148 struct platform_device *pdev;
149 struct ssp_device *ssp; 134 struct ssp_device *ssp;
150 135
151 spi_info = pci_get_drvdata(dev); 136 spi_info = pci_get_drvdata(dev);
152
153 ssp = &spi_info->ssp; 137 ssp = &spi_info->ssp;
154 pdev = &spi_info->spi_pdev; 138 platform_device_unregister(spi_info->spi_pdev);
155
156 platform_device_unregister(pdev);
157 139
158 iounmap(ssp->mmio_base); 140 iounmap(ssp->mmio_base);
159 release_mem_region(pci_resource_start(dev, 0), 141 release_mem_region(pci_resource_start(dev, 0),
@@ -169,7 +151,6 @@ static void __devexit ce4100_spi_remove(struct pci_dev *dev)
169} 151}
170 152
171static struct pci_device_id ce4100_spi_devices[] __devinitdata = { 153static struct pci_device_id ce4100_spi_devices[] __devinitdata = {
172
173 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e6a) }, 154 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e6a) },
174 { }, 155 { },
175}; 156};
diff --git a/drivers/spi/spi_sh_msiof.c b/drivers/spi/spi_sh_msiof.c
index da6e42ec856e..e00d94b22250 100644
--- a/drivers/spi/spi_sh_msiof.c
+++ b/drivers/spi/spi_sh_msiof.c
@@ -568,9 +568,11 @@ static int sh_msiof_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
568 bytes_done = 0; 568 bytes_done = 0;
569 569
570 while (bytes_done < t->len) { 570 while (bytes_done < t->len) {
571 void *rx_buf = t->rx_buf ? t->rx_buf + bytes_done : NULL;
572 const void *tx_buf = t->tx_buf ? t->tx_buf + bytes_done : NULL;
571 n = sh_msiof_spi_txrx_once(p, tx_fifo, rx_fifo, 573 n = sh_msiof_spi_txrx_once(p, tx_fifo, rx_fifo,
572 t->tx_buf + bytes_done, 574 tx_buf,
573 t->rx_buf + bytes_done, 575 rx_buf,
574 words, bits); 576 words, bits);
575 if (n < 0) 577 if (n < 0)
576 break; 578 break;