aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:50 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:50 -0400
commitc97c6aca75fd5f718056fde7cff798b8cbdb07c0 (patch)
tree275635f3afb9d3a1f1f9ea5cebe08b5f327fc92c /drivers/ide
parent51d87ed0aab98999bebaf891b99730e15502a592 (diff)
ide: pass hw_regs_t-s to ide_device_add[_all]() (take 3)
* Add 'hw_regs_t **hws' argument to ide_device_add[_all]() and convert host drivers + ide_legacy_init_one() + ide_setup_pci_device[s]() to use it instead of calling ide_init_port_hw() directly. [ However if host has > 1 port we must still set hwif->chipset to hint consecutive ide_find_port() call that the previous slot is occupied. ] * Unexport ide_init_port_hw(). v2: * Use defines instead of hard-coded values in buddha.c, gayle.c and q40ide.c. (Suggested by Geert Uytterhoeven) * Better patch description. v3: * Fix build problem in ide-cs.c. (Noticed by Stephen Rothwell) There should be no functional changes caused by this patch. Cc: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/arm/icside.c13
-rw-r--r--drivers/ide/arm/ide_arm.c5
-rw-r--r--drivers/ide/arm/palm_bk3710.c6
-rw-r--r--drivers/ide/arm/rapide.c5
-rw-r--r--drivers/ide/h8300/ide-h8300.c5
-rw-r--r--drivers/ide/ide-generic.c23
-rw-r--r--drivers/ide/ide-pnp.c6
-rw-r--r--drivers/ide/ide-probe.c29
-rw-r--r--drivers/ide/ide.c1
-rw-r--r--drivers/ide/legacy/buddha.c16
-rw-r--r--drivers/ide/legacy/falconide.c6
-rw-r--r--drivers/ide/legacy/gayle.c13
-rw-r--r--drivers/ide/legacy/ide-4drives.c10
-rw-r--r--drivers/ide/legacy/ide-cs.c10
-rw-r--r--drivers/ide/legacy/ide_platform.c9
-rw-r--r--drivers/ide/legacy/macide.c6
-rw-r--r--drivers/ide/legacy/q40ide.c14
-rw-r--r--drivers/ide/mips/au1xxx-ide.c6
-rw-r--r--drivers/ide/mips/swarm.c6
-rw-r--r--drivers/ide/pci/cmd640.c10
-rw-r--r--drivers/ide/pci/cs5520.c5
-rw-r--r--drivers/ide/pci/delkin_cb.c6
-rw-r--r--drivers/ide/pci/scc_pata.c5
-rw-r--r--drivers/ide/pci/sgiioc4.c6
-rw-r--r--drivers/ide/ppc/pmac.c5
-rw-r--r--drivers/ide/setup-pci.c38
26 files changed, 127 insertions, 137 deletions
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c
index 52f58c885783..850fe9342a1f 100644
--- a/drivers/ide/arm/icside.c
+++ b/drivers/ide/arm/icside.c
@@ -442,8 +442,8 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
442{ 442{
443 ide_hwif_t *hwif; 443 ide_hwif_t *hwif;
444 void __iomem *base; 444 void __iomem *base;
445 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
445 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 446 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
446 hw_regs_t hw;
447 447
448 base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); 448 base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
449 if (!base) 449 if (!base)
@@ -467,7 +467,6 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
467 if (!hwif) 467 if (!hwif)
468 return -ENODEV; 468 return -ENODEV;
469 469
470 ide_init_port_hw(hwif, &hw);
471 default_hwif_mmiops(hwif); 470 default_hwif_mmiops(hwif);
472 471
473 state->hwif[0] = hwif; 472 state->hwif[0] = hwif;
@@ -476,7 +475,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
476 475
477 idx[0] = hwif->index; 476 idx[0] = hwif->index;
478 477
479 ide_device_add(idx, NULL); 478 ide_device_add(idx, NULL, hws);
480 479
481 return 0; 480 return 0;
482} 481}
@@ -497,9 +496,9 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
497 void __iomem *ioc_base, *easi_base; 496 void __iomem *ioc_base, *easi_base;
498 unsigned int sel = 0; 497 unsigned int sel = 0;
499 int ret; 498 int ret;
499 hw_regs_t hw[2], *hws[] = { &hw[0], NULL, NULL, NULL };
500 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 500 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
501 struct ide_port_info d = icside_v6_port_info; 501 struct ide_port_info d = icside_v6_port_info;
502 hw_regs_t hw[2];
503 502
504 ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); 503 ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
505 if (!ioc_base) { 504 if (!ioc_base) {
@@ -545,16 +544,16 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
545 if (hwif == NULL) 544 if (hwif == NULL)
546 return -ENODEV; 545 return -ENODEV;
547 546
548 ide_init_port_hw(hwif, &hw[0]); 547 hwif->chipset = ide_acorn;
549 default_hwif_mmiops(hwif); 548 default_hwif_mmiops(hwif);
550 549
551 idx[0] = hwif->index; 550 idx[0] = hwif->index;
552 551
553 mate = ide_find_port(); 552 mate = ide_find_port();
554 if (mate) { 553 if (mate) {
555 ide_init_port_hw(mate, &hw[1]);
556 default_hwif_mmiops(mate); 554 default_hwif_mmiops(mate);
557 555
556 hws[1] = &hw[1];
558 idx[1] = mate->index; 557 idx[1] = mate->index;
559 } 558 }
560 559
@@ -569,7 +568,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
569 d.dma_ops = NULL; 568 d.dma_ops = NULL;
570 } 569 }
571 570
572 ide_device_add(idx, &d); 571 ide_device_add(idx, &d, hws);
573 572
574 return 0; 573 return 0;
575 574
diff --git a/drivers/ide/arm/ide_arm.c b/drivers/ide/arm/ide_arm.c
index 2f311da4c963..e9831bbd988a 100644
--- a/drivers/ide/arm/ide_arm.c
+++ b/drivers/ide/arm/ide_arm.c
@@ -29,8 +29,8 @@
29static int __init ide_arm_init(void) 29static int __init ide_arm_init(void)
30{ 30{
31 ide_hwif_t *hwif; 31 ide_hwif_t *hwif;
32 hw_regs_t hw;
33 unsigned long base = IDE_ARM_IO, ctl = IDE_ARM_IO + 0x206; 32 unsigned long base = IDE_ARM_IO, ctl = IDE_ARM_IO + 0x206;
33 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
34 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 34 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
35 35
36 if (!request_region(base, 8, DRV_NAME)) { 36 if (!request_region(base, 8, DRV_NAME)) {
@@ -53,10 +53,9 @@ static int __init ide_arm_init(void)
53 53
54 hwif = ide_find_port(); 54 hwif = ide_find_port();
55 if (hwif) { 55 if (hwif) {
56 ide_init_port_hw(hwif, &hw);
57 idx[0] = hwif->index; 56 idx[0] = hwif->index;
58 57
59 ide_device_add(idx, NULL); 58 ide_device_add(idx, NULL, hws);
60 } 59 }
61 60
62 return 0; 61 return 0;
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c
index c79b85b6e4a3..023c10753f15 100644
--- a/drivers/ide/arm/palm_bk3710.c
+++ b/drivers/ide/arm/palm_bk3710.c
@@ -351,7 +351,7 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev)
351 ide_hwif_t *hwif; 351 ide_hwif_t *hwif;
352 unsigned long base, rate; 352 unsigned long base, rate;
353 int i; 353 int i;
354 hw_regs_t hw; 354 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
355 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 355 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
356 356
357 clk = clk_get(NULL, "IDECLK"); 357 clk = clk_get(NULL, "IDECLK");
@@ -400,13 +400,11 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev)
400 400
401 i = hwif->index; 401 i = hwif->index;
402 402
403 ide_init_port_hw(hwif, &hw);
404
405 default_hwif_mmiops(hwif); 403 default_hwif_mmiops(hwif);
406 404
407 idx[0] = i; 405 idx[0] = i;
408 406
409 ide_device_add(idx, &palm_bk3710_port_info); 407 ide_device_add(idx, &palm_bk3710_port_info, hws);
410 408
411 return 0; 409 return 0;
412out: 410out:
diff --git a/drivers/ide/arm/rapide.c b/drivers/ide/arm/rapide.c
index 43057e0303c8..01896f6e8acf 100644
--- a/drivers/ide/arm/rapide.c
+++ b/drivers/ide/arm/rapide.c
@@ -35,8 +35,8 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
35 ide_hwif_t *hwif; 35 ide_hwif_t *hwif;
36 void __iomem *base; 36 void __iomem *base;
37 int ret; 37 int ret;
38 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
38 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 39 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
39 hw_regs_t hw;
40 40
41 ret = ecard_request_resources(ec); 41 ret = ecard_request_resources(ec);
42 if (ret) 42 if (ret)
@@ -59,12 +59,11 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
59 goto release; 59 goto release;
60 } 60 }
61 61
62 ide_init_port_hw(hwif, &hw);
63 default_hwif_mmiops(hwif); 62 default_hwif_mmiops(hwif);
64 63
65 idx[0] = hwif->index; 64 idx[0] = hwif->index;
66 65
67 ide_device_add(idx, &rapide_port_info); 66 ide_device_add(idx, &rapide_port_info, hws);
68 67
69 ecard_set_drvdata(ec, hwif); 68 ecard_set_drvdata(ec, hwif);
70 goto out; 69 goto out;
diff --git a/drivers/ide/h8300/ide-h8300.c b/drivers/ide/h8300/ide-h8300.c
index 20fad6d542cc..a71433b3d0f3 100644
--- a/drivers/ide/h8300/ide-h8300.c
+++ b/drivers/ide/h8300/ide-h8300.c
@@ -184,9 +184,9 @@ static const struct ide_port_info h8300_port_info = {
184 184
185static int __init h8300_ide_init(void) 185static int __init h8300_ide_init(void)
186{ 186{
187 hw_regs_t hw;
188 ide_hwif_t *hwif; 187 ide_hwif_t *hwif;
189 int index; 188 int index;
189 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
190 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 190 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
191 191
192 printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface\n"); 192 printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface\n");
@@ -205,12 +205,11 @@ static int __init h8300_ide_init(void)
205 return -ENOENT; 205 return -ENOENT;
206 206
207 index = hwif->index; 207 index = hwif->index;
208 ide_init_port_hw(hwif, &hw);
209 hwif_setup(hwif); 208 hwif_setup(hwif);
210 209
211 idx[0] = index; 210 idx[0] = index;
212 211
213 ide_device_add(idx, &h8300_port_info); 212 ide_device_add(idx, &h8300_port_info, hws);
214 213
215 return 0; 214 return 0;
216 215
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c
index 2d92214096ab..bb9fc905d60c 100644
--- a/drivers/ide/ide-generic.c
+++ b/drivers/ide/ide-generic.c
@@ -31,7 +31,7 @@ static ssize_t store_add(struct class *cls, const char *buf, size_t n)
31 ide_hwif_t *hwif; 31 ide_hwif_t *hwif;
32 unsigned int base, ctl; 32 unsigned int base, ctl;
33 int irq; 33 int irq;
34 hw_regs_t hw; 34 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
35 u8 idx[] = { 0xff, 0xff, 0xff, 0xff }; 35 u8 idx[] = { 0xff, 0xff, 0xff, 0xff };
36 36
37 if (sscanf(buf, "%x:%x:%d", &base, &ctl, &irq) != 3) 37 if (sscanf(buf, "%x:%x:%d", &base, &ctl, &irq) != 3)
@@ -46,11 +46,9 @@ static ssize_t store_add(struct class *cls, const char *buf, size_t n)
46 hw.irq = irq; 46 hw.irq = irq;
47 hw.chipset = ide_generic; 47 hw.chipset = ide_generic;
48 48
49 ide_init_port_hw(hwif, &hw);
50
51 idx[0] = hwif->index; 49 idx[0] = hwif->index;
52 50
53 ide_device_add(idx, NULL); 51 ide_device_add(idx, NULL, hws);
54 52
55 return n; 53 return n;
56}; 54};
@@ -90,6 +88,7 @@ static int __init ide_generic_sysfs_init(void)
90 88
91static int __init ide_generic_init(void) 89static int __init ide_generic_init(void)
92{ 90{
91 hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS];
93 u8 idx[MAX_HWIFS]; 92 u8 idx[MAX_HWIFS];
94 int i; 93 int i;
95 94
@@ -99,8 +98,8 @@ static int __init ide_generic_init(void)
99 for (i = 0; i < MAX_HWIFS; i++) { 98 for (i = 0; i < MAX_HWIFS; i++) {
100 ide_hwif_t *hwif; 99 ide_hwif_t *hwif;
101 unsigned long io_addr = ide_default_io_base(i); 100 unsigned long io_addr = ide_default_io_base(i);
102 hw_regs_t hw;
103 101
102 hws[i] = NULL;
104 idx[i] = 0xff; 103 idx[i] = 0xff;
105 104
106 if ((probe_mask & (1 << i)) && io_addr) { 105 if ((probe_mask & (1 << i)) && io_addr) {
@@ -129,17 +128,19 @@ static int __init ide_generic_init(void)
129 continue; 128 continue;
130 } 129 }
131 130
132 memset(&hw, 0, sizeof(hw)); 131 hwif->chipset = ide_generic;
133 ide_std_init_ports(&hw, io_addr, io_addr + 0x206); 132
134 hw.irq = ide_default_irq(io_addr); 133 memset(&hw[i], 0, sizeof(hw[i]));
135 hw.chipset = ide_generic; 134 ide_std_init_ports(&hw[i], io_addr, io_addr + 0x206);
136 ide_init_port_hw(hwif, &hw); 135 hw[i].irq = ide_default_irq(io_addr);
136 hw[i].chipset = ide_generic;
137 137
138 hws[i] = &hw[i];
138 idx[i] = i; 139 idx[i] = i;
139 } 140 }
140 } 141 }
141 142
142 ide_device_add_all(idx, NULL); 143 ide_device_add_all(idx, NULL, hws);
143 144
144 if (ide_generic_sysfs_init()) 145 if (ide_generic_sysfs_init())
145 printk(KERN_ERR DRV_NAME ": failed to create ide_generic " 146 printk(KERN_ERR DRV_NAME ": failed to create ide_generic "
diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c
index 03f2ef5470a3..89cd5cbe8573 100644
--- a/drivers/ide/ide-pnp.c
+++ b/drivers/ide/ide-pnp.c
@@ -29,9 +29,9 @@ static struct pnp_device_id idepnp_devices[] = {
29 29
30static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) 30static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
31{ 31{
32 hw_regs_t hw;
33 ide_hwif_t *hwif; 32 ide_hwif_t *hwif;
34 unsigned long base, ctl; 33 unsigned long base, ctl;
34 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
35 35
36 printk(KERN_INFO DRV_NAME ": generic PnP IDE interface\n"); 36 printk(KERN_INFO DRV_NAME ": generic PnP IDE interface\n");
37 37
@@ -64,11 +64,9 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
64 u8 index = hwif->index; 64 u8 index = hwif->index;
65 u8 idx[4] = { index, 0xff, 0xff, 0xff }; 65 u8 idx[4] = { index, 0xff, 0xff, 0xff };
66 66
67 ide_init_port_hw(hwif, &hw);
68
69 pnp_set_drvdata(dev, hwif); 67 pnp_set_drvdata(dev, hwif);
70 68
71 ide_device_add(idx, NULL); 69 ide_device_add(idx, NULL, hws);
72 70
73 return 0; 71 return 0;
74 } 72 }
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 235ebdb29b28..9d8686a49fcf 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1501,7 +1501,7 @@ out_found:
1501} 1501}
1502EXPORT_SYMBOL_GPL(ide_find_port_slot); 1502EXPORT_SYMBOL_GPL(ide_find_port_slot);
1503 1503
1504int ide_device_add_all(u8 *idx, const struct ide_port_info *d) 1504int ide_device_add_all(u8 *idx, const struct ide_port_info *d, hw_regs_t **hws)
1505{ 1505{
1506 ide_hwif_t *hwif, *mate = NULL; 1506 ide_hwif_t *hwif, *mate = NULL;
1507 int i, rc = 0; 1507 int i, rc = 0;
@@ -1514,6 +1514,7 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
1514 1514
1515 hwif = &ide_hwifs[idx[i]]; 1515 hwif = &ide_hwifs[idx[i]];
1516 1516
1517 ide_init_port_hw(hwif, hws[i]);
1517 ide_port_apply_params(hwif); 1518 ide_port_apply_params(hwif);
1518 1519
1519 if (d == NULL) { 1520 if (d == NULL) {
@@ -1603,15 +1604,18 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
1603} 1604}
1604EXPORT_SYMBOL_GPL(ide_device_add_all); 1605EXPORT_SYMBOL_GPL(ide_device_add_all);
1605 1606
1606int ide_device_add(u8 idx[4], const struct ide_port_info *d) 1607int ide_device_add(u8 *idx, const struct ide_port_info *d, hw_regs_t **hws)
1607{ 1608{
1609 hw_regs_t *hws_all[MAX_HWIFS];
1608 u8 idx_all[MAX_HWIFS]; 1610 u8 idx_all[MAX_HWIFS];
1609 int i; 1611 int i;
1610 1612
1611 for (i = 0; i < MAX_HWIFS; i++) 1613 for (i = 0; i < MAX_HWIFS; i++) {
1614 hws_all[i] = (i < 4) ? hws[i] : NULL;
1612 idx_all[i] = (i < 4) ? idx[i] : 0xff; 1615 idx_all[i] = (i < 4) ? idx[i] : 0xff;
1616 }
1613 1617
1614 return ide_device_add_all(idx_all, d); 1618 return ide_device_add_all(idx_all, d, hws_all);
1615} 1619}
1616EXPORT_SYMBOL_GPL(ide_device_add); 1620EXPORT_SYMBOL_GPL(ide_device_add);
1617 1621
@@ -1634,8 +1638,8 @@ void ide_port_scan(ide_hwif_t *hwif)
1634} 1638}
1635EXPORT_SYMBOL_GPL(ide_port_scan); 1639EXPORT_SYMBOL_GPL(ide_port_scan);
1636 1640
1637static void ide_legacy_init_one(u8 *idx, hw_regs_t *hw, u8 port_no, 1641static void ide_legacy_init_one(u8 *idx, hw_regs_t **hws, hw_regs_t *hw,
1638 const struct ide_port_info *d, 1642 u8 port_no, const struct ide_port_info *d,
1639 unsigned long config) 1643 unsigned long config)
1640{ 1644{
1641 ide_hwif_t *hwif; 1645 ide_hwif_t *hwif;
@@ -1671,9 +1675,12 @@ static void ide_legacy_init_one(u8 *idx, hw_regs_t *hw, u8 port_no,
1671 1675
1672 hwif = ide_find_port_slot(d); 1676 hwif = ide_find_port_slot(d);
1673 if (hwif) { 1677 if (hwif) {
1674 ide_init_port_hw(hwif, hw); 1678 hwif->chipset = hw->chipset;
1679
1675 if (config) 1680 if (config)
1676 hwif->config_data = config; 1681 hwif->config_data = config;
1682
1683 hws[port_no] = hw;
1677 idx[port_no] = hwif->index; 1684 idx[port_no] = hwif->index;
1678 } 1685 }
1679} 1686}
@@ -1681,19 +1688,19 @@ static void ide_legacy_init_one(u8 *idx, hw_regs_t *hw, u8 port_no,
1681int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config) 1688int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config)
1682{ 1689{
1683 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 1690 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
1684 hw_regs_t hw[2]; 1691 hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL };
1685 1692
1686 memset(&hw, 0, sizeof(hw)); 1693 memset(&hw, 0, sizeof(hw));
1687 1694
1688 if ((d->host_flags & IDE_HFLAG_QD_2ND_PORT) == 0) 1695 if ((d->host_flags & IDE_HFLAG_QD_2ND_PORT) == 0)
1689 ide_legacy_init_one(idx, &hw[0], 0, d, config); 1696 ide_legacy_init_one(idx, hws, &hw[0], 0, d, config);
1690 ide_legacy_init_one(idx, &hw[1], 1, d, config); 1697 ide_legacy_init_one(idx, hws, &hw[1], 1, d, config);
1691 1698
1692 if (idx[0] == 0xff && idx[1] == 0xff && 1699 if (idx[0] == 0xff && idx[1] == 0xff &&
1693 (d->host_flags & IDE_HFLAG_SINGLE)) 1700 (d->host_flags & IDE_HFLAG_SINGLE))
1694 return -ENOENT; 1701 return -ENOENT;
1695 1702
1696 ide_device_add(idx, d); 1703 ide_device_add(idx, d, hws);
1697 1704
1698 return 0; 1705 return 0;
1699} 1706}
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index d4a6b102a772..b6018f7b0907 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -288,7 +288,6 @@ void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw)
288 hwif->gendev.parent = hw->parent ? hw->parent : hw->dev; 288 hwif->gendev.parent = hw->parent ? hw->parent : hw->dev;
289 hwif->ack_intr = hw->ack_intr; 289 hwif->ack_intr = hw->ack_intr;
290} 290}
291EXPORT_SYMBOL_GPL(ide_init_port_hw);
292 291
293/* 292/*
294 * Locks for IDE setting functionality 293 * Locks for IDE setting functionality
diff --git a/drivers/ide/legacy/buddha.c b/drivers/ide/legacy/buddha.c
index 0497e7f85b09..c61bc6a1db36 100644
--- a/drivers/ide/legacy/buddha.c
+++ b/drivers/ide/legacy/buddha.c
@@ -37,6 +37,8 @@
37#define CATWEASEL_NUM_HWIFS 3 37#define CATWEASEL_NUM_HWIFS 3
38#define XSURF_NUM_HWIFS 2 38#define XSURF_NUM_HWIFS 2
39 39
40#define MAX_NUM_HWIFS 3
41
40 /* 42 /*
41 * Bases of the IDE interfaces (relative to the board address) 43 * Bases of the IDE interfaces (relative to the board address)
42 */ 44 */
@@ -148,7 +150,6 @@ static void __init buddha_setup_ports(hw_regs_t *hw, unsigned long base,
148 150
149static int __init buddha_init(void) 151static int __init buddha_init(void)
150{ 152{
151 hw_regs_t hw;
152 ide_hwif_t *hwif; 153 ide_hwif_t *hwif;
153 int i; 154 int i;
154 155
@@ -159,6 +160,7 @@ static int __init buddha_init(void)
159 160
160 while ((z = zorro_find_device(ZORRO_WILDCARD, z))) { 161 while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
161 unsigned long board; 162 unsigned long board;
163 hw_regs_t hw[MAX_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL };
162 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 164 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
163 165
164 if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA) { 166 if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA) {
@@ -221,19 +223,19 @@ fail_base2:
221 ack_intr = xsurf_ack_intr; 223 ack_intr = xsurf_ack_intr;
222 } 224 }
223 225
224 buddha_setup_ports(&hw, base, ctl, irq_port, ack_intr); 226 buddha_setup_ports(&hw[i], base, ctl, irq_port,
227 ack_intr);
225 228
226 hwif = ide_find_port(); 229 hwif = ide_find_port();
227 if (hwif) { 230 if (hwif) {
228 u8 index = hwif->index; 231 hwif->chipset = ide_generic;
229
230 ide_init_port_hw(hwif, &hw);
231 232
232 idx[i] = index; 233 hws[i] = &hw[i];
234 idx[i] = hwif->index;
233 } 235 }
234 } 236 }
235 237
236 ide_device_add(idx, NULL); 238 ide_device_add(idx, NULL, hws);
237 } 239 }
238 240
239 return 0; 241 return 0;
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c
index 129a812bb57f..1bb2aa72cc7f 100644
--- a/drivers/ide/legacy/falconide.c
+++ b/drivers/ide/legacy/falconide.c
@@ -91,8 +91,8 @@ static void __init falconide_setup_ports(hw_regs_t *hw)
91 91
92static int __init falconide_init(void) 92static int __init falconide_init(void)
93{ 93{
94 hw_regs_t hw;
95 ide_hwif_t *hwif; 94 ide_hwif_t *hwif;
95 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
96 96
97 if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE)) 97 if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE))
98 return 0; 98 return 0;
@@ -111,14 +111,12 @@ static int __init falconide_init(void)
111 u8 index = hwif->index; 111 u8 index = hwif->index;
112 u8 idx[4] = { index, 0xff, 0xff, 0xff }; 112 u8 idx[4] = { index, 0xff, 0xff, 0xff };
113 113
114 ide_init_port_hw(hwif, &hw);
115
116 /* Atari has a byte-swapped IDE interface */ 114 /* Atari has a byte-swapped IDE interface */
117 hwif->input_data = falconide_input_data; 115 hwif->input_data = falconide_input_data;
118 hwif->output_data = falconide_output_data; 116 hwif->output_data = falconide_output_data;
119 117
120 ide_get_lock(NULL, NULL); 118 ide_get_lock(NULL, NULL);
121 ide_device_add(idx, NULL); 119 ide_device_add(idx, NULL, hws);
122 ide_release_lock(); 120 ide_release_lock();
123 } 121 }
124 122
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c
index 7e74b20202df..e45c7341186c 100644
--- a/drivers/ide/legacy/gayle.c
+++ b/drivers/ide/legacy/gayle.c
@@ -125,6 +125,7 @@ static void __init gayle_setup_ports(hw_regs_t *hw, unsigned long base,
125static int __init gayle_init(void) 125static int __init gayle_init(void)
126{ 126{
127 int a4000, i; 127 int a4000, i;
128 hw_regs_t hw[GAYLE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL };
128 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 129 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
129 130
130 if (!MACH_IS_AMIGA) 131 if (!MACH_IS_AMIGA)
@@ -151,7 +152,6 @@ found:
151 for (i = 0; i < GAYLE_NUM_PROBE_HWIFS; i++) { 152 for (i = 0; i < GAYLE_NUM_PROBE_HWIFS; i++) {
152 unsigned long base, ctrlport, irqport; 153 unsigned long base, ctrlport, irqport;
153 ide_ack_intr_t *ack_intr; 154 ide_ack_intr_t *ack_intr;
154 hw_regs_t hw;
155 ide_hwif_t *hwif; 155 ide_hwif_t *hwif;
156 unsigned long phys_base, res_start, res_n; 156 unsigned long phys_base, res_start, res_n;
157 157
@@ -179,20 +179,19 @@ found:
179 base = (unsigned long)ZTWO_VADDR(phys_base); 179 base = (unsigned long)ZTWO_VADDR(phys_base);
180 ctrlport = GAYLE_HAS_CONTROL_REG ? (base + GAYLE_CONTROL) : 0; 180 ctrlport = GAYLE_HAS_CONTROL_REG ? (base + GAYLE_CONTROL) : 0;
181 181
182 gayle_setup_ports(&hw, base, ctrlport, irqport, ack_intr); 182 gayle_setup_ports(&hw[i], base, ctrlport, irqport, ack_intr);
183 183
184 hwif = ide_find_port(); 184 hwif = ide_find_port();
185 if (hwif) { 185 if (hwif) {
186 u8 index = hwif->index; 186 hwif->chipset = ide_generic;
187 187
188 ide_init_port_hw(hwif, &hw); 188 hws[i] = &hw[i];
189 189 idx[i] = hwif->index;
190 idx[i] = index;
191 } else 190 } else
192 release_mem_region(res_start, res_n); 191 release_mem_region(res_start, res_n);
193 } 192 }
194 193
195 ide_device_add(idx, NULL); 194 ide_device_add(idx, NULL, hws);
196 195
197 return 0; 196 return 0;
198} 197}
diff --git a/drivers/ide/legacy/ide-4drives.c b/drivers/ide/legacy/ide-4drives.c
index 89c8ff0a4d08..6310dc50e3c5 100644
--- a/drivers/ide/legacy/ide-4drives.c
+++ b/drivers/ide/legacy/ide-4drives.c
@@ -30,8 +30,8 @@ static int __init ide_4drives_init(void)
30{ 30{
31 ide_hwif_t *hwif, *mate; 31 ide_hwif_t *hwif, *mate;
32 unsigned long base = 0x1f0, ctl = 0x3f6; 32 unsigned long base = 0x1f0, ctl = 0x3f6;
33 hw_regs_t hw, *hws[] = { NULL, NULL, NULL, NULL };
33 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 34 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
34 hw_regs_t hw;
35 35
36 if (probe_4drives == 0) 36 if (probe_4drives == 0)
37 return -ENODEV; 37 return -ENODEV;
@@ -57,17 +57,19 @@ static int __init ide_4drives_init(void)
57 57
58 hwif = ide_find_port(); 58 hwif = ide_find_port();
59 if (hwif) { 59 if (hwif) {
60 ide_init_port_hw(hwif, &hw); 60 hwif->chipset = ide_4drives;
61
62 hws[0] = &hw;
61 idx[0] = hwif->index; 63 idx[0] = hwif->index;
62 } 64 }
63 65
64 mate = ide_find_port(); 66 mate = ide_find_port();
65 if (mate) { 67 if (mate) {
66 ide_init_port_hw(mate, &hw); 68 hws[1] = &hw;
67 idx[1] = mate->index; 69 idx[1] = mate->index;
68 } 70 }
69 71
70 ide_device_add(idx, &ide_4drives_port_info); 72 ide_device_add(idx, &ide_4drives_port_info, hws);
71 73
72 return 0; 74 return 0;
73} 75}
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index 27b1e0b7ecb4..f93d5454ebf8 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -161,8 +161,8 @@ static ide_hwif_t *idecs_register(unsigned long io, unsigned long ctl,
161 unsigned long irq, struct pcmcia_device *handle) 161 unsigned long irq, struct pcmcia_device *handle)
162{ 162{
163 ide_hwif_t *hwif; 163 ide_hwif_t *hwif;
164 hw_regs_t hw;
165 int i; 164 int i;
165 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
166 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 166 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
167 167
168 if (!request_region(io, 8, DRV_NAME)) { 168 if (!request_region(io, 8, DRV_NAME)) {
@@ -188,13 +188,9 @@ static ide_hwif_t *idecs_register(unsigned long io, unsigned long ctl,
188 if (hwif == NULL) 188 if (hwif == NULL)
189 goto out_release; 189 goto out_release;
190 190
191 i = hwif->index; 191 idx[0] = hwif->index;
192 192
193 ide_init_port_hw(hwif, &hw); 193 ide_device_add(idx, &idecs_port_info, hws);
194
195 idx[0] = i;
196
197 ide_device_add(idx, &idecs_port_info);
198 194
199 if (hwif->present) 195 if (hwif->present)
200 return hwif; 196 return hwif;
diff --git a/drivers/ide/legacy/ide_platform.c b/drivers/ide/legacy/ide_platform.c
index a249562b34b5..609da0d43196 100644
--- a/drivers/ide/legacy/ide_platform.c
+++ b/drivers/ide/legacy/ide_platform.c
@@ -54,10 +54,9 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
54 void __iomem *base, *alt_base; 54 void __iomem *base, *alt_base;
55 ide_hwif_t *hwif; 55 ide_hwif_t *hwif;
56 struct pata_platform_info *pdata; 56 struct pata_platform_info *pdata;
57 int ret = 0, mmio = 0;
58 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
57 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 59 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
58 int ret = 0;
59 int mmio = 0;
60 hw_regs_t hw;
61 struct ide_port_info d = platform_ide_port_info; 60 struct ide_port_info d = platform_ide_port_info;
62 61
63 pdata = pdev->dev.platform_data; 62 pdata = pdev->dev.platform_data;
@@ -104,8 +103,6 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
104 plat_ide_setup_ports(&hw, base, alt_base, pdata, res_irq->start); 103 plat_ide_setup_ports(&hw, base, alt_base, pdata, res_irq->start);
105 hw.dev = &pdev->dev; 104 hw.dev = &pdev->dev;
106 105
107 ide_init_port_hw(hwif, &hw);
108
109 if (mmio) { 106 if (mmio) {
110 d.host_flags |= IDE_HFLAG_MMIO; 107 d.host_flags |= IDE_HFLAG_MMIO;
111 default_hwif_mmiops(hwif); 108 default_hwif_mmiops(hwif);
@@ -113,7 +110,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
113 110
114 idx[0] = hwif->index; 111 idx[0] = hwif->index;
115 112
116 ide_device_add(idx, &d); 113 ide_device_add(idx, &d, hws);
117 114
118 platform_set_drvdata(pdev, hwif); 115 platform_set_drvdata(pdev, hwif);
119 116
diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c
index 0a6195bcfeda..d839df2239fc 100644
--- a/drivers/ide/legacy/macide.c
+++ b/drivers/ide/legacy/macide.c
@@ -95,7 +95,7 @@ static int __init macide_init(void)
95 ide_ack_intr_t *ack_intr; 95 ide_ack_intr_t *ack_intr;
96 unsigned long base; 96 unsigned long base;
97 int irq; 97 int irq;
98 hw_regs_t hw; 98 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
99 99
100 if (!MACH_IS_MAC) 100 if (!MACH_IS_MAC)
101 return -ENODEV; 101 return -ENODEV;
@@ -130,9 +130,7 @@ static int __init macide_init(void)
130 u8 index = hwif->index; 130 u8 index = hwif->index;
131 u8 idx[4] = { index, 0xff, 0xff, 0xff }; 131 u8 idx[4] = { index, 0xff, 0xff, 0xff };
132 132
133 ide_init_port_hw(hwif, &hw); 133 ide_device_add(idx, NULL, hws);
134
135 ide_device_add(idx, NULL);
136 } 134 }
137 135
138 return 0; 136 return 0;
diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c
index 9c2b9d078f69..fcb04b8b0238 100644
--- a/drivers/ide/legacy/q40ide.c
+++ b/drivers/ide/legacy/q40ide.c
@@ -112,7 +112,7 @@ static int __init q40ide_init(void)
112{ 112{
113 int i; 113 int i;
114 ide_hwif_t *hwif; 114 ide_hwif_t *hwif;
115 const char *name; 115 hw_regs_t hw[Q40IDE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL };
116 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 116 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
117 117
118 if (!MACH_IS_Q40) 118 if (!MACH_IS_Q40)
@@ -121,9 +121,8 @@ static int __init q40ide_init(void)
121 printk(KERN_INFO "ide: Q40 IDE controller\n"); 121 printk(KERN_INFO "ide: Q40 IDE controller\n");
122 122
123 for (i = 0; i < Q40IDE_NUM_HWIFS; i++) { 123 for (i = 0; i < Q40IDE_NUM_HWIFS; i++) {
124 hw_regs_t hw; 124 const char *name = q40_ide_names[i];
125 125
126 name = q40_ide_names[i];
127 if (!request_region(pcide_bases[i], 8, name)) { 126 if (!request_region(pcide_bases[i], 8, name)) {
128 printk("could not reserve ports %lx-%lx for %s\n", 127 printk("could not reserve ports %lx-%lx for %s\n",
129 pcide_bases[i],pcide_bases[i]+8,name); 128 pcide_bases[i],pcide_bases[i]+8,name);
@@ -135,24 +134,23 @@ static int __init q40ide_init(void)
135 release_region(pcide_bases[i], 8); 134 release_region(pcide_bases[i], 8);
136 continue; 135 continue;
137 } 136 }
138 q40_ide_setup_ports(&hw, pcide_bases[i], 137 q40_ide_setup_ports(&hw[i], pcide_bases[i], NULL,
139 NULL,
140// m68kide_iops,
141 q40ide_default_irq(pcide_bases[i])); 138 q40ide_default_irq(pcide_bases[i]));
142 139
143 hwif = ide_find_port(); 140 hwif = ide_find_port();
144 if (hwif) { 141 if (hwif) {
145 ide_init_port_hw(hwif, &hw); 142 hwif->chipset = ide_generic;
146 143
147 /* Q40 has a byte-swapped IDE interface */ 144 /* Q40 has a byte-swapped IDE interface */
148 hwif->input_data = q40ide_input_data; 145 hwif->input_data = q40ide_input_data;
149 hwif->output_data = q40ide_output_data; 146 hwif->output_data = q40ide_output_data;
150 147
148 hws[i] = &hw[i];
151 idx[i] = hwif->index; 149 idx[i] = hwif->index;
152 } 150 }
153 } 151 }
154 152
155 ide_device_add(idx, NULL); 153 ide_device_add(idx, NULL, hws);
156 154
157 return 0; 155 return 0;
158} 156}
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c
index 48d57cae63c6..475da582fd89 100644
--- a/drivers/ide/mips/au1xxx-ide.c
+++ b/drivers/ide/mips/au1xxx-ide.c
@@ -546,8 +546,8 @@ static int au_ide_probe(struct device *dev)
546 ide_hwif_t *hwif; 546 ide_hwif_t *hwif;
547 struct resource *res; 547 struct resource *res;
548 int ret = 0; 548 int ret = 0;
549 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
549 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 550 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
550 hw_regs_t hw;
551 551
552#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) 552#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA)
553 char *mode = "MWDMA2"; 553 char *mode = "MWDMA2";
@@ -596,8 +596,6 @@ static int au_ide_probe(struct device *dev)
596 hw.dev = dev; 596 hw.dev = dev;
597 hw.chipset = ide_au1xxx; 597 hw.chipset = ide_au1xxx;
598 598
599 ide_init_port_hw(hwif, &hw);
600
601 /* If the user has selected DDMA assisted copies, 599 /* If the user has selected DDMA assisted copies,
602 then set up a few local I/O function entry points 600 then set up a few local I/O function entry points
603 */ 601 */
@@ -611,7 +609,7 @@ static int au_ide_probe(struct device *dev)
611 609
612 idx[0] = hwif->index; 610 idx[0] = hwif->index;
613 611
614 ide_device_add(idx, &au1xxx_port_info); 612 ide_device_add(idx, &au1xxx_port_info, hws);
615 613
616 dev_set_drvdata(dev, hwif); 614 dev_set_drvdata(dev, hwif);
617 615
diff --git a/drivers/ide/mips/swarm.c b/drivers/ide/mips/swarm.c
index 9f1212cc4aed..6da6844d2d8c 100644
--- a/drivers/ide/mips/swarm.c
+++ b/drivers/ide/mips/swarm.c
@@ -75,8 +75,8 @@ static int __devinit swarm_ide_probe(struct device *dev)
75 ide_hwif_t *hwif; 75 ide_hwif_t *hwif;
76 u8 __iomem *base; 76 u8 __iomem *base;
77 phys_t offset, size; 77 phys_t offset, size;
78 hw_regs_t hw;
79 int i; 78 int i;
79 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
80 u8 idx[] = { 0xff, 0xff, 0xff, 0xff }; 80 u8 idx[] = { 0xff, 0xff, 0xff, 0xff };
81 81
82 if (!SIBYTE_HAVE_IDE) 82 if (!SIBYTE_HAVE_IDE)
@@ -120,14 +120,12 @@ static int __devinit swarm_ide_probe(struct device *dev)
120 if (hwif == NULL) 120 if (hwif == NULL)
121 goto err; 121 goto err;
122 122
123 ide_init_port_hw(hwif, &hw);
124
125 /* Setup MMIO ops. */ 123 /* Setup MMIO ops. */
126 default_hwif_mmiops(hwif); 124 default_hwif_mmiops(hwif);
127 125
128 idx[0] = hwif->index; 126 idx[0] = hwif->index;
129 127
130 ide_device_add(idx, &swarm_port_info); 128 ide_device_add(idx, &swarm_port_info, hws);
131 129
132 dev_set_drvdata(dev, hwif); 130 dev_set_drvdata(dev, hwif);
133 131
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c
index 1ad1e23e3105..ccde1e444e13 100644
--- a/drivers/ide/pci/cmd640.c
+++ b/drivers/ide/pci/cmd640.c
@@ -717,8 +717,8 @@ static int __init cmd640x_init(void)
717 int second_port_cmd640 = 0, rc; 717 int second_port_cmd640 = 0, rc;
718 const char *bus_type, *port2; 718 const char *bus_type, *port2;
719 u8 b, cfr; 719 u8 b, cfr;
720 hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL };
720 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 721 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
721 hw_regs_t hw[2];
722 722
723 if (cmd640_vlb && probe_for_cmd640_vlb()) { 723 if (cmd640_vlb && probe_for_cmd640_vlb()) {
724 bus_type = "VLB"; 724 bus_type = "VLB";
@@ -787,7 +787,9 @@ static int __init cmd640x_init(void)
787 * Initialize data for primary port 787 * Initialize data for primary port
788 */ 788 */
789 if (cmd_hwif0) { 789 if (cmd_hwif0) {
790 ide_init_port_hw(cmd_hwif0, &hw[0]); 790 cmd_hwif0->chipset = ide_cmd640;
791
792 hws[0] = &hw[0];
791 idx[0] = cmd_hwif0->index; 793 idx[0] = cmd_hwif0->index;
792 } 794 }
793 795
@@ -832,7 +834,7 @@ static int __init cmd640x_init(void)
832 if (second_port_cmd640) { 834 if (second_port_cmd640) {
833 cmd_hwif1 = ide_find_port(); 835 cmd_hwif1 = ide_find_port();
834 if (cmd_hwif1) { 836 if (cmd_hwif1) {
835 ide_init_port_hw(cmd_hwif1, &hw[1]); 837 hws[1] = &hw[1];
836 idx[1] = cmd_hwif1->index; 838 idx[1] = cmd_hwif1->index;
837 } 839 }
838 } 840 }
@@ -843,7 +845,7 @@ static int __init cmd640x_init(void)
843 cmd640_dump_regs(); 845 cmd640_dump_regs();
844#endif 846#endif
845 847
846 ide_device_add(idx, &cmd640_port_info); 848 ide_device_add(idx, &cmd640_port_info, hws);
847 849
848 return 1; 850 return 1;
849} 851}
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
index 992b1cf8db69..a13f2bc0665c 100644
--- a/drivers/ide/pci/cs5520.c
+++ b/drivers/ide/pci/cs5520.c
@@ -146,6 +146,7 @@ static const struct ide_port_info cyrix_chipsets[] __devinitdata = {
146static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) 146static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id)
147{ 147{
148 const struct ide_port_info *d = &cyrix_chipsets[id->driver_data]; 148 const struct ide_port_info *d = &cyrix_chipsets[id->driver_data];
149 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
149 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 150 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
150 151
151 ide_setup_pci_noise(dev, d); 152 ide_setup_pci_noise(dev, d);
@@ -168,9 +169,9 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
168 * do all the device setup for us 169 * do all the device setup for us
169 */ 170 */
170 171
171 ide_pci_setup_ports(dev, d, 14, &idx[0]); 172 ide_pci_setup_ports(dev, d, 14, &idx[0], &hw[0], &hws[0]);
172 173
173 ide_device_add(idx, d); 174 ide_device_add(idx, d, hws);
174 175
175 return 0; 176 return 0;
176} 177}
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c
index 0106e2a2df77..33fe15db408a 100644
--- a/drivers/ide/pci/delkin_cb.c
+++ b/drivers/ide/pci/delkin_cb.c
@@ -57,9 +57,9 @@ static 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 unsigned long base; 59 unsigned long base;
60 hw_regs_t hw;
61 ide_hwif_t *hwif = NULL; 60 ide_hwif_t *hwif = NULL;
62 int i, rc; 61 int i, rc;
62 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
63 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 63 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
64 64
65 rc = pci_enable_device(dev); 65 rc = pci_enable_device(dev);
@@ -93,11 +93,9 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
93 93
94 i = hwif->index; 94 i = hwif->index;
95 95
96 ide_init_port_hw(hwif, &hw);
97
98 idx[0] = i; 96 idx[0] = i;
99 97
100 ide_device_add(idx, &delkin_cb_port_info); 98 ide_device_add(idx, &delkin_cb_port_info, hws);
101 99
102 pci_set_drvdata(dev, hwif); 100 pci_set_drvdata(dev, hwif);
103 101
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index 789c66dfbde5..328e2df66550 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -554,7 +554,7 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev,
554{ 554{
555 struct scc_ports *ports = pci_get_drvdata(dev); 555 struct scc_ports *ports = pci_get_drvdata(dev);
556 ide_hwif_t *hwif = NULL; 556 ide_hwif_t *hwif = NULL;
557 hw_regs_t hw; 557 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
558 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 558 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
559 int i; 559 int i;
560 560
@@ -568,11 +568,10 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev,
568 hw.irq = dev->irq; 568 hw.irq = dev->irq;
569 hw.dev = &dev->dev; 569 hw.dev = &dev->dev;
570 hw.chipset = ide_pci; 570 hw.chipset = ide_pci;
571 ide_init_port_hw(hwif, &hw);
572 571
573 idx[0] = hwif->index; 572 idx[0] = hwif->index;
574 573
575 ide_device_add(idx, d); 574 ide_device_add(idx, d, hws);
576 575
577 return 0; 576 return 0;
578} 577}
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index c79ff5b41088..76afa1f9c599 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -584,8 +584,8 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
584 unsigned long bar0, cmd_phys_base, ctl; 584 unsigned long bar0, cmd_phys_base, ctl;
585 void __iomem *virt_base; 585 void __iomem *virt_base;
586 ide_hwif_t *hwif; 586 ide_hwif_t *hwif;
587 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
587 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 588 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
588 hw_regs_t hw;
589 struct ide_port_info d = sgiioc4_port_info; 589 struct ide_port_info d = sgiioc4_port_info;
590 590
591 /* Get the CmdBlk and CtrlBlk Base Registers */ 591 /* Get the CmdBlk and CtrlBlk Base Registers */
@@ -622,8 +622,6 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
622 if (hwif == NULL) 622 if (hwif == NULL)
623 goto err; 623 goto err;
624 624
625 ide_init_port_hw(hwif, &hw);
626
627 /* The IOC4 uses MMIO rather than Port IO. */ 625 /* The IOC4 uses MMIO rather than Port IO. */
628 default_hwif_mmiops(hwif); 626 default_hwif_mmiops(hwif);
629 627
@@ -634,7 +632,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
634 632
635 idx[0] = hwif->index; 633 idx[0] = hwif->index;
636 634
637 if (ide_device_add(idx, &d)) 635 if (ide_device_add(idx, &d, hws))
638 return -EIO; 636 return -EIO;
639 637
640 return 0; 638 return 0;
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 4e2944ee76d8..e68e33bb2c35 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1010,6 +1010,7 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
1010 struct device_node *np = pmif->node; 1010 struct device_node *np = pmif->node;
1011 const int *bidp; 1011 const int *bidp;
1012 ide_hwif_t *hwif; 1012 ide_hwif_t *hwif;
1013 hw_regs_t *hws[] = { hw, NULL, NULL, NULL };
1013 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 1014 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
1014 struct ide_port_info d = pmac_port_info; 1015 struct ide_port_info d = pmac_port_info;
1015 1016
@@ -1095,11 +1096,9 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
1095 default_hwif_mmiops(hwif); 1096 default_hwif_mmiops(hwif);
1096 hwif->OUTBSYNC = pmac_outbsync; 1097 hwif->OUTBSYNC = pmac_outbsync;
1097 1098
1098 ide_init_port_hw(hwif, hw);
1099
1100 idx[0] = hwif->index; 1099 idx[0] = hwif->index;
1101 1100
1102 ide_device_add(idx, &d); 1101 ide_device_add(idx, &d, hws);
1103 1102
1104 return 0; 1103 return 0;
1105} 1104}
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index 7ae6ae45331f..acb467c6f345 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -289,6 +289,7 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *
289 * @d: IDE port info 289 * @d: IDE port info
290 * @port: port number 290 * @port: port number
291 * @irq: PCI IRQ 291 * @irq: PCI IRQ
292 * @hw: hw_regs_t instance corresponding to this port
292 * 293 *
293 * Perform the initial set up for the hardware interface structure. This 294 * Perform the initial set up for the hardware interface structure. This
294 * is done per interface port rather than per PCI device. There may be 295 * is done per interface port rather than per PCI device. There may be
@@ -299,11 +300,11 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *
299 300
300static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, 301static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev,
301 const struct ide_port_info *d, 302 const struct ide_port_info *d,
302 unsigned int port, int irq) 303 unsigned int port, int irq,
304 hw_regs_t *hw)
303{ 305{
304 unsigned long ctl = 0, base = 0; 306 unsigned long ctl = 0, base = 0;
305 ide_hwif_t *hwif; 307 ide_hwif_t *hwif;
306 struct hw_regs_s hw;
307 308
308 if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) { 309 if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) {
309 if (ide_pci_check_iomem(dev, d, 2 * port) || 310 if (ide_pci_check_iomem(dev, d, 2 * port) ||
@@ -327,17 +328,17 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev,
327 return NULL; 328 return NULL;
328 } 329 }
329 330
331 memset(hw, 0, sizeof(*hw));
332 hw->irq = irq;
333 hw->dev = &dev->dev;
334 hw->chipset = d->chipset ? d->chipset : ide_pci;
335 ide_std_init_ports(hw, base, ctl | 2);
336
330 hwif = ide_find_port_slot(d); 337 hwif = ide_find_port_slot(d);
331 if (hwif == NULL) 338 if (hwif == NULL)
332 return NULL; 339 return NULL;
333 340
334 memset(&hw, 0, sizeof(hw)); 341 hwif->chipset = hw->chipset;
335 hw.irq = irq;
336 hw.dev = &dev->dev;
337 hw.chipset = d->chipset ? d->chipset : ide_pci;
338 ide_std_init_ports(&hw, base, ctl | 2);
339
340 ide_init_port_hw(hwif, &hw);
341 342
342 return hwif; 343 return hwif;
343} 344}
@@ -430,6 +431,8 @@ out:
430 * @d: IDE port info 431 * @d: IDE port info
431 * @pciirq: IRQ line 432 * @pciirq: IRQ line
432 * @idx: ATA index table to update 433 * @idx: ATA index table to update
434 * @hw: hw_regs_t instances corresponding to this PCI IDE device
435 * @hws: hw_regs_t pointers table to update
433 * 436 *
434 * Scan the interfaces attached to this device and do any 437 * Scan the interfaces attached to this device and do any
435 * necessary per port setup. Attach the devices and ask the 438 * necessary per port setup. Attach the devices and ask the
@@ -440,7 +443,8 @@ out:
440 * where the chipset setup is not the default PCI IDE one. 443 * where the chipset setup is not the default PCI IDE one.
441 */ 444 */
442 445
443void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int pciirq, u8 *idx) 446void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d,
447 int pciirq, u8 *idx, hw_regs_t *hw, hw_regs_t **hws)
444{ 448{
445 int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; 449 int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port;
446 ide_hwif_t *hwif; 450 ide_hwif_t *hwif;
@@ -459,10 +463,11 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int
459 continue; /* port not enabled */ 463 continue; /* port not enabled */
460 } 464 }
461 465
462 hwif = ide_hwif_configure(dev, d, port, pciirq); 466 hwif = ide_hwif_configure(dev, d, port, pciirq, hw + port);
463 if (hwif == NULL) 467 if (hwif == NULL)
464 continue; 468 continue;
465 469
470 *(hws + port) = hw + port;
466 *(idx + port) = hwif->index; 471 *(idx + port) = hwif->index;
467 } 472 }
468} 473}
@@ -537,15 +542,16 @@ out:
537int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) 542int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d)
538{ 543{
539 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 544 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
545 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
540 int ret; 546 int ret;
541 547
542 ret = do_ide_setup_pci_device(dev, d, 1); 548 ret = do_ide_setup_pci_device(dev, d, 1);
543 549
544 if (ret >= 0) { 550 if (ret >= 0) {
545 /* FIXME: silent failure can happen */ 551 /* FIXME: silent failure can happen */
546 ide_pci_setup_ports(dev, d, ret, &idx[0]); 552 ide_pci_setup_ports(dev, d, ret, &idx[0], &hw[0], &hws[0]);
547 553
548 ide_device_add(idx, d); 554 ide_device_add(idx, d, hws);
549 } 555 }
550 556
551 return ret; 557 return ret;
@@ -557,6 +563,7 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
557{ 563{
558 struct pci_dev *pdev[] = { dev1, dev2 }; 564 struct pci_dev *pdev[] = { dev1, dev2 };
559 int ret, i; 565 int ret, i;
566 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
560 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 567 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
561 568
562 for (i = 0; i < 2; i++) { 569 for (i = 0; i < 2; i++) {
@@ -570,10 +577,11 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
570 goto out; 577 goto out;
571 578
572 /* FIXME: silent failure can happen */ 579 /* FIXME: silent failure can happen */
573 ide_pci_setup_ports(pdev[i], d, ret, &idx[i*2]); 580 ide_pci_setup_ports(pdev[i], d, ret, &idx[i*2], &hw[i*2],
581 &hws[i*2]);
574 } 582 }
575 583
576 ide_device_add(idx, d); 584 ide_device_add(idx, d, hws);
577out: 585out:
578 return ret; 586 return ret;
579} 587}