diff options
Diffstat (limited to 'drivers/ata/sata_inic162x.c')
-rw-r--r-- | drivers/ata/sata_inic162x.c | 78 |
1 files changed, 29 insertions, 49 deletions
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c index ca4092aaae5b..f099a1d83a00 100644 --- a/drivers/ata/sata_inic162x.c +++ b/drivers/ata/sata_inic162x.c | |||
@@ -559,7 +559,6 @@ static struct ata_port_operations inic_port_ops = { | |||
559 | .bmdma_stop = inic_bmdma_stop, | 559 | .bmdma_stop = inic_bmdma_stop, |
560 | .bmdma_status = inic_bmdma_status, | 560 | .bmdma_status = inic_bmdma_status, |
561 | 561 | ||
562 | .irq_handler = inic_interrupt, | ||
563 | .irq_clear = inic_irq_clear, | 562 | .irq_clear = inic_irq_clear, |
564 | .irq_on = ata_irq_on, | 563 | .irq_on = ata_irq_on, |
565 | .irq_ack = ata_irq_ack, | 564 | .irq_ack = ata_irq_ack, |
@@ -580,7 +579,6 @@ static struct ata_port_operations inic_port_ops = { | |||
580 | }; | 579 | }; |
581 | 580 | ||
582 | static struct ata_port_info inic_port_info = { | 581 | static struct ata_port_info inic_port_info = { |
583 | .sht = &inic_sht, | ||
584 | /* For some reason, ATA_PROT_ATAPI is broken on this | 582 | /* For some reason, ATA_PROT_ATAPI is broken on this |
585 | * controller, and no, PIO_POLLING does't fix it. It somehow | 583 | * controller, and no, PIO_POLLING does't fix it. It somehow |
586 | * manages to report the wrong ireason and ignoring ireason | 584 | * manages to report the wrong ireason and ignoring ireason |
@@ -661,8 +659,8 @@ static int inic_pci_device_resume(struct pci_dev *pdev) | |||
661 | static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | 659 | static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
662 | { | 660 | { |
663 | static int printed_version; | 661 | static int printed_version; |
664 | struct ata_port_info *pinfo = &inic_port_info; | 662 | const struct ata_port_info *ppi[] = { &inic_port_info, NULL }; |
665 | struct ata_probe_ent *probe_ent; | 663 | struct ata_host *host; |
666 | struct inic_host_priv *hpriv; | 664 | struct inic_host_priv *hpriv; |
667 | void __iomem * const *iomap; | 665 | void __iomem * const *iomap; |
668 | int i, rc; | 666 | int i, rc; |
@@ -670,6 +668,15 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
670 | if (!printed_version++) | 668 | if (!printed_version++) |
671 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 669 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
672 | 670 | ||
671 | /* alloc host */ | ||
672 | host = ata_host_alloc_pinfo(&pdev->dev, ppi, NR_PORTS); | ||
673 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); | ||
674 | if (!host || !hpriv) | ||
675 | return -ENOMEM; | ||
676 | |||
677 | host->private_data = hpriv; | ||
678 | |||
679 | /* acquire resources and fill host */ | ||
673 | rc = pcim_enable_device(pdev); | 680 | rc = pcim_enable_device(pdev); |
674 | if (rc) | 681 | if (rc) |
675 | return rc; | 682 | return rc; |
@@ -677,7 +684,22 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
677 | rc = pcim_iomap_regions(pdev, 0x3f, DRV_NAME); | 684 | rc = pcim_iomap_regions(pdev, 0x3f, DRV_NAME); |
678 | if (rc) | 685 | if (rc) |
679 | return rc; | 686 | return rc; |
680 | iomap = pcim_iomap_table(pdev); | 687 | host->iomap = iomap = pcim_iomap_table(pdev); |
688 | |||
689 | for (i = 0; i < NR_PORTS; i++) { | ||
690 | struct ata_ioports *port = &host->ports[i]->ioaddr; | ||
691 | void __iomem *port_base = iomap[MMIO_BAR] + i * PORT_SIZE; | ||
692 | |||
693 | port->cmd_addr = iomap[2 * i]; | ||
694 | port->altstatus_addr = | ||
695 | port->ctl_addr = (void __iomem *) | ||
696 | ((unsigned long)iomap[2 * i + 1] | ATA_PCI_CTL_OFS); | ||
697 | port->scr_addr = port_base + PORT_SCR; | ||
698 | |||
699 | ata_std_ports(port); | ||
700 | } | ||
701 | |||
702 | hpriv->cached_hctl = readw(iomap[MMIO_BAR] + HOST_CTL); | ||
681 | 703 | ||
682 | /* Set dma_mask. This devices doesn't support 64bit addressing. */ | 704 | /* Set dma_mask. This devices doesn't support 64bit addressing. */ |
683 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | 705 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); |
@@ -694,43 +716,6 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
694 | return rc; | 716 | return rc; |
695 | } | 717 | } |
696 | 718 | ||
697 | probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL); | ||
698 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); | ||
699 | if (!probe_ent || !hpriv) | ||
700 | return -ENOMEM; | ||
701 | |||
702 | probe_ent->dev = &pdev->dev; | ||
703 | INIT_LIST_HEAD(&probe_ent->node); | ||
704 | |||
705 | probe_ent->sht = pinfo->sht; | ||
706 | probe_ent->port_flags = pinfo->flags; | ||
707 | probe_ent->pio_mask = pinfo->pio_mask; | ||
708 | probe_ent->mwdma_mask = pinfo->mwdma_mask; | ||
709 | probe_ent->udma_mask = pinfo->udma_mask; | ||
710 | probe_ent->port_ops = pinfo->port_ops; | ||
711 | probe_ent->n_ports = NR_PORTS; | ||
712 | |||
713 | probe_ent->irq = pdev->irq; | ||
714 | probe_ent->irq_flags = IRQF_SHARED; | ||
715 | |||
716 | probe_ent->iomap = iomap; | ||
717 | |||
718 | for (i = 0; i < NR_PORTS; i++) { | ||
719 | struct ata_ioports *port = &probe_ent->port[i]; | ||
720 | void __iomem *port_base = iomap[MMIO_BAR] + i * PORT_SIZE; | ||
721 | |||
722 | port->cmd_addr = iomap[2 * i]; | ||
723 | port->altstatus_addr = | ||
724 | port->ctl_addr = (void __iomem *) | ||
725 | ((unsigned long)iomap[2 * i + 1] | ATA_PCI_CTL_OFS); | ||
726 | port->scr_addr = port_base + PORT_SCR; | ||
727 | |||
728 | ata_std_ports(port); | ||
729 | } | ||
730 | |||
731 | probe_ent->private_data = hpriv; | ||
732 | hpriv->cached_hctl = readw(iomap[MMIO_BAR] + HOST_CTL); | ||
733 | |||
734 | rc = init_controller(iomap[MMIO_BAR], hpriv->cached_hctl); | 719 | rc = init_controller(iomap[MMIO_BAR], hpriv->cached_hctl); |
735 | if (rc) { | 720 | if (rc) { |
736 | dev_printk(KERN_ERR, &pdev->dev, | 721 | dev_printk(KERN_ERR, &pdev->dev, |
@@ -739,13 +724,8 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
739 | } | 724 | } |
740 | 725 | ||
741 | pci_set_master(pdev); | 726 | pci_set_master(pdev); |
742 | 727 | return ata_host_activate(host, pdev->irq, inic_interrupt, IRQF_SHARED, | |
743 | if (!ata_device_add(probe_ent)) | 728 | &inic_sht); |
744 | return -ENODEV; | ||
745 | |||
746 | devm_kfree(&pdev->dev, probe_ent); | ||
747 | |||
748 | return 0; | ||
749 | } | 729 | } |
750 | 730 | ||
751 | static const struct pci_device_id inic_pci_tbl[] = { | 731 | static const struct pci_device_id inic_pci_tbl[] = { |