aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:57 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:57 -0400
commit48c3c1072651922ed153bcf0a33ea82cf20df390 (patch)
tree92ad23e3869e70731eca99394c08a3bf06b8753e /drivers/ide/pci
parent374e042c3e767ac2e5a40b78529220e0b3de793c (diff)
ide: add struct ide_host (take 3)
* Add struct ide_host which keeps pointers to host's ports. * Add ide_host_alloc[_all]() and ide_host_remove() helpers. * Pass 'struct ide_host *host' instead of 'u8 *idx' to ide_device_add[_all]() and rename it to ide_host_register[_all](). * Convert host drivers and core code to use struct ide_host. * Remove no longer needed ide_find_port(). * Make ide_find_port_slot() static. * Unexport ide_unregister(). v2: * Add missing 'struct ide_host *host' to macide.c. v3: * Fix build problem in pmac.c (s/ide_alloc_host/ide_host_alloc/) (Noticed by Stephen Rothwell). Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/pci')
-rw-r--r--drivers/ide/pci/cmd640.c30
-rw-r--r--drivers/ide/pci/cs5520.c8
-rw-r--r--drivers/ide/pci/delkin_cb.c19
-rw-r--r--drivers/ide/pci/scc_pata.c24
-rw-r--r--drivers/ide/pci/sgiioc4.c13
5 files changed, 36 insertions, 58 deletions
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c
index ccde1e444e13..013697b8cef4 100644
--- a/drivers/ide/pci/cmd640.c
+++ b/drivers/ide/pci/cmd640.c
@@ -181,11 +181,6 @@ static u8 recovery_counts[4] = {16, 16, 16, 16}; /* Recovery count (encoded) */
181static DEFINE_SPINLOCK(cmd640_lock); 181static DEFINE_SPINLOCK(cmd640_lock);
182 182
183/* 183/*
184 * These are initialized to point at the devices we control
185 */
186static ide_hwif_t *cmd_hwif0, *cmd_hwif1;
187
188/*
189 * Interface to access cmd640x registers 184 * Interface to access cmd640x registers
190 */ 185 */
191static unsigned int cmd640_key; 186static unsigned int cmd640_key;
@@ -714,11 +709,11 @@ static int cmd640x_init_one(unsigned long base, unsigned long ctl)
714 */ 709 */
715static int __init cmd640x_init(void) 710static int __init cmd640x_init(void)
716{ 711{
712 struct ide_host *host;
717 int second_port_cmd640 = 0, rc; 713 int second_port_cmd640 = 0, rc;
718 const char *bus_type, *port2; 714 const char *bus_type, *port2;
719 u8 b, cfr; 715 u8 b, cfr;
720 hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL }; 716 hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL };
721 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
722 717
723 if (cmd640_vlb && probe_for_cmd640_vlb()) { 718 if (cmd640_vlb && probe_for_cmd640_vlb()) {
724 bus_type = "VLB"; 719 bus_type = "VLB";
@@ -781,17 +776,10 @@ static int __init cmd640x_init(void)
781 printk(KERN_INFO "cmd640: buggy cmd640%c interface on %s, config=0x%02x" 776 printk(KERN_INFO "cmd640: buggy cmd640%c interface on %s, config=0x%02x"
782 "\n", 'a' + cmd640_chip_version - 1, bus_type, cfr); 777 "\n", 'a' + cmd640_chip_version - 1, bus_type, cfr);
783 778
784 cmd_hwif0 = ide_find_port();
785
786 /* 779 /*
787 * Initialize data for primary port 780 * Initialize data for primary port
788 */ 781 */
789 if (cmd_hwif0) { 782 hws[0] = &hw[0];
790 cmd_hwif0->chipset = ide_cmd640;
791
792 hws[0] = &hw[0];
793 idx[0] = cmd_hwif0->index;
794 }
795 783
796 /* 784 /*
797 * Ensure compatibility by always using the slowest timings 785 * Ensure compatibility by always using the slowest timings
@@ -831,13 +819,9 @@ static int __init cmd640x_init(void)
831 /* 819 /*
832 * Initialize data for secondary cmd640 port, if enabled 820 * Initialize data for secondary cmd640 port, if enabled
833 */ 821 */
834 if (second_port_cmd640) { 822 if (second_port_cmd640)
835 cmd_hwif1 = ide_find_port(); 823 hws[1] = &hw[1];
836 if (cmd_hwif1) { 824
837 hws[1] = &hw[1];
838 idx[1] = cmd_hwif1->index;
839 }
840 }
841 printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n", 825 printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n",
842 second_port_cmd640 ? "" : "not ", port2); 826 second_port_cmd640 ? "" : "not ", port2);
843 827
@@ -845,7 +829,9 @@ static int __init cmd640x_init(void)
845 cmd640_dump_regs(); 829 cmd640_dump_regs();
846#endif 830#endif
847 831
848 ide_device_add(idx, &cmd640_port_info, hws); 832 host = ide_host_alloc(&cmd640_port_info, hws);
833 if (host)
834 ide_host_register(host, &cmd640_port_info, hws);
849 835
850 return 1; 836 return 1;
851} 837}
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
index e8e7df1915bf..b8ec06d22c61 100644
--- a/drivers/ide/pci/cs5520.c
+++ b/drivers/ide/pci/cs5520.c
@@ -114,9 +114,9 @@ static const struct ide_port_info cyrix_chipsets[] __devinitdata = {
114 114
115static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) 115static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id)
116{ 116{
117 struct ide_host *host;
117 const struct ide_port_info *d = &cyrix_chipsets[id->driver_data]; 118 const struct ide_port_info *d = &cyrix_chipsets[id->driver_data];
118 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; 119 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
119 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
120 120
121 ide_setup_pci_noise(dev, d); 121 ide_setup_pci_noise(dev, d);
122 122
@@ -138,9 +138,11 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
138 * do all the device setup for us 138 * do all the device setup for us
139 */ 139 */
140 140
141 ide_pci_setup_ports(dev, d, 14, &idx[0], &hw[0], &hws[0]); 141 ide_pci_setup_ports(dev, d, 14, &hw[0], &hws[0]);
142 142
143 ide_device_add(idx, d, hws); 143 host = ide_host_alloc(d, hws);
144 if (host)
145 ide_host_register(host, d, hws);
144 146
145 return 0; 147 return 0;
146} 148}
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c
index 33fe15db408a..5eb9d9325184 100644
--- a/drivers/ide/pci/delkin_cb.c
+++ b/drivers/ide/pci/delkin_cb.c
@@ -56,11 +56,10 @@ static const struct ide_port_info delkin_cb_port_info = {
56static int __devinit 56static int __devinit
57delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) 57delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
58{ 58{
59 struct ide_host *host;
59 unsigned long base; 60 unsigned long base;
60 ide_hwif_t *hwif = NULL;
61 int i, rc; 61 int i, rc;
62 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 62 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
63 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
64 63
65 rc = pci_enable_device(dev); 64 rc = pci_enable_device(dev);
66 if (rc) { 65 if (rc) {
@@ -87,17 +86,13 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
87 hw.dev = &dev->dev; 86 hw.dev = &dev->dev;
88 hw.chipset = ide_pci; /* this enables IRQ sharing */ 87 hw.chipset = ide_pci; /* this enables IRQ sharing */
89 88
90 hwif = ide_find_port(); 89 host = ide_host_alloc(&delkin_cb_port_info, hws);
91 if (hwif == NULL) 90 if (host == NULL)
92 goto out_disable; 91 goto out_disable;
93 92
94 i = hwif->index; 93 ide_host_register(host, &delkin_cb_port_info, hws);
95 94
96 idx[0] = i; 95 pci_set_drvdata(dev, host);
97
98 ide_device_add(idx, &delkin_cb_port_info, hws);
99
100 pci_set_drvdata(dev, hwif);
101 96
102 return 0; 97 return 0;
103 98
@@ -110,9 +105,9 @@ out_disable:
110static void 105static void
111delkin_cb_remove (struct pci_dev *dev) 106delkin_cb_remove (struct pci_dev *dev)
112{ 107{
113 ide_hwif_t *hwif = pci_get_drvdata(dev); 108 struct ide_host *host = pci_get_drvdata(dev);
114 109
115 ide_unregister(hwif); 110 ide_host_remove(host);
116 111
117 pci_release_regions(dev); 112 pci_release_regions(dev);
118 pci_disable_device(dev); 113 pci_disable_device(dev);
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index 5b1a0e950dfd..d5e2ba6bacd6 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -65,7 +65,7 @@
65 65
66static struct scc_ports { 66static struct scc_ports {
67 unsigned long ctl, dma; 67 unsigned long ctl, dma;
68 ide_hwif_t *hwif; /* for removing port from system */ 68 struct ide_host *host; /* for removing port from system */
69} scc_ports[MAX_HWIFS]; 69} scc_ports[MAX_HWIFS];
70 70
71/* PIO transfer mode table */ 71/* PIO transfer mode table */
@@ -586,15 +586,10 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev,
586 const struct ide_port_info *d) 586 const struct ide_port_info *d)
587{ 587{
588 struct scc_ports *ports = pci_get_drvdata(dev); 588 struct scc_ports *ports = pci_get_drvdata(dev);
589 ide_hwif_t *hwif = NULL; 589 struct ide_host *host;
590 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 590 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
591 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
592 int i; 591 int i;
593 592
594 hwif = ide_find_port_slot(d);
595 if (hwif == NULL)
596 return -ENOMEM;
597
598 memset(&hw, 0, sizeof(hw)); 593 memset(&hw, 0, sizeof(hw));
599 for (i = 0; i <= 8; i++) 594 for (i = 0; i <= 8; i++)
600 hw.io_ports_array[i] = ports->dma + 0x20 + i * 4; 595 hw.io_ports_array[i] = ports->dma + 0x20 + i * 4;
@@ -602,9 +597,13 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev,
602 hw.dev = &dev->dev; 597 hw.dev = &dev->dev;
603 hw.chipset = ide_pci; 598 hw.chipset = ide_pci;
604 599
605 idx[0] = hwif->index; 600 host = ide_host_alloc(d, hws);
601 if (host == NULL)
602 return -ENOMEM;
606 603
607 ide_device_add(idx, d, hws); 604 ide_host_register(host, d, hws);
605
606 ports->host = host;
608 607
609 return 0; 608 return 0;
610} 609}
@@ -848,8 +847,6 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif)
848{ 847{
849 struct scc_ports *ports = ide_get_hwifdata(hwif); 848 struct scc_ports *ports = ide_get_hwifdata(hwif);
850 849
851 ports->hwif = hwif;
852
853 /* PTERADD */ 850 /* PTERADD */
854 out_be32((void __iomem *)(hwif->dma_base + 0x018), hwif->dmatable_dma); 851 out_be32((void __iomem *)(hwif->dma_base + 0x018), hwif->dmatable_dma);
855 852
@@ -932,7 +929,8 @@ static int __devinit scc_init_one(struct pci_dev *dev, const struct pci_device_i
932static void __devexit scc_remove(struct pci_dev *dev) 929static void __devexit scc_remove(struct pci_dev *dev)
933{ 930{
934 struct scc_ports *ports = pci_get_drvdata(dev); 931 struct scc_ports *ports = pci_get_drvdata(dev);
935 ide_hwif_t *hwif = ports->hwif; 932 struct ide_host *host = ports->host;
933 ide_hwif_t *hwif = host->ports[0];
936 934
937 if (hwif->dmatable_cpu) { 935 if (hwif->dmatable_cpu) {
938 pci_free_consistent(dev, PRD_ENTRIES * PRD_BYTES, 936 pci_free_consistent(dev, PRD_ENTRIES * PRD_BYTES,
@@ -940,7 +938,7 @@ static void __devexit scc_remove(struct pci_dev *dev)
940 hwif->dmatable_cpu = NULL; 938 hwif->dmatable_cpu = NULL;
941 } 939 }
942 940
943 ide_unregister(hwif); 941 ide_host_remove(host);
944 942
945 iounmap((void*)ports->dma); 943 iounmap((void*)ports->dma);
946 iounmap((void*)ports->ctl); 944 iounmap((void*)ports->ctl);
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 5598bd5936d9..440f43a86ad3 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -600,9 +600,8 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
600 unsigned long cmd_base, irqport; 600 unsigned long cmd_base, irqport;
601 unsigned long bar0, cmd_phys_base, ctl; 601 unsigned long bar0, cmd_phys_base, ctl;
602 void __iomem *virt_base; 602 void __iomem *virt_base;
603 ide_hwif_t *hwif; 603 struct ide_host *host;
604 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 604 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
605 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
606 struct ide_port_info d = sgiioc4_port_info; 605 struct ide_port_info d = sgiioc4_port_info;
607 606
608 /* Get the CmdBlk and CtrlBlk Base Registers */ 607 /* Get the CmdBlk and CtrlBlk Base Registers */
@@ -635,16 +634,14 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
635 hw.chipset = ide_pci; 634 hw.chipset = ide_pci;
636 hw.dev = &dev->dev; 635 hw.dev = &dev->dev;
637 636
638 hwif = ide_find_port_slot(&d);
639 if (hwif == NULL)
640 goto err;
641
642 /* Initializing chipset IRQ Registers */ 637 /* Initializing chipset IRQ Registers */
643 writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); 638 writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4));
644 639
645 idx[0] = hwif->index; 640 host = ide_host_alloc(&d, hws);
641 if (host == NULL)
642 goto err;
646 643
647 if (ide_device_add(idx, &d, hws)) 644 if (ide_host_register(host, &d, hws))
648 return -EIO; 645 return -EIO;
649 646
650 return 0; 647 return 0;