diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-04-26 17:36:36 +0200 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-04-26 17:36:36 +0200 |
commit | e277f91fef8a0ff7726ad33eb79c6f0d0c6229a8 (patch) | |
tree | d275b5e0c720c5db73efa446c86a2437fd93dca2 /drivers/ide/legacy/qd65xx.c | |
parent | ide: merge ide_match_hwif() and ide_find_port() (diff) | |
download | linux-e277f91fef8a0ff7726ad33eb79c6f0d0c6229a8.tar.xz linux-e277f91fef8a0ff7726ad33eb79c6f0d0c6229a8.zip |
ide: use ide_find_port() in legacy VLB host drivers (take 2)
* Add IDE_HFLAG_QD_2ND_PORT host flag to indicate the need of skipping
first ide_hwifs[] slot for the second port of QD65xx controller.
* Handle this new host flag in ide_find_port_slot().
* Convert legacy VLB host drivers to use ide_find_port().
While at it:
* Fix couple of printk()-s in qd65xx host driver to not use hwif->name.
v2:
* Fix qd65xx.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/legacy/qd65xx.c')
-rw-r--r-- | drivers/ide/legacy/qd65xx.c | 72 |
1 files changed, 40 insertions, 32 deletions
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c index 5c92fb6d81a1..b693a5f21a42 100644 --- a/drivers/ide/legacy/qd65xx.c +++ b/drivers/ide/legacy/qd65xx.c @@ -355,6 +355,7 @@ static int __init qd_probe(int base) u8 config, unit; u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; hw_regs_t hw[2]; + struct ide_port_info d = qd65xx_port_info; config = inb(QD_CONFIG_PORT); @@ -363,6 +364,9 @@ static int __init qd_probe(int base) unit = ! (config & QD_CONFIG_IDE_BASEPORT); + if (unit) + d.host_flags |= IDE_HFLAG_QD_2ND_PORT; + memset(&hw, 0, sizeof(hw)); ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); @@ -378,16 +382,19 @@ static int __init qd_probe(int base) /* qd6500 found */ - hwif = &ide_hwifs[unit]; - printk(KERN_NOTICE "%s: qd6500 at %#x\n", hwif->name, base); - printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n", - config, QD_ID3); - if (config & QD_CONFIG_DISABLED) { printk(KERN_WARNING "qd6500 is disabled !\n"); return -ENODEV; } + printk(KERN_NOTICE "qd6500 at %#x\n", base); + printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n", + config, QD_ID3); + + hwif = ide_find_port_slot(&d); + if (hwif == NULL) + return -ENOENT; + ide_init_port_hw(hwif, &hw[unit]); qd_setup(hwif, base, config); @@ -395,9 +402,9 @@ static int __init qd_probe(int base) hwif->port_init_devs = qd6500_port_init_devs; hwif->set_pio_mode = &qd6500_set_pio_mode; - idx[unit] = unit; + idx[unit] = hwif->index; - ide_device_add(idx, &qd65xx_port_info); + ide_device_add(idx, &d); return 1; } @@ -423,9 +430,11 @@ static int __init qd_probe(int base) if (control & QD_CONTR_SEC_DISABLED) { /* secondary disabled */ - hwif = &ide_hwifs[unit]; - printk(KERN_INFO "%s: qd6580: single IDE board\n", - hwif->name); + printk(KERN_INFO "qd6580: single IDE board\n"); + + hwif = ide_find_port_slot(&d); + if (hwif == NULL) + return -ENOENT; ide_init_port_hw(hwif, &hw[unit]); @@ -434,35 +443,34 @@ static int __init qd_probe(int base) hwif->port_init_devs = qd6580_port_init_devs; hwif->set_pio_mode = &qd6580_set_pio_mode; - idx[unit] = unit; + idx[unit] = hwif->index; - ide_device_add(idx, &qd65xx_port_info); + ide_device_add(idx, &d); return 1; } else { ide_hwif_t *mate; - hwif = &ide_hwifs[0]; - mate = &ide_hwifs[1]; /* secondary enabled */ - printk(KERN_INFO "%s&%s: qd6580: dual IDE board\n", - hwif->name, mate->name); - - ide_init_port_hw(hwif, &hw[0]); - ide_init_port_hw(mate, &hw[1]); - - qd_setup(hwif, base, config | (control << 8)); - - hwif->port_init_devs = qd6580_port_init_devs; - hwif->set_pio_mode = &qd6580_set_pio_mode; - - qd_setup(mate, base, config | (control << 8)); - - mate->port_init_devs = qd6580_port_init_devs; - mate->set_pio_mode = &qd6580_set_pio_mode; - - idx[0] = 0; - idx[1] = 1; + printk(KERN_INFO "qd6580: dual IDE board\n"); + + hwif = ide_find_port(); + if (hwif) { + ide_init_port_hw(hwif, &hw[0]); + qd_setup(hwif, base, config | (control << 8)); + hwif->port_init_devs = qd6580_port_init_devs; + hwif->set_pio_mode = qd6580_set_pio_mode; + idx[0] = hwif->index; + } + + mate = ide_find_port(); + if (mate) { + ide_init_port_hw(mate, &hw[1]); + qd_setup(mate, base, config | (control << 8)); + mate->port_init_devs = qd6580_port_init_devs; + mate->set_pio_mode = qd6580_set_pio_mode; + idx[1] = mate->index; + } ide_device_add(idx, &qd65xx_port_info); |