aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-03-09 05:43:35 -0500
committerJeff Garzik <jeff@garzik.org>2007-04-28 14:16:02 -0400
commit55a6adeea4077521b4bba1dfe674f5835157a00b (patch)
tree908e61d7a0a828bc9625b38bc1e22e0645230ade /drivers/ata
parent17199b187b5d9a22f2ec835c9fdb38302501b918 (diff)
libata: fix native mode disabled port handling
Disabled port handling in ata_pci_init_native_mode() is slightly broken in that it may end up using the wrong port_info. This patch updates it such that disables ports are made dummy as done in the legacy and other cases. While at it, fix indentation in ata_resources_present(). Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/libata-sff.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 0a194660fd21..93cc96782165 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -526,8 +526,8 @@ static int ata_resources_present(struct pci_dev *pdev, int port)
526 port = port * 2; 526 port = port * 2;
527 for (i = 0; i < 2; i ++) { 527 for (i = 0; i < 2; i ++) {
528 if (pci_resource_start(pdev, port + i) == 0 || 528 if (pci_resource_start(pdev, port + i) == 0 ||
529 pci_resource_len(pdev, port + i) == 0) 529 pci_resource_len(pdev, port + i) == 0)
530 return 0; 530 return 0;
531 } 531 }
532 return 1; 532 return 1;
533} 533}
@@ -554,11 +554,26 @@ struct ata_probe_ent *
554ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int ports) 554ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int ports)
555{ 555{
556 struct ata_probe_ent *probe_ent; 556 struct ata_probe_ent *probe_ent;
557 int i, p = 0; 557 int i;
558 void __iomem * const *iomap; 558 void __iomem * const *iomap;
559 559
560 /* Discard disabled ports. Some controllers show their unused
561 * channels this way. Disabled ports will be made dummy.
562 */
563 if (ata_resources_present(pdev, 0) == 0)
564 ports &= ~ATA_PORT_PRIMARY;
565 if (ata_resources_present(pdev, 1) == 0)
566 ports &= ~ATA_PORT_SECONDARY;
567
568 if (!ports) {
569 dev_printk(KERN_ERR, &pdev->dev, "no available port\n");
570 return NULL;
571 }
572
560 /* iomap BARs */ 573 /* iomap BARs */
561 for (i = 0; i < 4; i++) { 574 for (i = 0; i < 4; i++) {
575 if (!(ports & (1 << (i / 2))))
576 continue;
562 if (pcim_iomap(pdev, i, 0) == NULL) { 577 if (pcim_iomap(pdev, i, 0) == NULL) {
563 dev_printk(KERN_ERR, &pdev->dev, 578 dev_printk(KERN_ERR, &pdev->dev,
564 "failed to iomap PCI BAR %d\n", i); 579 "failed to iomap PCI BAR %d\n", i);
@@ -574,48 +589,41 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
574 if (!probe_ent) 589 if (!probe_ent)
575 return NULL; 590 return NULL;
576 591
592 probe_ent->n_ports = 2;
577 probe_ent->irq = pdev->irq; 593 probe_ent->irq = pdev->irq;
578 probe_ent->irq_flags = IRQF_SHARED; 594 probe_ent->irq_flags = IRQF_SHARED;
579 595
580 /* Discard disabled ports. Some controllers show their
581 unused channels this way */
582 if (ata_resources_present(pdev, 0) == 0)
583 ports &= ~ATA_PORT_PRIMARY;
584 if (ata_resources_present(pdev, 1) == 0)
585 ports &= ~ATA_PORT_SECONDARY;
586
587 if (ports & ATA_PORT_PRIMARY) { 596 if (ports & ATA_PORT_PRIMARY) {
588 probe_ent->port[p].cmd_addr = iomap[0]; 597 probe_ent->port[0].cmd_addr = iomap[0];
589 probe_ent->port[p].altstatus_addr = 598 probe_ent->port[0].altstatus_addr =
590 probe_ent->port[p].ctl_addr = (void __iomem *) 599 probe_ent->port[0].ctl_addr = (void __iomem *)
591 ((unsigned long)iomap[1] | ATA_PCI_CTL_OFS); 600 ((unsigned long)iomap[1] | ATA_PCI_CTL_OFS);
592 if (iomap[4]) { 601 if (iomap[4]) {
593 if ((!(port[p]->flags & ATA_FLAG_IGN_SIMPLEX)) && 602 if ((!(port[0]->flags & ATA_FLAG_IGN_SIMPLEX)) &&
594 (ioread8(iomap[4] + 2) & 0x80)) 603 (ioread8(iomap[4] + 2) & 0x80))
595 probe_ent->_host_flags |= ATA_HOST_SIMPLEX; 604 probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
596 probe_ent->port[p].bmdma_addr = iomap[4]; 605 probe_ent->port[0].bmdma_addr = iomap[4];
597 } 606 }
598 ata_std_ports(&probe_ent->port[p]); 607 ata_std_ports(&probe_ent->port[0]);
599 p++; 608 } else
600 } 609 probe_ent->dummy_port_mask |= ATA_PORT_PRIMARY;
601 610
602 if (ports & ATA_PORT_SECONDARY) { 611 if (ports & ATA_PORT_SECONDARY) {
603 probe_ent->port[p].cmd_addr = iomap[2]; 612 probe_ent->port[1].cmd_addr = iomap[2];
604 probe_ent->port[p].altstatus_addr = 613 probe_ent->port[1].altstatus_addr =
605 probe_ent->port[p].ctl_addr = (void __iomem *) 614 probe_ent->port[1].ctl_addr = (void __iomem *)
606 ((unsigned long)iomap[3] | ATA_PCI_CTL_OFS); 615 ((unsigned long)iomap[3] | ATA_PCI_CTL_OFS);
607 if (iomap[4]) { 616 if (iomap[4]) {
608 if ((!(port[p]->flags & ATA_FLAG_IGN_SIMPLEX)) && 617 if ((!(port[1]->flags & ATA_FLAG_IGN_SIMPLEX)) &&
609 (ioread8(iomap[4] + 10) & 0x80)) 618 (ioread8(iomap[4] + 10) & 0x80))
610 probe_ent->_host_flags |= ATA_HOST_SIMPLEX; 619 probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
611 probe_ent->port[p].bmdma_addr = iomap[4] + 8; 620 probe_ent->port[1].bmdma_addr = iomap[4] + 8;
612 } 621 }
613 ata_std_ports(&probe_ent->port[p]); 622 ata_std_ports(&probe_ent->port[1]);
614 probe_ent->pinfo2 = port[1]; 623 probe_ent->pinfo2 = port[1];
615 p++; 624 } else
616 } 625 probe_ent->dummy_port_mask |= ATA_PORT_SECONDARY;
617 626
618 probe_ent->n_ports = p;
619 return probe_ent; 627 return probe_ent;
620} 628}
621 629