aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/sata_svw.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-01-20 02:00:28 -0500
committerJeff Garzik <jeff@garzik.org>2007-02-09 17:39:37 -0500
commit24dc5f33ea4b504cfbd23fa159a4cacba8e4d800 (patch)
treed76de456157f555c9a65b83f426fd805fee1e846 /drivers/ata/sata_svw.c
parentf0d36efdc624beb3d9e29b9ab9e9537bf0f25d5b (diff)
libata: update libata LLDs to use devres
Update libata LLDs to use devres. Core layer is already converted to support managed LLDs. This patch simplifies initialization and fixes many resource related bugs in init failure and detach path. For example, all converted drivers now handle ata_device_add() failure gracefully without excessive resource rollback code. As most resources are released automatically on driver detach, many drivers don't need or can do with much simpler ->{port|host}_stop(). In general, stop callbacks are need iff port or host needs to be given commands to shut it down. Note that freezing is enough in many cases and ports are automatically frozen before being detached. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/sata_svw.c')
-rw-r--r--drivers/ata/sata_svw.c48
1 files changed, 16 insertions, 32 deletions
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
index 5f4e82ade6cd..9c48b418ad7f 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -359,8 +359,6 @@ static const struct ata_port_operations k2_sata_ops = {
359 .scr_read = k2_sata_scr_read, 359 .scr_read = k2_sata_scr_read,
360 .scr_write = k2_sata_scr_write, 360 .scr_write = k2_sata_scr_write,
361 .port_start = ata_port_start, 361 .port_start = ata_port_start,
362 .port_stop = ata_port_stop,
363 .host_stop = ata_pci_host_stop,
364}; 362};
365 363
366static void k2_sata_setup_port(struct ata_ioports *port, unsigned long base) 364static void k2_sata_setup_port(struct ata_ioports *port, unsigned long base)
@@ -386,12 +384,12 @@ static void k2_sata_setup_port(struct ata_ioports *port, unsigned long base)
386static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 384static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
387{ 385{
388 static int printed_version; 386 static int printed_version;
389 struct ata_probe_ent *probe_ent = NULL; 387 struct device *dev = &pdev->dev;
388 struct ata_probe_ent *probe_ent;
390 unsigned long base; 389 unsigned long base;
391 void __iomem *mmio_base; 390 void __iomem *mmio_base;
392 const struct k2_board_info *board_info = 391 const struct k2_board_info *board_info =
393 &k2_board_info[ent->driver_data]; 392 &k2_board_info[ent->driver_data];
394 int pci_dev_busy = 0;
395 int rc; 393 int rc;
396 int i; 394 int i;
397 395
@@ -402,7 +400,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
402 * If this driver happens to only be useful on Apple's K2, then 400 * If this driver happens to only be useful on Apple's K2, then
403 * we should check that here as it has a normal Serverworks ID 401 * we should check that here as it has a normal Serverworks ID
404 */ 402 */
405 rc = pci_enable_device(pdev); 403 rc = pcim_enable_device(pdev);
406 if (rc) 404 if (rc)
407 return rc; 405 return rc;
408 /* 406 /*
@@ -415,32 +413,27 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
415 /* Request PCI regions */ 413 /* Request PCI regions */
416 rc = pci_request_regions(pdev, DRV_NAME); 414 rc = pci_request_regions(pdev, DRV_NAME);
417 if (rc) { 415 if (rc) {
418 pci_dev_busy = 1; 416 pcim_pin_device(pdev);
419 goto err_out; 417 return rc;
420 } 418 }
421 419
422 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); 420 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
423 if (rc) 421 if (rc)
424 goto err_out_regions; 422 return rc;
425 rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); 423 rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
426 if (rc) 424 if (rc)
427 goto err_out_regions; 425 return rc;
428 426
429 probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); 427 probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL);
430 if (probe_ent == NULL) { 428 if (probe_ent == NULL)
431 rc = -ENOMEM; 429 return -ENOMEM;
432 goto err_out_regions;
433 }
434 430
435 memset(probe_ent, 0, sizeof(*probe_ent));
436 probe_ent->dev = pci_dev_to_dev(pdev); 431 probe_ent->dev = pci_dev_to_dev(pdev);
437 INIT_LIST_HEAD(&probe_ent->node); 432 INIT_LIST_HEAD(&probe_ent->node);
438 433
439 mmio_base = pci_iomap(pdev, 5, 0); 434 mmio_base = pcim_iomap(pdev, 5, 0);
440 if (mmio_base == NULL) { 435 if (mmio_base == NULL)
441 rc = -ENOMEM; 436 return -ENOMEM;
442 goto err_out_free_ent;
443 }
444 base = (unsigned long) mmio_base; 437 base = (unsigned long) mmio_base;
445 438
446 /* Clear a magic bit in SCR1 according to Darwin, those help 439 /* Clear a magic bit in SCR1 according to Darwin, those help
@@ -478,20 +471,11 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
478 471
479 pci_set_master(pdev); 472 pci_set_master(pdev);
480 473
481 /* FIXME: check ata_device_add return value */ 474 if (!ata_device_add(probe_ent))
482 ata_device_add(probe_ent); 475 return -ENODEV;
483 kfree(probe_ent);
484 476
477 devm_kfree(dev, probe_ent);
485 return 0; 478 return 0;
486
487err_out_free_ent:
488 kfree(probe_ent);
489err_out_regions:
490 pci_release_regions(pdev);
491err_out:
492 if (!pci_dev_busy)
493 pci_disable_device(pdev);
494 return rc;
495} 479}
496 480
497/* 0x240 is device ID for Apple K2 device 481/* 0x240 is device ID for Apple K2 device