diff options
Diffstat (limited to 'drivers/ata/sata_uli.c')
-rw-r--r-- | drivers/ata/sata_uli.c | 66 |
1 files changed, 27 insertions, 39 deletions
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c index a43aec62d505..80131eec68f4 100644 --- a/drivers/ata/sata_uli.c +++ b/drivers/ata/sata_uli.c | |||
@@ -108,7 +108,7 @@ static const struct ata_port_operations uli_ops = { | |||
108 | .bmdma_status = ata_bmdma_status, | 108 | .bmdma_status = ata_bmdma_status, |
109 | .qc_prep = ata_qc_prep, | 109 | .qc_prep = ata_qc_prep, |
110 | .qc_issue = ata_qc_issue_prot, | 110 | .qc_issue = ata_qc_issue_prot, |
111 | .data_xfer = ata_pio_data_xfer, | 111 | .data_xfer = ata_data_xfer, |
112 | 112 | ||
113 | .freeze = ata_bmdma_freeze, | 113 | .freeze = ata_bmdma_freeze, |
114 | .thaw = ata_bmdma_thaw, | 114 | .thaw = ata_bmdma_thaw, |
@@ -117,13 +117,13 @@ static const struct ata_port_operations uli_ops = { | |||
117 | 117 | ||
118 | .irq_handler = ata_interrupt, | 118 | .irq_handler = ata_interrupt, |
119 | .irq_clear = ata_bmdma_irq_clear, | 119 | .irq_clear = ata_bmdma_irq_clear, |
120 | .irq_on = ata_irq_on, | ||
121 | .irq_ack = ata_irq_ack, | ||
120 | 122 | ||
121 | .scr_read = uli_scr_read, | 123 | .scr_read = uli_scr_read, |
122 | .scr_write = uli_scr_write, | 124 | .scr_write = uli_scr_write, |
123 | 125 | ||
124 | .port_start = ata_port_start, | 126 | .port_start = ata_port_start, |
125 | .port_stop = ata_port_stop, | ||
126 | .host_stop = ata_host_stop, | ||
127 | }; | 127 | }; |
128 | 128 | ||
129 | static struct ata_port_info uli_port_info = { | 129 | static struct ata_port_info uli_port_info = { |
@@ -189,62 +189,60 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
189 | struct ata_port_info *ppi[2]; | 189 | struct ata_port_info *ppi[2]; |
190 | int rc; | 190 | int rc; |
191 | unsigned int board_idx = (unsigned int) ent->driver_data; | 191 | unsigned int board_idx = (unsigned int) ent->driver_data; |
192 | int pci_dev_busy = 0; | ||
193 | struct uli_priv *hpriv; | 192 | struct uli_priv *hpriv; |
193 | void __iomem * const *iomap; | ||
194 | 194 | ||
195 | if (!printed_version++) | 195 | if (!printed_version++) |
196 | dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); | 196 | dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); |
197 | 197 | ||
198 | rc = pci_enable_device(pdev); | 198 | rc = pcim_enable_device(pdev); |
199 | if (rc) | 199 | if (rc) |
200 | return rc; | 200 | return rc; |
201 | 201 | ||
202 | rc = pci_request_regions(pdev, DRV_NAME); | 202 | rc = pci_request_regions(pdev, DRV_NAME); |
203 | if (rc) { | 203 | if (rc) { |
204 | pci_dev_busy = 1; | 204 | pcim_pin_device(pdev); |
205 | goto err_out; | 205 | return rc; |
206 | } | 206 | } |
207 | 207 | ||
208 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 208 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
209 | if (rc) | 209 | if (rc) |
210 | goto err_out_regions; | 210 | return rc; |
211 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | 211 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); |
212 | if (rc) | 212 | if (rc) |
213 | goto err_out_regions; | 213 | return rc; |
214 | 214 | ||
215 | ppi[0] = ppi[1] = &uli_port_info; | 215 | ppi[0] = ppi[1] = &uli_port_info; |
216 | probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); | 216 | probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); |
217 | if (!probe_ent) { | 217 | if (!probe_ent) |
218 | rc = -ENOMEM; | 218 | return -ENOMEM; |
219 | goto err_out_regions; | ||
220 | } | ||
221 | 219 | ||
222 | hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL); | 220 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); |
223 | if (!hpriv) { | 221 | if (!hpriv) |
224 | rc = -ENOMEM; | 222 | return -ENOMEM; |
225 | goto err_out_probe_ent; | ||
226 | } | ||
227 | 223 | ||
228 | probe_ent->private_data = hpriv; | 224 | probe_ent->private_data = hpriv; |
229 | 225 | ||
226 | iomap = pcim_iomap_table(pdev); | ||
227 | |||
230 | switch (board_idx) { | 228 | switch (board_idx) { |
231 | case uli_5287: | 229 | case uli_5287: |
232 | hpriv->scr_cfg_addr[0] = ULI5287_BASE; | 230 | hpriv->scr_cfg_addr[0] = ULI5287_BASE; |
233 | hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS; | 231 | hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS; |
234 | probe_ent->n_ports = 4; | 232 | probe_ent->n_ports = 4; |
235 | 233 | ||
236 | probe_ent->port[2].cmd_addr = pci_resource_start(pdev, 0) + 8; | 234 | probe_ent->port[2].cmd_addr = iomap[0] + 8; |
237 | probe_ent->port[2].altstatus_addr = | 235 | probe_ent->port[2].altstatus_addr = |
238 | probe_ent->port[2].ctl_addr = | 236 | probe_ent->port[2].ctl_addr = (void __iomem *) |
239 | (pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS) + 4; | 237 | ((unsigned long)iomap[1] | ATA_PCI_CTL_OFS) + 4; |
240 | probe_ent->port[2].bmdma_addr = pci_resource_start(pdev, 4) + 16; | 238 | probe_ent->port[2].bmdma_addr = iomap[4] + 16; |
241 | hpriv->scr_cfg_addr[2] = ULI5287_BASE + ULI5287_OFFS*4; | 239 | hpriv->scr_cfg_addr[2] = ULI5287_BASE + ULI5287_OFFS*4; |
242 | 240 | ||
243 | probe_ent->port[3].cmd_addr = pci_resource_start(pdev, 2) + 8; | 241 | probe_ent->port[3].cmd_addr = iomap[2] + 8; |
244 | probe_ent->port[3].altstatus_addr = | 242 | probe_ent->port[3].altstatus_addr = |
245 | probe_ent->port[3].ctl_addr = | 243 | probe_ent->port[3].ctl_addr = (void __iomem *) |
246 | (pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS) + 4; | 244 | ((unsigned long)iomap[3] | ATA_PCI_CTL_OFS) + 4; |
247 | probe_ent->port[3].bmdma_addr = pci_resource_start(pdev, 4) + 24; | 245 | probe_ent->port[3].bmdma_addr = iomap[4] + 24; |
248 | hpriv->scr_cfg_addr[3] = ULI5287_BASE + ULI5287_OFFS*5; | 246 | hpriv->scr_cfg_addr[3] = ULI5287_BASE + ULI5287_OFFS*5; |
249 | 247 | ||
250 | ata_std_ports(&probe_ent->port[2]); | 248 | ata_std_ports(&probe_ent->port[2]); |
@@ -269,21 +267,11 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
269 | pci_set_master(pdev); | 267 | pci_set_master(pdev); |
270 | pci_intx(pdev, 1); | 268 | pci_intx(pdev, 1); |
271 | 269 | ||
272 | /* FIXME: check ata_device_add return value */ | 270 | if (!ata_device_add(probe_ent)) |
273 | ata_device_add(probe_ent); | 271 | return -ENODEV; |
274 | kfree(probe_ent); | ||
275 | 272 | ||
273 | devm_kfree(&pdev->dev, probe_ent); | ||
276 | return 0; | 274 | return 0; |
277 | |||
278 | err_out_probe_ent: | ||
279 | kfree(probe_ent); | ||
280 | err_out_regions: | ||
281 | pci_release_regions(pdev); | ||
282 | err_out: | ||
283 | if (!pci_dev_busy) | ||
284 | pci_disable_device(pdev); | ||
285 | return rc; | ||
286 | |||
287 | } | 275 | } |
288 | 276 | ||
289 | static int __init uli_init(void) | 277 | static int __init uli_init(void) |