Skip to content

Commit

Permalink
ide: pass hw_regs_t-s to ide_device_add[_all]() (take 3)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Bartlomiej Zolnierkiewicz committed Jul 23, 2008
1 parent 51d87ed commit c97c6ac
Show file tree
Hide file tree
Showing 27 changed files with 131 additions and 140 deletions.
13 changes: 6 additions & 7 deletions drivers/ide/arm/icside.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;

Expand Down
5 changes: 2 additions & 3 deletions drivers/ide/arm/ide_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions drivers/ide/arm/palm_bk3710.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions drivers/ide/arm/rapide.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions drivers/ide/h8300/ide-h8300.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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;

Expand Down
23 changes: 12 additions & 11 deletions drivers/ide/ide-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
};
Expand Down Expand Up @@ -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;

Expand All @@ -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) {
Expand Down Expand Up @@ -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 "
Expand Down
6 changes: 2 additions & 4 deletions drivers/ide/ide-pnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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;
}
Expand Down
29 changes: 18 additions & 11 deletions drivers/ide/ide-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@ ide_hwif_t *ide_find_port_slot(const struct ide_port_info *d)
}
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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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);

Expand All @@ -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;
Expand Down Expand Up @@ -1671,29 +1675,32 @@ 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;
}
}

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;
}
Expand Down
1 change: 0 additions & 1 deletion drivers/ide/ide.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions drivers/ide/legacy/buddha.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*/
Expand Down Expand Up @@ -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;

Expand All @@ -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) {
Expand Down Expand Up @@ -221,19 +223,19 @@ static int __init buddha_init(void)
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;
Expand Down
Loading

0 comments on commit c97c6ac

Please sign in to comment.