diff options
| -rw-r--r-- | drivers/spi/pxa2xx_spi_pci.c | 61 |
1 files changed, 21 insertions, 40 deletions
diff --git a/drivers/spi/pxa2xx_spi_pci.c b/drivers/spi/pxa2xx_spi_pci.c index 351d8a375b57..19752b09e155 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 | ||
| 10 | struct awesome_struct { | 10 | struct 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 | ||
| 16 | static DEFINE_MUTEX(ssp_lock); | 15 | static DEFINE_MUTEX(ssp_lock); |
| @@ -51,23 +50,15 @@ void pxa_ssp_free(struct ssp_device *ssp) | |||
| 51 | } | 50 | } |
| 52 | EXPORT_SYMBOL_GPL(pxa_ssp_free); | 51 | EXPORT_SYMBOL_GPL(pxa_ssp_free); |
| 53 | 52 | ||
| 54 | static 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 | |||
| 62 | static int __devinit ce4100_spi_probe(struct pci_dev *dev, | 53 | static 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,33 +75,30 @@ 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 | #ifdef CONFIG_OF | 92 | #ifdef CONFIG_OF |
| 102 | pdev->dev.of_node = dev->dev.of_node; | 93 | pdev->dev.of_node = dev->dev.of_node; |
| 103 | #endif | 94 | #endif |
| 104 | pdev->dev.release = plat_dev_release; | 95 | ssp = &spi_info->ssp; |
| 105 | |||
| 106 | spi_pdata->num_chipselect = dev->devfn; | ||
| 107 | |||
| 108 | ssp->phys_base = pci_resource_start(dev, 0); | 96 | ssp->phys_base = pci_resource_start(dev, 0); |
| 109 | ssp->mmio_base = ioremap(phys_beg, phys_len); | 97 | ssp->mmio_base = ioremap(phys_beg, phys_len); |
| 110 | if (!ssp->mmio_base) { | 98 | if (!ssp->mmio_base) { |
| 111 | dev_err(&pdev->dev, "failed to ioremap() registers\n"); | 99 | dev_err(&pdev->dev, "failed to ioremap() registers\n"); |
| 112 | ret = -EIO; | 100 | ret = -EIO; |
| 113 | goto err_remap; | 101 | goto err_nomem; |
| 114 | } | 102 | } |
| 115 | ssp->irq = dev->irq; | 103 | ssp->irq = dev->irq; |
| 116 | ssp->port_id = pdev->id; | 104 | ssp->port_id = pdev->id; |
| @@ -122,7 +110,7 @@ static int __devinit ce4100_spi_probe(struct pci_dev *dev, | |||
| 122 | 110 | ||
| 123 | pci_set_drvdata(dev, spi_info); | 111 | pci_set_drvdata(dev, spi_info); |
| 124 | 112 | ||
| 125 | ret = platform_device_register(pdev); | 113 | ret = platform_device_add(pdev); |
| 126 | if (ret) | 114 | if (ret) |
| 127 | goto err_dev_add; | 115 | goto err_dev_add; |
| 128 | 116 | ||
| @@ -135,27 +123,21 @@ err_dev_add: | |||
| 135 | mutex_unlock(&ssp_lock); | 123 | mutex_unlock(&ssp_lock); |
| 136 | iounmap(ssp->mmio_base); | 124 | iounmap(ssp->mmio_base); |
| 137 | 125 | ||
| 138 | err_remap: | 126 | err_nomem: |
| 139 | kfree(spi_info); | ||
| 140 | |||
| 141 | err_kz: | ||
| 142 | release_mem_region(phys_beg, phys_len); | 127 | release_mem_region(phys_beg, phys_len); |
| 143 | 128 | platform_device_put(pdev); | |
| 129 | kfree(spi_info); | ||
| 144 | return ret; | 130 | return ret; |
| 145 | } | 131 | } |
| 146 | 132 | ||
| 147 | static void __devexit ce4100_spi_remove(struct pci_dev *dev) | 133 | static void __devexit ce4100_spi_remove(struct pci_dev *dev) |
| 148 | { | 134 | { |
| 149 | struct awesome_struct *spi_info; | 135 | struct ce4100_info *spi_info; |
| 150 | struct platform_device *pdev; | ||
| 151 | struct ssp_device *ssp; | 136 | struct ssp_device *ssp; |
| 152 | 137 | ||
| 153 | spi_info = pci_get_drvdata(dev); | 138 | spi_info = pci_get_drvdata(dev); |
| 154 | |||
| 155 | ssp = &spi_info->ssp; | 139 | ssp = &spi_info->ssp; |
| 156 | pdev = &spi_info->spi_pdev; | 140 | platform_device_unregister(spi_info->spi_pdev); |
| 157 | |||
| 158 | platform_device_unregister(pdev); | ||
| 159 | 141 | ||
| 160 | iounmap(ssp->mmio_base); | 142 | iounmap(ssp->mmio_base); |
| 161 | release_mem_region(pci_resource_start(dev, 0), | 143 | release_mem_region(pci_resource_start(dev, 0), |
| @@ -171,7 +153,6 @@ static void __devexit ce4100_spi_remove(struct pci_dev *dev) | |||
| 171 | } | 153 | } |
| 172 | 154 | ||
| 173 | static struct pci_device_id ce4100_spi_devices[] __devinitdata = { | 155 | static struct pci_device_id ce4100_spi_devices[] __devinitdata = { |
| 174 | |||
| 175 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e6a) }, | 156 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e6a) }, |
| 176 | { }, | 157 | { }, |
| 177 | }; | 158 | }; |
