diff options
Diffstat (limited to 'drivers/ata/sata_sx4.c')
-rw-r--r-- | drivers/ata/sata_sx4.c | 131 |
1 files changed, 31 insertions, 100 deletions
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c index ae7992de4b08..d9838dcb4b01 100644 --- a/drivers/ata/sata_sx4.c +++ b/drivers/ata/sata_sx4.c | |||
@@ -42,7 +42,6 @@ | |||
42 | #include <scsi/scsi_host.h> | 42 | #include <scsi/scsi_host.h> |
43 | #include <scsi/scsi_cmnd.h> | 43 | #include <scsi/scsi_cmnd.h> |
44 | #include <linux/libata.h> | 44 | #include <linux/libata.h> |
45 | #include <asm/io.h> | ||
46 | #include "sata_promise.h" | 45 | #include "sata_promise.h" |
47 | 46 | ||
48 | #define DRV_NAME "sata_sx4" | 47 | #define DRV_NAME "sata_sx4" |
@@ -156,11 +155,9 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance); | |||
156 | static void pdc_eng_timeout(struct ata_port *ap); | 155 | static void pdc_eng_timeout(struct ata_port *ap); |
157 | static void pdc_20621_phy_reset (struct ata_port *ap); | 156 | static void pdc_20621_phy_reset (struct ata_port *ap); |
158 | static int pdc_port_start(struct ata_port *ap); | 157 | static int pdc_port_start(struct ata_port *ap); |
159 | static void pdc_port_stop(struct ata_port *ap); | ||
160 | static void pdc20621_qc_prep(struct ata_queued_cmd *qc); | 158 | static void pdc20621_qc_prep(struct ata_queued_cmd *qc); |
161 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); | 159 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); |
162 | static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); | 160 | static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); |
163 | static void pdc20621_host_stop(struct ata_host *host); | ||
164 | static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe); | 161 | static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe); |
165 | static int pdc20621_detect_dimm(struct ata_probe_ent *pe); | 162 | static int pdc20621_detect_dimm(struct ata_probe_ent *pe); |
166 | static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, | 163 | static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, |
@@ -210,8 +207,6 @@ static const struct ata_port_operations pdc_20621_ops = { | |||
210 | .irq_handler = pdc20621_interrupt, | 207 | .irq_handler = pdc20621_interrupt, |
211 | .irq_clear = pdc20621_irq_clear, | 208 | .irq_clear = pdc20621_irq_clear, |
212 | .port_start = pdc_port_start, | 209 | .port_start = pdc_port_start, |
213 | .port_stop = pdc_port_stop, | ||
214 | .host_stop = pdc20621_host_stop, | ||
215 | }; | 210 | }; |
216 | 211 | ||
217 | static const struct ata_port_info pdc_port_info[] = { | 212 | static const struct ata_port_info pdc_port_info[] = { |
@@ -243,18 +238,6 @@ static struct pci_driver pdc_sata_pci_driver = { | |||
243 | }; | 238 | }; |
244 | 239 | ||
245 | 240 | ||
246 | static void pdc20621_host_stop(struct ata_host *host) | ||
247 | { | ||
248 | struct pci_dev *pdev = to_pci_dev(host->dev); | ||
249 | struct pdc_host_priv *hpriv = host->private_data; | ||
250 | void __iomem *dimm_mmio = hpriv->dimm_mmio; | ||
251 | |||
252 | pci_iounmap(pdev, dimm_mmio); | ||
253 | kfree(hpriv); | ||
254 | |||
255 | pci_iounmap(pdev, host->mmio_base); | ||
256 | } | ||
257 | |||
258 | static int pdc_port_start(struct ata_port *ap) | 241 | static int pdc_port_start(struct ata_port *ap) |
259 | { | 242 | { |
260 | struct device *dev = ap->host->dev; | 243 | struct device *dev = ap->host->dev; |
@@ -265,43 +248,19 @@ static int pdc_port_start(struct ata_port *ap) | |||
265 | if (rc) | 248 | if (rc) |
266 | return rc; | 249 | return rc; |
267 | 250 | ||
268 | pp = kmalloc(sizeof(*pp), GFP_KERNEL); | 251 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); |
269 | if (!pp) { | 252 | if (!pp) |
270 | rc = -ENOMEM; | 253 | return -ENOMEM; |
271 | goto err_out; | ||
272 | } | ||
273 | memset(pp, 0, sizeof(*pp)); | ||
274 | 254 | ||
275 | pp->pkt = dma_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL); | 255 | pp->pkt = dmam_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL); |
276 | if (!pp->pkt) { | 256 | if (!pp->pkt) |
277 | rc = -ENOMEM; | 257 | return -ENOMEM; |
278 | goto err_out_kfree; | ||
279 | } | ||
280 | 258 | ||
281 | ap->private_data = pp; | 259 | ap->private_data = pp; |
282 | 260 | ||
283 | return 0; | 261 | return 0; |
284 | |||
285 | err_out_kfree: | ||
286 | kfree(pp); | ||
287 | err_out: | ||
288 | ata_port_stop(ap); | ||
289 | return rc; | ||
290 | } | ||
291 | |||
292 | |||
293 | static void pdc_port_stop(struct ata_port *ap) | ||
294 | { | ||
295 | struct device *dev = ap->host->dev; | ||
296 | struct pdc_port_priv *pp = ap->private_data; | ||
297 | |||
298 | ap->private_data = NULL; | ||
299 | dma_free_coherent(dev, 128, pp->pkt, pp->pkt_dma); | ||
300 | kfree(pp); | ||
301 | ata_port_stop(ap); | ||
302 | } | 262 | } |
303 | 263 | ||
304 | |||
305 | static void pdc_20621_phy_reset (struct ata_port *ap) | 264 | static void pdc_20621_phy_reset (struct ata_port *ap) |
306 | { | 265 | { |
307 | VPRINTK("ENTER\n"); | 266 | VPRINTK("ENTER\n"); |
@@ -1365,65 +1324,53 @@ static void pdc_20621_init(struct ata_probe_ent *pe) | |||
1365 | static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 1324 | static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
1366 | { | 1325 | { |
1367 | static int printed_version; | 1326 | static int printed_version; |
1368 | struct ata_probe_ent *probe_ent = NULL; | 1327 | struct ata_probe_ent *probe_ent; |
1369 | unsigned long base; | 1328 | unsigned long base; |
1370 | void __iomem *mmio_base; | 1329 | void __iomem *mmio_base; |
1371 | void __iomem *dimm_mmio = NULL; | 1330 | void __iomem *dimm_mmio; |
1372 | struct pdc_host_priv *hpriv = NULL; | 1331 | struct pdc_host_priv *hpriv; |
1373 | unsigned int board_idx = (unsigned int) ent->driver_data; | 1332 | unsigned int board_idx = (unsigned int) ent->driver_data; |
1374 | int pci_dev_busy = 0; | ||
1375 | int rc; | 1333 | int rc; |
1376 | 1334 | ||
1377 | if (!printed_version++) | 1335 | if (!printed_version++) |
1378 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 1336 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
1379 | 1337 | ||
1380 | rc = pci_enable_device(pdev); | 1338 | rc = pcim_enable_device(pdev); |
1381 | if (rc) | 1339 | if (rc) |
1382 | return rc; | 1340 | return rc; |
1383 | 1341 | ||
1384 | rc = pci_request_regions(pdev, DRV_NAME); | 1342 | rc = pci_request_regions(pdev, DRV_NAME); |
1385 | if (rc) { | 1343 | if (rc) { |
1386 | pci_dev_busy = 1; | 1344 | pcim_pin_device(pdev); |
1387 | goto err_out; | 1345 | return rc; |
1388 | } | 1346 | } |
1389 | 1347 | ||
1390 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 1348 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
1391 | if (rc) | 1349 | if (rc) |
1392 | goto err_out_regions; | 1350 | return rc; |
1393 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | 1351 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); |
1394 | if (rc) | 1352 | if (rc) |
1395 | goto err_out_regions; | 1353 | return rc; |
1396 | 1354 | ||
1397 | probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); | 1355 | probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL); |
1398 | if (probe_ent == NULL) { | 1356 | if (probe_ent == NULL) |
1399 | rc = -ENOMEM; | 1357 | return -ENOMEM; |
1400 | goto err_out_regions; | ||
1401 | } | ||
1402 | 1358 | ||
1403 | memset(probe_ent, 0, sizeof(*probe_ent)); | ||
1404 | probe_ent->dev = pci_dev_to_dev(pdev); | 1359 | probe_ent->dev = pci_dev_to_dev(pdev); |
1405 | INIT_LIST_HEAD(&probe_ent->node); | 1360 | INIT_LIST_HEAD(&probe_ent->node); |
1406 | 1361 | ||
1407 | mmio_base = pci_iomap(pdev, 3, 0); | 1362 | mmio_base = pcim_iomap(pdev, 3, 0); |
1408 | if (mmio_base == NULL) { | 1363 | if (mmio_base == NULL) |
1409 | rc = -ENOMEM; | 1364 | return -ENOMEM; |
1410 | goto err_out_free_ent; | ||
1411 | } | ||
1412 | base = (unsigned long) mmio_base; | 1365 | base = (unsigned long) mmio_base; |
1413 | 1366 | ||
1414 | hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL); | 1367 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); |
1415 | if (!hpriv) { | 1368 | if (!hpriv) |
1416 | rc = -ENOMEM; | 1369 | return -ENOMEM; |
1417 | goto err_out_iounmap; | ||
1418 | } | ||
1419 | memset(hpriv, 0, sizeof(*hpriv)); | ||
1420 | 1370 | ||
1421 | dimm_mmio = pci_iomap(pdev, 4, 0); | 1371 | dimm_mmio = pcim_iomap(pdev, 4, 0); |
1422 | if (!dimm_mmio) { | 1372 | if (!dimm_mmio) |
1423 | kfree(hpriv); | 1373 | return -ENOMEM; |
1424 | rc = -ENOMEM; | ||
1425 | goto err_out_iounmap; | ||
1426 | } | ||
1427 | 1374 | ||
1428 | hpriv->dimm_mmio = dimm_mmio; | 1375 | hpriv->dimm_mmio = dimm_mmio; |
1429 | 1376 | ||
@@ -1451,31 +1398,15 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id * | |||
1451 | 1398 | ||
1452 | /* initialize adapter */ | 1399 | /* initialize adapter */ |
1453 | /* initialize local dimm */ | 1400 | /* initialize local dimm */ |
1454 | if (pdc20621_dimm_init(probe_ent)) { | 1401 | if (pdc20621_dimm_init(probe_ent)) |
1455 | rc = -ENOMEM; | 1402 | return -ENOMEM; |
1456 | goto err_out_iounmap_dimm; | ||
1457 | } | ||
1458 | pdc_20621_init(probe_ent); | 1403 | pdc_20621_init(probe_ent); |
1459 | 1404 | ||
1460 | /* FIXME: check ata_device_add return value */ | 1405 | if (!ata_device_add(probe_ent)) |
1461 | ata_device_add(probe_ent); | 1406 | return -ENODEV; |
1462 | kfree(probe_ent); | ||
1463 | 1407 | ||
1408 | devm_kfree(&pdev->dev, probe_ent); | ||
1464 | return 0; | 1409 | return 0; |
1465 | |||
1466 | err_out_iounmap_dimm: /* only get to this label if 20621 */ | ||
1467 | kfree(hpriv); | ||
1468 | pci_iounmap(pdev, dimm_mmio); | ||
1469 | err_out_iounmap: | ||
1470 | pci_iounmap(pdev, mmio_base); | ||
1471 | err_out_free_ent: | ||
1472 | kfree(probe_ent); | ||
1473 | err_out_regions: | ||
1474 | pci_release_regions(pdev); | ||
1475 | err_out: | ||
1476 | if (!pci_dev_busy) | ||
1477 | pci_disable_device(pdev); | ||
1478 | return rc; | ||
1479 | } | 1410 | } |
1480 | 1411 | ||
1481 | 1412 | ||