diff options
Diffstat (limited to 'drivers/ata/sata_via.c')
-rw-r--r-- | drivers/ata/sata_via.c | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c index e95acfac30b9..c7f527578d11 100644 --- a/drivers/ata/sata_via.c +++ b/drivers/ata/sata_via.c | |||
@@ -44,7 +44,6 @@ | |||
44 | #include <linux/device.h> | 44 | #include <linux/device.h> |
45 | #include <scsi/scsi_host.h> | 45 | #include <scsi/scsi_host.h> |
46 | #include <linux/libata.h> | 46 | #include <linux/libata.h> |
47 | #include <asm/io.h> | ||
48 | 47 | ||
49 | #define DRV_NAME "sata_via" | 48 | #define DRV_NAME "sata_via" |
50 | #define DRV_VERSION "2.0" | 49 | #define DRV_VERSION "2.0" |
@@ -146,8 +145,6 @@ static const struct ata_port_operations vt6420_sata_ops = { | |||
146 | .irq_clear = ata_bmdma_irq_clear, | 145 | .irq_clear = ata_bmdma_irq_clear, |
147 | 146 | ||
148 | .port_start = ata_port_start, | 147 | .port_start = ata_port_start, |
149 | .port_stop = ata_port_stop, | ||
150 | .host_stop = ata_host_stop, | ||
151 | }; | 148 | }; |
152 | 149 | ||
153 | static const struct ata_port_operations vt6421_pata_ops = { | 150 | static const struct ata_port_operations vt6421_pata_ops = { |
@@ -180,8 +177,6 @@ static const struct ata_port_operations vt6421_pata_ops = { | |||
180 | .irq_clear = ata_bmdma_irq_clear, | 177 | .irq_clear = ata_bmdma_irq_clear, |
181 | 178 | ||
182 | .port_start = vt6421_port_start, | 179 | .port_start = vt6421_port_start, |
183 | .port_stop = ata_port_stop, | ||
184 | .host_stop = ata_host_stop, | ||
185 | }; | 180 | }; |
186 | 181 | ||
187 | static const struct ata_port_operations vt6421_sata_ops = { | 182 | static const struct ata_port_operations vt6421_sata_ops = { |
@@ -214,8 +209,6 @@ static const struct ata_port_operations vt6421_sata_ops = { | |||
214 | .scr_write = svia_scr_write, | 209 | .scr_write = svia_scr_write, |
215 | 210 | ||
216 | .port_start = vt6421_port_start, | 211 | .port_start = vt6421_port_start, |
217 | .port_stop = ata_port_stop, | ||
218 | .host_stop = ata_host_stop, | ||
219 | }; | 212 | }; |
220 | 213 | ||
221 | static struct ata_port_info vt6420_port_info = { | 214 | static struct ata_port_info vt6420_port_info = { |
@@ -446,7 +439,7 @@ static struct ata_probe_ent *vt6421_init_probe_ent(struct pci_dev *pdev) | |||
446 | struct ata_probe_ent *probe_ent; | 439 | struct ata_probe_ent *probe_ent; |
447 | unsigned int i; | 440 | unsigned int i; |
448 | 441 | ||
449 | probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); | 442 | probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL); |
450 | if (!probe_ent) | 443 | if (!probe_ent) |
451 | return NULL; | 444 | return NULL; |
452 | 445 | ||
@@ -517,20 +510,19 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
517 | struct ata_probe_ent *probe_ent; | 510 | struct ata_probe_ent *probe_ent; |
518 | int board_id = (int) ent->driver_data; | 511 | int board_id = (int) ent->driver_data; |
519 | const int *bar_sizes; | 512 | const int *bar_sizes; |
520 | int pci_dev_busy = 0; | ||
521 | u8 tmp8; | 513 | u8 tmp8; |
522 | 514 | ||
523 | if (!printed_version++) | 515 | if (!printed_version++) |
524 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 516 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
525 | 517 | ||
526 | rc = pci_enable_device(pdev); | 518 | rc = pcim_enable_device(pdev); |
527 | if (rc) | 519 | if (rc) |
528 | return rc; | 520 | return rc; |
529 | 521 | ||
530 | rc = pci_request_regions(pdev, DRV_NAME); | 522 | rc = pci_request_regions(pdev, DRV_NAME); |
531 | if (rc) { | 523 | if (rc) { |
532 | pci_dev_busy = 1; | 524 | pcim_pin_device(pdev); |
533 | goto err_out; | 525 | return rc; |
534 | } | 526 | } |
535 | 527 | ||
536 | if (board_id == vt6420) { | 528 | if (board_id == vt6420) { |
@@ -539,8 +531,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
539 | dev_printk(KERN_ERR, &pdev->dev, | 531 | dev_printk(KERN_ERR, &pdev->dev, |
540 | "SATA master/slave not supported (0x%x)\n", | 532 | "SATA master/slave not supported (0x%x)\n", |
541 | (int) tmp8); | 533 | (int) tmp8); |
542 | rc = -EIO; | 534 | return -EIO; |
543 | goto err_out_regions; | ||
544 | } | 535 | } |
545 | 536 | ||
546 | bar_sizes = &svia_bar_sizes[0]; | 537 | bar_sizes = &svia_bar_sizes[0]; |
@@ -556,16 +547,15 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
556 | i, | 547 | i, |
557 | (unsigned long long)pci_resource_start(pdev, i), | 548 | (unsigned long long)pci_resource_start(pdev, i), |
558 | (unsigned long long)pci_resource_len(pdev, i)); | 549 | (unsigned long long)pci_resource_len(pdev, i)); |
559 | rc = -ENODEV; | 550 | return -ENODEV; |
560 | goto err_out_regions; | ||
561 | } | 551 | } |
562 | 552 | ||
563 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 553 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
564 | if (rc) | 554 | if (rc) |
565 | goto err_out_regions; | 555 | return rc; |
566 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | 556 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); |
567 | if (rc) | 557 | if (rc) |
568 | goto err_out_regions; | 558 | return rc; |
569 | 559 | ||
570 | if (board_id == vt6420) | 560 | if (board_id == vt6420) |
571 | probe_ent = vt6420_init_probe_ent(pdev); | 561 | probe_ent = vt6420_init_probe_ent(pdev); |
@@ -574,26 +564,18 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
574 | 564 | ||
575 | if (!probe_ent) { | 565 | if (!probe_ent) { |
576 | dev_printk(KERN_ERR, &pdev->dev, "out of memory\n"); | 566 | dev_printk(KERN_ERR, &pdev->dev, "out of memory\n"); |
577 | rc = -ENOMEM; | 567 | return -ENOMEM; |
578 | goto err_out_regions; | ||
579 | } | 568 | } |
580 | 569 | ||
581 | svia_configure(pdev); | 570 | svia_configure(pdev); |
582 | 571 | ||
583 | pci_set_master(pdev); | 572 | pci_set_master(pdev); |
584 | 573 | ||
585 | /* FIXME: check ata_device_add return value */ | 574 | if (!ata_device_add(probe_ent)) |
586 | ata_device_add(probe_ent); | 575 | return -ENODEV; |
587 | kfree(probe_ent); | ||
588 | 576 | ||
577 | devm_kfree(&pdev->dev, probe_ent); | ||
589 | return 0; | 578 | return 0; |
590 | |||
591 | err_out_regions: | ||
592 | pci_release_regions(pdev); | ||
593 | err_out: | ||
594 | if (!pci_dev_busy) | ||
595 | pci_disable_device(pdev); | ||
596 | return rc; | ||
597 | } | 579 | } |
598 | 580 | ||
599 | static int __init svia_init(void) | 581 | static int __init svia_init(void) |