Skip to content

Commit 4447d35

Browse files
htejunJeff Garzik
authored andcommitted
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv, sata_sx4, sata_vsc and sata_inic162x to new init model. Now that host and ap are available during intialization, functions are converted to take either host or ap instead of low level parameters which were inevitable for functions shared between init and other paths. This simplifies code quite a bit. * init_one()'s now follow more consistent init order * ahci_setup_port() and ahci_host_init() collapsed into ahci_init_one() for init order consistency * sata_vsc uses port_info instead of setting fields manually * in sata_svw, k2_board_info converted to port_info (info is now in port flags). port number is honored now. Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
1 parent 9a829cc commit 4447d35

File tree

9 files changed

+444
-657
lines changed

9 files changed

+444
-657
lines changed

drivers/ata/ahci.c

Lines changed: 135 additions & 192 deletions
Large diffs are not rendered by default.

drivers/ata/sata_inic162x.c

Lines changed: 29 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,6 @@ static struct ata_port_operations inic_port_ops = {
559559
.bmdma_stop = inic_bmdma_stop,
560560
.bmdma_status = inic_bmdma_status,
561561

562-
.irq_handler = inic_interrupt,
563562
.irq_clear = inic_irq_clear,
564563
.irq_on = ata_irq_on,
565564
.irq_ack = ata_irq_ack,
@@ -580,7 +579,6 @@ static struct ata_port_operations inic_port_ops = {
580579
};
581580

582581
static struct ata_port_info inic_port_info = {
583-
.sht = &inic_sht,
584582
/* For some reason, ATA_PROT_ATAPI is broken on this
585583
* controller, and no, PIO_POLLING does't fix it. It somehow
586584
* manages to report the wrong ireason and ignoring ireason
@@ -661,23 +659,47 @@ static int inic_pci_device_resume(struct pci_dev *pdev)
661659
static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
662660
{
663661
static int printed_version;
664-
struct ata_port_info *pinfo = &inic_port_info;
665-
struct ata_probe_ent *probe_ent;
662+
const struct ata_port_info *ppi[] = { &inic_port_info, NULL };
663+
struct ata_host *host;
666664
struct inic_host_priv *hpriv;
667665
void __iomem * const *iomap;
668666
int i, rc;
669667

670668
if (!printed_version++)
671669
dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
672670

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 */
673680
rc = pcim_enable_device(pdev);
674681
if (rc)
675682
return rc;
676683

677684
rc = pcim_iomap_regions(pdev, 0x3f, DRV_NAME);
678685
if (rc)
679686
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);
681703

682704
/* Set dma_mask. This devices doesn't support 64bit addressing. */
683705
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)
694716
return rc;
695717
}
696718

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-
734719
rc = init_controller(iomap[MMIO_BAR], hpriv->cached_hctl);
735720
if (rc) {
736721
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)
739724
}
740725

741726
pci_set_master(pdev);
742-
743-
if (!ata_device_add(probe_ent))
744-
return -ENODEV;
745-
746-
devm_kfree(&pdev->dev, probe_ent);
747-
748-
return 0;
727+
return ata_host_activate(host, pdev->irq, inic_interrupt, IRQF_SHARED,
728+
&inic_sht);
749729
}
750730

751731
static const struct pci_device_id inic_pci_tbl[] = {

0 commit comments

Comments
 (0)