aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/setup-pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/setup-pci.c')
-rw-r--r--drivers/ide/setup-pci.c67
1 files changed, 13 insertions, 54 deletions
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index 4e9de2043113..252cb8c5931a 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -512,7 +512,7 @@ out:
512 * @dev: PCI device 512 * @dev: PCI device
513 * @d: IDE pci device info 513 * @d: IDE pci device info
514 * @pciirq: IRQ line 514 * @pciirq: IRQ line
515 * @index: ata index to update 515 * @idx: ATA index table to update
516 * 516 *
517 * Scan the interfaces attached to this device and do any 517 * Scan the interfaces attached to this device and do any
518 * necessary per port setup. Attach the devices and ask the 518 * necessary per port setup. Attach the devices and ask the
@@ -522,15 +522,13 @@ out:
522 * but is also used directly as a helper function by some controllers 522 * but is also used directly as a helper function by some controllers
523 * where the chipset setup is not the default PCI IDE one. 523 * where the chipset setup is not the default PCI IDE one.
524 */ 524 */
525 525
526void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, ata_index_t *index) 526void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, u8 *idx)
527{ 527{
528 int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; 528 int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port;
529 ide_hwif_t *hwif, *mate = NULL; 529 ide_hwif_t *hwif, *mate = NULL;
530 u8 tmp; 530 u8 tmp;
531 531
532 index->all = 0xf0f0;
533
534 /* 532 /*
535 * Set up the IDE ports 533 * Set up the IDE ports
536 */ 534 */
@@ -550,11 +548,7 @@ void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, a
550 /* setup proper ancestral information */ 548 /* setup proper ancestral information */
551 hwif->gendev.parent = &dev->dev; 549 hwif->gendev.parent = &dev->dev;
552 550
553 if (hwif->channel) { 551 *(idx + port) = hwif->index;
554 index->b.high = hwif->index;
555 } else {
556 index->b.low = hwif->index;
557 }
558 552
559 553
560 if (d->init_iops) 554 if (d->init_iops)
@@ -620,9 +614,8 @@ EXPORT_SYMBOL_GPL(ide_pci_setup_ports);
620 * for all other chipsets, we just assume both interfaces are enabled. 614 * for all other chipsets, we just assume both interfaces are enabled.
621 */ 615 */
622static int do_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d, 616static int do_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d,
623 ata_index_t *index, u8 noisy) 617 u8 *idx, u8 noisy)
624{ 618{
625 static ata_index_t ata_index = { .b = { .low = 0xff, .high = 0xff } };
626 int tried_config = 0; 619 int tried_config = 0;
627 int pciirq, ret; 620 int pciirq, ret;
628 621
@@ -672,37 +665,21 @@ static int do_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d,
672 665
673 /* FIXME: silent failure can happen */ 666 /* FIXME: silent failure can happen */
674 667
675 *index = ata_index; 668 ide_pci_setup_ports(dev, d, pciirq, idx);
676 ide_pci_setup_ports(dev, d, pciirq, index);
677out: 669out:
678 return ret; 670 return ret;
679} 671}
680 672
681int ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d) 673int ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d)
682{ 674{
683 ide_hwif_t *hwif = NULL, *mate = NULL; 675 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
684 ata_index_t index_list;
685 int ret; 676 int ret;
686 677
687 ret = do_ide_setup_pci_device(dev, d, &index_list, 1); 678 ret = do_ide_setup_pci_device(dev, d, &idx[0], 1);
688 if (ret < 0)
689 goto out;
690 679
691 if ((index_list.b.low & 0xf0) != 0xf0) 680 if (ret >= 0)
692 hwif = &ide_hwifs[index_list.b.low]; 681 ide_device_add(idx);
693 if ((index_list.b.high & 0xf0) != 0xf0)
694 mate = &ide_hwifs[index_list.b.high];
695 682
696 if (hwif)
697 probe_hwif_init(hwif);
698 if (mate)
699 probe_hwif_init(mate);
700
701 if (hwif)
702 ide_proc_register_port(hwif);
703 if (mate)
704 ide_proc_register_port(mate);
705out:
706 return ret; 683 return ret;
707} 684}
708 685
@@ -712,11 +689,11 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
712 ide_pci_device_t *d) 689 ide_pci_device_t *d)
713{ 690{
714 struct pci_dev *pdev[] = { dev1, dev2 }; 691 struct pci_dev *pdev[] = { dev1, dev2 };
715 ata_index_t index_list[2];
716 int ret, i; 692 int ret, i;
693 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
717 694
718 for (i = 0; i < 2; i++) { 695 for (i = 0; i < 2; i++) {
719 ret = do_ide_setup_pci_device(pdev[i], d, index_list + i, !i); 696 ret = do_ide_setup_pci_device(pdev[i], d, &idx[i*2], !i);
720 /* 697 /*
721 * FIXME: Mom, mom, they stole me the helper function to undo 698 * FIXME: Mom, mom, they stole me the helper function to undo
722 * do_ide_setup_pci_device() on the first device! 699 * do_ide_setup_pci_device() on the first device!
@@ -725,25 +702,7 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
725 goto out; 702 goto out;
726 } 703 }
727 704
728 for (i = 0; i < 2; i++) { 705 ide_device_add(idx);
729 u8 idx[2] = { index_list[i].b.low, index_list[i].b.high };
730 int j;
731
732 for (j = 0; j < 2; j++) {
733 if ((idx[j] & 0xf0) != 0xf0)
734 probe_hwif_init(ide_hwifs + idx[j]);
735 }
736 }
737
738 for (i = 0; i < 2; i++) {
739 u8 idx[2] = { index_list[i].b.low, index_list[i].b.high };
740 int j;
741
742 for (j = 0; j < 2; j++) {
743 if ((idx[j] & 0xf0) != 0xf0)
744 ide_proc_register_port(ide_hwifs + idx[j]);
745 }
746 }
747out: 706out:
748 return ret; 707 return ret;
749} 708}