diff options
author | Tejun Heo <htejun@gmail.com> | 2007-01-20 02:00:28 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-02-09 17:39:37 -0500 |
commit | 24dc5f33ea4b504cfbd23fa159a4cacba8e4d800 (patch) | |
tree | d76de456157f555c9a65b83f426fd805fee1e846 /drivers/ata/sata_sil.c | |
parent | f0d36efdc624beb3d9e29b9ab9e9537bf0f25d5b (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_sil.c')
-rw-r--r-- | drivers/ata/sata_sil.c | 47 |
1 files changed, 16 insertions, 31 deletions
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c index 1f3fdcf29876..00f2465dcdce 100644 --- a/drivers/ata/sata_sil.c +++ b/drivers/ata/sata_sil.c | |||
@@ -210,8 +210,6 @@ static const struct ata_port_operations sil_ops = { | |||
210 | .scr_read = sil_scr_read, | 210 | .scr_read = sil_scr_read, |
211 | .scr_write = sil_scr_write, | 211 | .scr_write = sil_scr_write, |
212 | .port_start = ata_port_start, | 212 | .port_start = ata_port_start, |
213 | .port_stop = ata_port_stop, | ||
214 | .host_stop = ata_pci_host_stop, | ||
215 | }; | 213 | }; |
216 | 214 | ||
217 | static const struct ata_port_info sil_port_info[] = { | 215 | static const struct ata_port_info sil_port_info[] = { |
@@ -621,38 +619,36 @@ static void sil_init_controller(struct pci_dev *pdev, | |||
621 | static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 619 | static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
622 | { | 620 | { |
623 | static int printed_version; | 621 | static int printed_version; |
624 | struct ata_probe_ent *probe_ent = NULL; | 622 | struct device *dev = &pdev->dev; |
623 | struct ata_probe_ent *probe_ent; | ||
625 | unsigned long base; | 624 | unsigned long base; |
626 | void __iomem *mmio_base; | 625 | void __iomem *mmio_base; |
627 | int rc; | 626 | int rc; |
628 | unsigned int i; | 627 | unsigned int i; |
629 | int pci_dev_busy = 0; | ||
630 | 628 | ||
631 | if (!printed_version++) | 629 | if (!printed_version++) |
632 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 630 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
633 | 631 | ||
634 | rc = pci_enable_device(pdev); | 632 | rc = pcim_enable_device(pdev); |
635 | if (rc) | 633 | if (rc) |
636 | return rc; | 634 | return rc; |
637 | 635 | ||
638 | rc = pci_request_regions(pdev, DRV_NAME); | 636 | rc = pci_request_regions(pdev, DRV_NAME); |
639 | if (rc) { | 637 | if (rc) { |
640 | pci_dev_busy = 1; | 638 | pcim_pin_device(pdev); |
641 | goto err_out; | 639 | return rc; |
642 | } | 640 | } |
643 | 641 | ||
644 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 642 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
645 | if (rc) | 643 | if (rc) |
646 | goto err_out_regions; | 644 | return rc; |
647 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | 645 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); |
648 | if (rc) | 646 | if (rc) |
649 | goto err_out_regions; | 647 | return rc; |
650 | 648 | ||
651 | probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL); | 649 | probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL); |
652 | if (probe_ent == NULL) { | 650 | if (probe_ent == NULL) |
653 | rc = -ENOMEM; | 651 | return -ENOMEM; |
654 | goto err_out_regions; | ||
655 | } | ||
656 | 652 | ||
657 | INIT_LIST_HEAD(&probe_ent->node); | 653 | INIT_LIST_HEAD(&probe_ent->node); |
658 | probe_ent->dev = pci_dev_to_dev(pdev); | 654 | probe_ent->dev = pci_dev_to_dev(pdev); |
@@ -666,11 +662,9 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
666 | probe_ent->irq_flags = IRQF_SHARED; | 662 | probe_ent->irq_flags = IRQF_SHARED; |
667 | probe_ent->port_flags = sil_port_info[ent->driver_data].flags; | 663 | probe_ent->port_flags = sil_port_info[ent->driver_data].flags; |
668 | 664 | ||
669 | mmio_base = pci_iomap(pdev, 5, 0); | 665 | mmio_base = pcim_iomap(pdev, 5, 0); |
670 | if (mmio_base == NULL) { | 666 | if (mmio_base == NULL) |
671 | rc = -ENOMEM; | 667 | return -ENOMEM; |
672 | goto err_out_free_ent; | ||
673 | } | ||
674 | 668 | ||
675 | probe_ent->mmio_base = mmio_base; | 669 | probe_ent->mmio_base = mmio_base; |
676 | 670 | ||
@@ -690,20 +684,11 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
690 | 684 | ||
691 | pci_set_master(pdev); | 685 | pci_set_master(pdev); |
692 | 686 | ||
693 | /* FIXME: check ata_device_add return value */ | 687 | if (!ata_device_add(probe_ent)) |
694 | ata_device_add(probe_ent); | 688 | return -ENODEV; |
695 | kfree(probe_ent); | ||
696 | 689 | ||
690 | devm_kfree(dev, probe_ent); | ||
697 | return 0; | 691 | return 0; |
698 | |||
699 | err_out_free_ent: | ||
700 | kfree(probe_ent); | ||
701 | err_out_regions: | ||
702 | pci_release_regions(pdev); | ||
703 | err_out: | ||
704 | if (!pci_dev_busy) | ||
705 | pci_disable_device(pdev); | ||
706 | return rc; | ||
707 | } | 692 | } |
708 | 693 | ||
709 | #ifdef CONFIG_PM | 694 | #ifdef CONFIG_PM |