diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-04-26 16:25:18 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-04-26 16:25:18 -0400 |
commit | d9b819a025ca1b09dafbe90b5d25ba57a639f048 (patch) | |
tree | 242d4c8cb9b8232ff5b707afc656debce5b985d7 /drivers/ide | |
parent | 2305d94321bbbdc461acfb24b41fbf50f8a6dd91 (diff) |
ide: add ide_legacy_init_one() helper
Move the common code for primary/seconary port setup from
ide_legacy_device_add() to ide_legacy_init_one().
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide-probe.c | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index da6025cfa09a..e299c80c6a57 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -1630,40 +1630,50 @@ void ide_port_scan(ide_hwif_t *hwif) | |||
1630 | } | 1630 | } |
1631 | EXPORT_SYMBOL_GPL(ide_port_scan); | 1631 | EXPORT_SYMBOL_GPL(ide_port_scan); |
1632 | 1632 | ||
1633 | int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config) | 1633 | static void ide_legacy_init_one(u8 *idx, hw_regs_t *hw, u8 port_no, |
1634 | const struct ide_port_info *d, | ||
1635 | unsigned long config) | ||
1634 | { | 1636 | { |
1635 | ide_hwif_t *hwif, *mate; | 1637 | ide_hwif_t *hwif; |
1636 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 1638 | unsigned long base, ctl; |
1637 | hw_regs_t hw[2]; | 1639 | int irq; |
1638 | |||
1639 | memset(&hw, 0, sizeof(hw)); | ||
1640 | 1640 | ||
1641 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); | 1641 | if (port_no == 0) { |
1642 | hw[0].irq = 14; | 1642 | base = 0x1f0; |
1643 | ctl = 0x3f6; | ||
1644 | irq = 14; | ||
1645 | } else { | ||
1646 | base = 0x170; | ||
1647 | ctl = 0x376; | ||
1648 | irq = 15; | ||
1649 | } | ||
1643 | 1650 | ||
1644 | ide_std_init_ports(&hw[1], 0x170, 0x376); | 1651 | ide_std_init_ports(hw, base, ctl); |
1645 | hw[1].irq = 15; | 1652 | hw->irq = irq; |
1646 | 1653 | ||
1647 | hwif = ide_find_port_slot(d); | 1654 | hwif = ide_find_port_slot(d); |
1648 | if (hwif) { | 1655 | if (hwif) { |
1649 | u8 j = (d->host_flags & IDE_HFLAG_QD_2ND_PORT) ? 1 : 0; | 1656 | ide_init_port_hw(hwif, hw); |
1650 | |||
1651 | ide_init_port_hw(hwif, &hw[j]); | ||
1652 | if (config) | 1657 | if (config) |
1653 | hwif->config_data = config; | 1658 | hwif->config_data = config; |
1654 | idx[j] = hwif->index; | 1659 | idx[port_no] = hwif->index; |
1655 | } | 1660 | } |
1661 | } | ||
1656 | 1662 | ||
1657 | if (hwif == NULL && (d->host_flags & IDE_HFLAG_SINGLE)) | 1663 | int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config) |
1658 | return -ENOENT; | 1664 | { |
1665 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
1666 | hw_regs_t hw[2]; | ||
1659 | 1667 | ||
1660 | mate = ide_find_port_slot(d); | 1668 | memset(&hw, 0, sizeof(hw)); |
1661 | if (mate) { | 1669 | |
1662 | ide_init_port_hw(mate, &hw[1]); | 1670 | if ((d->host_flags & IDE_HFLAG_QD_2ND_PORT) == 0) |
1663 | if (config) | 1671 | ide_legacy_init_one(idx, &hw[0], 0, d, config); |
1664 | mate->config_data = config; | 1672 | ide_legacy_init_one(idx, &hw[1], 1, d, config); |
1665 | idx[1] = mate->index; | 1673 | |
1666 | } | 1674 | if (idx[0] == 0xff && idx[1] == 0xff && |
1675 | (d->host_flags & IDE_HFLAG_SINGLE)) | ||
1676 | return -ENOENT; | ||
1667 | 1677 | ||
1668 | ide_device_add(idx, d); | 1678 | ide_device_add(idx, d); |
1669 | 1679 | ||