diff options
author | Tejun Heo <htejun@gmail.com> | 2007-01-20 08:00:28 +0100 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-02-09 23:39:37 +0100 |
commit | 24dc5f33ea4b504cfbd23fa159a4cacba8e4d800 (patch) | |
tree | d76de456157f555c9a65b83f426fd805fee1e846 /drivers/ata/sata_svw.c | |
parent | libata: update libata core layer to use devres (diff) | |
download | linux-24dc5f33ea4b504cfbd23fa159a4cacba8e4d800.tar.xz linux-24dc5f33ea4b504cfbd23fa159a4cacba8e4d800.zip |
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.c | 48 |
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 = { .scr_read = k2_sata_scr_read, .scr_write = k2_sata_scr_write, .port_start = ata_port_start, - .port_stop = ata_port_stop, - .host_stop = ata_pci_host_stop, }; static 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) static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; - struct ata_probe_ent *probe_ent = NULL; + struct device *dev = &pdev->dev; + struct ata_probe_ent *probe_ent; unsigned long base; void __iomem *mmio_base; const struct k2_board_info *board_info = &k2_board_info[ent->driver_data]; - int pci_dev_busy = 0; int rc; int i; @@ -402,7 +400,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e * If this driver happens to only be useful on Apple's K2, then * we should check that here as it has a normal Serverworks ID */ - rc = pci_enable_device(pdev); + rc = pcim_enable_device(pdev); if (rc) return rc; /* @@ -415,32 +413,27 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e /* Request PCI regions */ rc = pci_request_regions(pdev, DRV_NAME); if (rc) { - pci_dev_busy = 1; - goto err_out; + pcim_pin_device(pdev); + return rc; } rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); if (rc) - goto err_out_regions; + return rc; rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); if (rc) - goto err_out_regions; + return rc; - probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); - if (probe_ent == NULL) { - rc = -ENOMEM; - goto err_out_regions; - } + probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL); + if (probe_ent == NULL) + return -ENOMEM; - memset(probe_ent, 0, sizeof(*probe_ent)); probe_ent->dev = pci_dev_to_dev(pdev); INIT_LIST_HEAD(&probe_ent->node); - mmio_base = pci_iomap(pdev, 5, 0); - if (mmio_base == NULL) { - rc = -ENOMEM; - goto err_out_free_ent; - } + mmio_base = pcim_iomap(pdev, 5, 0); + if (mmio_base == NULL) + return -ENOMEM; base = (unsigned long) mmio_base; /* 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 pci_set_master(pdev); - /* FIXME: check ata_device_add return value */ - ata_device_add(probe_ent); - kfree(probe_ent); + if (!ata_device_add(probe_ent)) + return -ENODEV; + devm_kfree(dev, probe_ent); return 0; - -err_out_free_ent: - kfree(probe_ent); -err_out_regions: - pci_release_regions(pdev); -err_out: - if (!pci_dev_busy) - pci_disable_device(pdev); - return rc; } /* 0x240 is device ID for Apple K2 device |