summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 19:55:50 +0200
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 19:55:50 +0200
commitc97c6aca75fd5f718056fde7cff798b8cbdb07c0 (patch)
tree275635f3afb9d3a1f1f9ea5cebe08b5f327fc92c
parent51d87ed0aab98999bebaf891b99730e15502a592 (diff)
downloadblackbird-op-linux-c97c6aca75fd5f718056fde7cff798b8cbdb07c0.tar.gz
blackbird-op-linux-c97c6aca75fd5f718056fde7cff798b8cbdb07c0.zip
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>
-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
-rw-r--r--include/linux/ide.h7
27 files changed, 131 insertions, 140 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)
{
ide_hwif_t *hwif;
void __iomem *base;
+ hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
- hw_regs_t hw;
base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
if (!base)
@@ -467,7 +467,6 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
if (!hwif)
return -ENODEV;
- ide_init_port_hw(hwif, &hw);
default_hwif_mmiops(hwif);
state->hwif[0] = hwif;
@@ -476,7 +475,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
idx[0] = hwif->index;
- ide_device_add(idx, NULL);
+ ide_device_add(idx, NULL, hws);
return 0;
}
@@ -497,9 +496,9 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
void __iomem *ioc_base, *easi_base;
unsigned int sel = 0;
int ret;
+ hw_regs_t hw[2], *hws[] = { &hw[0], NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
struct ide_port_info d = icside_v6_port_info;
- hw_regs_t hw[2];
ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
if (!ioc_base) {
@@ -545,16 +544,16 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
if (hwif == NULL)
return -ENODEV;
- ide_init_port_hw(hwif, &hw[0]);
+ hwif->chipset = ide_acorn;
default_hwif_mmiops(hwif);
idx[0] = hwif->index;
mate = ide_find_port();
if (mate) {
- ide_init_port_hw(mate, &hw[1]);
default_hwif_mmiops(mate);
+ hws[1] = &hw[1];
idx[1] = mate->index;
}
@@ -569,7 +568,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
d.dma_ops = NULL;
}
- ide_device_add(idx, &d);
+ ide_device_add(idx, &d, hws);
return 0;
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 @@
static int __init ide_arm_init(void)
{
ide_hwif_t *hwif;
- hw_regs_t hw;
unsigned long base = IDE_ARM_IO, ctl = IDE_ARM_IO + 0x206;
+ hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
if (!request_region(base, 8, DRV_NAME)) {
@@ -53,10 +53,9 @@ static int __init ide_arm_init(void)
hwif = ide_find_port();
if (hwif) {
- ide_init_port_hw(hwif, &hw);
idx[0] = hwif->index;
- ide_device_add(idx, NULL);
+ ide_device_add(idx, NULL, hws);
}
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)
ide_hwif_t *hwif;
unsigned long base, rate;
int i;
- hw_regs_t hw;
+ hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
clk = clk_get(NULL, "IDECLK");
@@ -400,13 +400,11 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev)
i = hwif->index;
- ide_init_port_hw(hwif, &hw);
-
default_hwif_mmiops(hwif);
idx[0] = i;
- ide_device_add(idx, &palm_bk3710_port_info);
+ ide_device_add(idx, &palm_bk3710_port_info, hws);
return 0;
out:
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)
ide_hwif_t *hwif;
void __iomem *base;
int ret;
+ hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
- hw_regs_t hw;
ret = ecard_request_resources(ec);
if (ret)
@@ -59,12 +59,11 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
goto release;
}
- ide_init_port_hw(hwif, &hw);
default_hwif_mmiops(hwif);
idx[0] = hwif->index;
- ide_device_add(idx, &rapide_port_info);
+ ide_device_add(idx, &rapide_port_info, hws);
ecard_set_drvdata(ec, hwif);
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 = {
static int __init h8300_ide_init(void)
{
- hw_regs_t hw;
ide_hwif_t *hwif;
int index;
+ hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface\n");
@@ -205,12 +205,11 @@ static int __init h8300_ide_init(void)
return -ENOENT;
index = hwif->index;
- ide_init_port_hw(hwif, &hw);
hwif_setup(hwif);
idx[0] = index;
- ide_device_add(idx, &h8300_port_info);
+ ide_device_add(idx, &h8300_port_info, hws);
return 0;
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)
ide_hwif_t *hwif;
unsigned int base, ctl;
int irq;
- hw_regs_t hw;
+ hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
u8 idx[] = { 0xff, 0xff, 0xff, 0xff };
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)
hw.irq = irq;
hw.chipset = ide_generic;
- ide_init_port_hw(hwif, &hw);
-
idx[0] = hwif->index;
- ide_device_add(idx, NULL);
+ ide_device_add(idx, NULL, hws);
return n;
};
@@ -90,6 +88,7 @@ static int __init ide_generic_sysfs_init(void)
static int __init ide_generic_init(void)
{
+ hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS];
u8 idx[MAX_HWIFS];
int i;
@@ -99,8 +98,8 @@ static int __init ide_generic_init(void)
for (i = 0; i < MAX_HWIFS; i++) {
ide_hwif_t *hwif;
unsigned long io_addr = ide_default_io_base(i);
- hw_regs_t hw;
+ hws[i] = NULL;
idx[i] = 0xff;
if ((probe_mask & (1 << i)) && io_addr) {
@@ -129,17 +128,19 @@ static int __init ide_generic_init(void)
continue;
}
- memset(&hw, 0, sizeof(hw));
- ide_std_init_ports(&hw, io_addr, io_addr + 0x206);
- hw.irq = ide_default_irq(io_addr);
- hw.chipset = ide_generic;
- ide_init_port_hw(hwif, &hw);
+ hwif->chipset = ide_generic;
+
+ memset(&hw[i], 0, sizeof(hw[i]));
+ ide_std_init_ports(&hw[i], io_addr, io_addr + 0x206);
+ hw[i].irq = ide_default_irq(io_addr);
+ hw[i].chipset = ide_generic;
+ hws[i] = &hw[i];
idx[i] = i;
}
}
- ide_device_add_all(idx, NULL);
+ ide_device_add_all(idx, NULL, hws);
if (ide_generic_sysfs_init())
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[] = {
static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
{
- hw_regs_t hw;
ide_hwif_t *hwif;
unsigned long base, ctl;
+ hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
printk(KERN_INFO DRV_NAME ": generic PnP IDE interface\n");
@@ -64,11 +64,9 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
u8 index = hwif->index;
u8 idx[4] = { index, 0xff, 0xff, 0xff };
- ide_init_port_hw(hwif, &hw);
-
pnp_set_drvdata(dev, hwif);
- ide_device_add(idx, NULL);
+ ide_device_add(idx, NULL, hws);
return 0;
}
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:
}
EXPORT_SYMBOL_GPL(ide_find_port_slot);
-int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
+int ide_device_add_all(u8 *idx, const struct ide_port_info *d, hw_regs_t **hws)
{
ide_hwif_t *hwif, *mate = NULL;
int i, rc = 0;
@@ -1514,6 +1514,7 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
hwif = &ide_hwifs[idx[i]];
+ ide_init_port_hw(hwif, hws[i]);
ide_port_apply_params(hwif);
if (d == NULL) {
@@ -1603,15 +1604,18 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
}
EXPORT_SYMBOL_GPL(ide_device_add_all);
-int ide_device_add(u8 idx[4], const struct ide_port_info *d)
+int ide_device_add(u8 *idx, const struct ide_port_info *d, hw_regs_t **hws)
{
+ hw_regs_t *hws_all[MAX_HWIFS];
u8 idx_all[MAX_HWIFS];
int i;
- for (i = 0; i < MAX_HWIFS; i++)
+ for (i = 0; i < MAX_HWIFS; i++) {
+ hws_all[i] = (i < 4) ? hws[i] : NULL;
idx_all[i] = (i < 4) ? idx[i] : 0xff;
+ }
- return ide_device_add_all(idx_all, d);
+ return ide_device_add_all(idx_all, d, hws_all);
}
EXPORT_SYMBOL_GPL(ide_device_add);
@@ -1634,8 +1638,8 @@ void ide_port_scan(ide_hwif_t *hwif)
}
EXPORT_SYMBOL_GPL(ide_port_scan);
-static void ide_legacy_init_one(u8 *idx, hw_regs_t *hw, u8 port_no,
- const struct ide_port_info *d,
+static void ide_legacy_init_one(u8 *idx, hw_regs_t **hws, hw_regs_t *hw,
+ u8 port_no, const struct ide_port_info *d,
unsigned long config)
{
ide_hwif_t *hwif;
@@ -1671,9 +1675,12 @@ static void ide_legacy_init_one(u8 *idx, hw_regs_t *hw, u8 port_no,
hwif = ide_find_port_slot(d);
if (hwif) {
- ide_init_port_hw(hwif, hw);
+ hwif->chipset = hw->chipset;
+
if (config)
hwif->config_data = config;
+
+ hws[port_no] = hw;
idx[port_no] = hwif->index;
}
}
@@ -1681,19 +1688,19 @@ static void ide_legacy_init_one(u8 *idx, hw_regs_t *hw, u8 port_no,
int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config)
{
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
- hw_regs_t hw[2];
+ hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL };
memset(&hw, 0, sizeof(hw));
if ((d->host_flags & IDE_HFLAG_QD_2ND_PORT) == 0)
- ide_legacy_init_one(idx, &hw[0], 0, d, config);
- ide_legacy_init_one(idx, &hw[1], 1, d, config);
+ ide_legacy_init_one(idx, hws, &hw[0], 0, d, config);
+ ide_legacy_init_one(idx, hws, &hw[1], 1, d, config);
if (idx[0] == 0xff && idx[1] == 0xff &&
(d->host_flags & IDE_HFLAG_SINGLE))
return -ENOENT;
- ide_device_add(idx, d);
+ ide_device_add(idx, d, hws);
return 0;
}
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)
hwif->gendev.parent = hw->parent ? hw->parent : hw->dev;
hwif->ack_intr = hw->ack_intr;
}
-EXPORT_SYMBOL_GPL(ide_init_port_hw);
/*
* 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 @@
#define CATWEASEL_NUM_HWIFS 3
#define XSURF_NUM_HWIFS 2
+#define MAX_NUM_HWIFS 3
+
/*
* Bases of the IDE interfaces (relative to the board address)
*/
@@ -148,7 +150,6 @@ static void __init buddha_setup_ports(hw_regs_t *hw, unsigned long base,
static int __init buddha_init(void)
{
- hw_regs_t hw;
ide_hwif_t *hwif;
int i;
@@ -159,6 +160,7 @@ static int __init buddha_init(void)
while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
unsigned long board;
+ hw_regs_t hw[MAX_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA) {
@@ -221,19 +223,19 @@ fail_base2:
ack_intr = xsurf_ack_intr;
}
- buddha_setup_ports(&hw, base, ctl, irq_port, ack_intr);
+ buddha_setup_ports(&hw[i], base, ctl, irq_port,
+ ack_intr);
hwif = ide_find_port();
if (hwif) {
- u8 index = hwif->index;
-
- ide_init_port_hw(hwif, &hw);
+ hwif->chipset = ide_generic;
- idx[i] = index;
+ hws[i] = &hw[i];
+ idx[i] = hwif->index;
}
}
- ide_device_add(idx, NULL);
+ ide_device_add(idx, NULL, hws);
}
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)
static int __init falconide_init(void)
{
- hw_regs_t hw;
ide_hwif_t *hwif;
+ hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE))
return 0;
@@ -111,14 +111,12 @@ static int __init falconide_init(void)
u8 index = hwif->index;
u8 idx[4] = { index, 0xff, 0xff, 0xff };
- ide_init_port_hw(hwif, &hw);
-
/* Atari has a byte-swapped IDE interface */
hwif->input_data = falconide_input_data;
hwif->output_data = falconide_output_data;
ide_get_lock(NULL, NULL);
- ide_device_add(idx, NULL);
+ ide_device_add(idx, NULL, hws);
ide_release_lock();
}
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,
static int __init gayle_init(void)
{
int a4000, i;
+ hw_regs_t hw[GAYLE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
if (!MACH_IS_AMIGA)
@@ -151,7 +152,6 @@ found:
for (i = 0; i < GAYLE_NUM_PROBE_HWIFS; i++) {
unsigned long base, ctrlport, irqport;
ide_ack_intr_t *ack_intr;
- hw_regs_t hw;
ide_hwif_t *hwif;
unsigned long phys_base, res_start, res_n;
@@ -179,20 +179,19 @@ found:
base = (unsigned long)ZTWO_VADDR(phys_base);
ctrlport = GAYLE_HAS_CONTROL_REG ? (base + GAYLE_CONTROL) : 0;
- gayle_setup_ports(&hw, base, ctrlport, irqport, ack_intr);
+ gayle_setup_ports(&hw[i], base, ctrlport, irqport, ack_intr);
hwif = ide_find_port();
if (hwif) {
- u8 index = hwif->index;
+ hwif->chipset = ide_generic;
- ide_init_port_hw(hwif, &hw);
-
- idx[i] = index;
+ hws[i] = &hw[i];
+ idx[i] = hwif->index;
} else
release_mem_region(res_start, res_n);
}
- ide_device_add(idx, NULL);
+ ide_device_add(idx, NULL, hws);
return 0;
}
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)
{
ide_hwif_t *hwif, *mate;
unsigned long base = 0x1f0, ctl = 0x3f6;
+ hw_regs_t hw, *hws[] = { NULL, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
- hw_regs_t hw;
if (probe_4drives == 0)
return -ENODEV;
@@ -57,17 +57,19 @@ static int __init ide_4drives_init(void)
hwif = ide_find_port();
if (hwif) {
- ide_init_port_hw(hwif, &hw);
+ hwif->chipset = ide_4drives;
+
+ hws[0] = &hw;
idx[0] = hwif->index;
}
mate = ide_find_port();
if (mate) {
- ide_init_port_hw(mate, &hw);
+ hws[1] = &hw;
idx[1] = mate->index;
}
- ide_device_add(idx, &ide_4drives_port_info);
+ ide_device_add(idx, &ide_4drives_port_info, hws);
return 0;
}
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,
unsigned long irq, struct pcmcia_device *handle)
{
ide_hwif_t *hwif;
- hw_regs_t hw;
int i;
+ hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
if (!request_region(io, 8, DRV_NAME)) {
@@ -188,13 +188,9 @@ static ide_hwif_t *idecs_register(unsigned long io, unsigned long ctl,
if (hwif == NULL)
goto out_release;
- i = hwif->index;
+ idx[0] = hwif->index;
- ide_init_port_hw(hwif, &hw);
-
- idx[0] = i;
-
- ide_device_add(idx, &idecs_port_info);
+ ide_device_add(idx, &idecs_port_info, hws);
if (hwif->present)
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)
void __iomem *base, *alt_base;
ide_hwif_t *hwif;
struct pata_platform_info *pdata;
+ int ret = 0, mmio = 0;
+ hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
- int ret = 0;
- int mmio = 0;
- hw_regs_t hw;
struct ide_port_info d = platform_ide_port_info;
pdata = pdev->dev.platform_data;
@@ -104,8 +103,6 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
plat_ide_setup_ports(&hw, base, alt_base, pdata, res_irq->start);
hw.dev = &pdev->dev;
- ide_init_port_hw(hwif, &hw);
-
if (mmio) {
d.host_flags |= IDE_HFLAG_MMIO;
default_hwif_mmiops(hwif);
@@ -113,7 +110,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
idx[0] = hwif->index;
- ide_device_add(idx, &d);
+ ide_device_add(idx, &d, hws);
platform_set_drvdata(pdev, hwif);
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)
ide_ack_intr_t *ack_intr;
unsigned long base;
int irq;
- hw_regs_t hw;
+ hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
if (!MACH_IS_MAC)
return -ENODEV;
@@ -130,9 +130,7 @@ static int __init macide_init(void)
u8 index = hwif->index;
u8 idx[4] = { index, 0xff, 0xff, 0xff };
- ide_init_port_hw(hwif, &hw);
-
- ide_device_add(idx, NULL);
+ ide_device_add(idx, NULL, hws);
}
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)
{
int i;
ide_hwif_t *hwif;
- const char *name;
+ hw_regs_t hw[Q40IDE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
if (!MACH_IS_Q40)
@@ -121,9 +121,8 @@ static int __init q40ide_init(void)
printk(KERN_INFO "ide: Q40 IDE controller\n");
for (i = 0; i < Q40IDE_NUM_HWIFS; i++) {
- hw_regs_t hw;
+ const char *name = q40_ide_names[i];
- name = q40_ide_names[i];
if (!request_region(pcide_bases[i], 8, name)) {
printk("could not reserve ports %lx-%lx for %s\n",
pcide_bases[i],pcide_bases[i]+8,name);
@@ -135,24 +134,23 @@ static int __init q40ide_init(void)
release_region(pcide_bases[i], 8);
continue;
}
- q40_ide_setup_ports(&hw, pcide_bases[i],
- NULL,
-// m68kide_iops,
+ q40_ide_setup_ports(&hw[i], pcide_bases[i], NULL,
q40ide_default_irq(pcide_bases[i]));
hwif = ide_find_port();
if (hwif) {
- ide_init_port_hw(hwif, &hw);
+ hwif->chipset = ide_generic;
/* Q40 has a byte-swapped IDE interface */
hwif->input_data = q40ide_input_data;
hwif->output_data = q40ide_output_data;
+ hws[i] = &hw[i];
idx[i] = hwif->index;
}
}
- ide_device_add(idx, NULL);
+ ide_device_add(idx, NULL, hws);
return 0;
}
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)
ide_hwif_t *hwif;
struct resource *res;
int ret = 0;
+ hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
- hw_regs_t hw;
#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA)
char *mode = "MWDMA2";
@@ -596,8 +596,6 @@ static int au_ide_probe(struct device *dev)
hw.dev = dev;
hw.chipset = ide_au1xxx;
- ide_init_port_hw(hwif, &hw);
-
/* If the user has selected DDMA assisted copies,
then set up a few local I/O function entry points
*/
@@ -611,7 +609,7 @@ static int au_ide_probe(struct device *dev)
idx[0] = hwif->index;
- ide_device_add(idx, &au1xxx_port_info);
+ ide_device_add(idx, &au1xxx_port_info, hws);
dev_set_drvdata(dev, hwif);
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)
ide_hwif_t *hwif;
u8 __iomem *base;
phys_t offset, size;
- hw_regs_t hw;
int i;
+ hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
u8 idx[] = { 0xff, 0xff, 0xff, 0xff };
if (!SIBYTE_HAVE_IDE)
@@ -120,14 +120,12 @@ static int __devinit swarm_ide_probe(struct device *dev)
if (hwif == NULL)
goto err;
- ide_init_port_hw(hwif, &hw);
-
/* Setup MMIO ops. */
default_hwif_mmiops(hwif);
idx[0] = hwif->index;
- ide_device_add(idx, &swarm_port_info);
+ ide_device_add(idx, &swarm_port_info, hws);
dev_set_drvdata(dev, hwif);
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)
int second_port_cmd640 = 0, rc;
const char *bus_type, *port2;
u8 b, cfr;
+ hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
- hw_regs_t hw[2];
if (cmd640_vlb && probe_for_cmd640_vlb()) {
bus_type = "VLB";
@@ -787,7 +787,9 @@ static int __init cmd640x_init(void)
* Initialize data for primary port
*/
if (cmd_hwif0) {
- ide_init_port_hw(cmd_hwif0, &hw[0]);
+ cmd_hwif0->chipset = ide_cmd640;
+
+ hws[0] = &hw[0];
idx[0] = cmd_hwif0->index;
}
@@ -832,7 +834,7 @@ static int __init cmd640x_init(void)
if (second_port_cmd640) {
cmd_hwif1 = ide_find_port();
if (cmd_hwif1) {
- ide_init_port_hw(cmd_hwif1, &hw[1]);
+ hws[1] = &hw[1];
idx[1] = cmd_hwif1->index;
}
}
@@ -843,7 +845,7 @@ static int __init cmd640x_init(void)
cmd640_dump_regs();
#endif
- ide_device_add(idx, &cmd640_port_info);
+ ide_device_add(idx, &cmd640_port_info, hws);
return 1;
}
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 = {
static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{
const struct ide_port_info *d = &cyrix_chipsets[id->driver_data];
+ hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
ide_setup_pci_noise(dev, d);
@@ -168,9 +169,9 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
* do all the device setup for us
*/
- ide_pci_setup_ports(dev, d, 14, &idx[0]);
+ ide_pci_setup_ports(dev, d, 14, &idx[0], &hw[0], &hws[0]);
- ide_device_add(idx, d);
+ ide_device_add(idx, d, hws);
return 0;
}
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
delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
{
unsigned long base;
- hw_regs_t hw;
ide_hwif_t *hwif = NULL;
int i, rc;
+ hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
rc = pci_enable_device(dev);
@@ -93,11 +93,9 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
i = hwif->index;
- ide_init_port_hw(hwif, &hw);
-
idx[0] = i;
- ide_device_add(idx, &delkin_cb_port_info);
+ ide_device_add(idx, &delkin_cb_port_info, hws);
pci_set_drvdata(dev, hwif);
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,
{
struct scc_ports *ports = pci_get_drvdata(dev);
ide_hwif_t *hwif = NULL;
- hw_regs_t hw;
+ hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
int i;
@@ -568,11 +568,10 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev,
hw.irq = dev->irq;
hw.dev = &dev->dev;
hw.chipset = ide_pci;
- ide_init_port_hw(hwif, &hw);
idx[0] = hwif->index;
- ide_device_add(idx, d);
+ ide_device_add(idx, d, hws);
return 0;
}
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)
unsigned long bar0, cmd_phys_base, ctl;
void __iomem *virt_base;
ide_hwif_t *hwif;
+ hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
- hw_regs_t hw;
struct ide_port_info d = sgiioc4_port_info;
/* Get the CmdBlk and CtrlBlk Base Registers */
@@ -622,8 +622,6 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
if (hwif == NULL)
goto err;
- ide_init_port_hw(hwif, &hw);
-
/* The IOC4 uses MMIO rather than Port IO. */
default_hwif_mmiops(hwif);
@@ -634,7 +632,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
idx[0] = hwif->index;
- if (ide_device_add(idx, &d))
+ if (ide_device_add(idx, &d, hws))
return -EIO;
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)
struct device_node *np = pmif->node;
const int *bidp;
ide_hwif_t *hwif;
+ hw_regs_t *hws[] = { hw, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
struct ide_port_info d = pmac_port_info;
@@ -1095,11 +1096,9 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
default_hwif_mmiops(hwif);
hwif->OUTBSYNC = pmac_outbsync;
- ide_init_port_hw(hwif, hw);
-
idx[0] = hwif->index;
- ide_device_add(idx, &d);
+ ide_device_add(idx, &d, hws);
return 0;
}
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 *
* @d: IDE port info
* @port: port number
* @irq: PCI IRQ
+ * @hw: hw_regs_t instance corresponding to this port
*
* Perform the initial set up for the hardware interface structure. This
* 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 *
static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev,
const struct ide_port_info *d,
- unsigned int port, int irq)
+ unsigned int port, int irq,
+ hw_regs_t *hw)
{
unsigned long ctl = 0, base = 0;
ide_hwif_t *hwif;
- struct hw_regs_s hw;
if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) {
if (ide_pci_check_iomem(dev, d, 2 * port) ||
@@ -327,17 +328,17 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev,
return NULL;
}
+ memset(hw, 0, sizeof(*hw));
+ hw->irq = irq;
+ hw->dev = &dev->dev;
+ hw->chipset = d->chipset ? d->chipset : ide_pci;
+ ide_std_init_ports(hw, base, ctl | 2);
+
hwif = ide_find_port_slot(d);
if (hwif == NULL)
return NULL;
- memset(&hw, 0, sizeof(hw));
- hw.irq = irq;
- hw.dev = &dev->dev;
- hw.chipset = d->chipset ? d->chipset : ide_pci;
- ide_std_init_ports(&hw, base, ctl | 2);
-
- ide_init_port_hw(hwif, &hw);
+ hwif->chipset = hw->chipset;
return hwif;
}
@@ -430,6 +431,8 @@ out:
* @d: IDE port info
* @pciirq: IRQ line
* @idx: ATA index table to update
+ * @hw: hw_regs_t instances corresponding to this PCI IDE device
+ * @hws: hw_regs_t pointers table to update
*
* Scan the interfaces attached to this device and do any
* necessary per port setup. Attach the devices and ask the
@@ -440,7 +443,8 @@ out:
* where the chipset setup is not the default PCI IDE one.
*/
-void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int pciirq, u8 *idx)
+void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d,
+ int pciirq, u8 *idx, hw_regs_t *hw, hw_regs_t **hws)
{
int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port;
ide_hwif_t *hwif;
@@ -459,10 +463,11 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int
continue; /* port not enabled */
}
- hwif = ide_hwif_configure(dev, d, port, pciirq);
+ hwif = ide_hwif_configure(dev, d, port, pciirq, hw + port);
if (hwif == NULL)
continue;
+ *(hws + port) = hw + port;
*(idx + port) = hwif->index;
}
}
@@ -537,15 +542,16 @@ out:
int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d)
{
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
+ hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
int ret;
ret = do_ide_setup_pci_device(dev, d, 1);
if (ret >= 0) {
/* FIXME: silent failure can happen */
- ide_pci_setup_ports(dev, d, ret, &idx[0]);
+ ide_pci_setup_ports(dev, d, ret, &idx[0], &hw[0], &hws[0]);
- ide_device_add(idx, d);
+ ide_device_add(idx, d, hws);
}
return ret;
@@ -557,6 +563,7 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
{
struct pci_dev *pdev[] = { dev1, dev2 };
int ret, i;
+ hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
for (i = 0; i < 2; i++) {
@@ -570,10 +577,11 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
goto out;
/* FIXME: silent failure can happen */
- ide_pci_setup_ports(pdev[i], d, ret, &idx[i*2]);
+ ide_pci_setup_ports(pdev[i], d, ret, &idx[i*2], &hw[i*2],
+ &hws[i*2]);
}
- ide_device_add(idx, d);
+ ide_device_add(idx, d, hws);
out:
return ret;
}
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 4726126f5a59..f58548becac0 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1000,7 +1000,8 @@ extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *o
#define ide_pci_register_driver(d) pci_register_driver(d)
#endif
-void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int, u8 *);
+void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int,
+ u8 *, hw_regs_t *, hw_regs_t **);
void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *);
#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
@@ -1217,8 +1218,8 @@ void ide_undecoded_slave(ide_drive_t *);
void ide_port_apply_params(ide_hwif_t *);
-int ide_device_add_all(u8 *idx, const struct ide_port_info *);
-int ide_device_add(u8 idx[4], const struct ide_port_info *);
+int ide_device_add_all(u8 *, const struct ide_port_info *, hw_regs_t **);
+int ide_device_add(u8 *, const struct ide_port_info *, hw_regs_t **);
int ide_legacy_device_add(const struct ide_port_info *, unsigned long);
void ide_port_unregister_devices(ide_hwif_t *);
void ide_port_scan(ide_hwif_t *);
OpenPOWER on IntegriCloud