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: NBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
上级 2305d943
...@@ -1630,40 +1630,50 @@ void ide_port_scan(ide_hwif_t *hwif) ...@@ -1630,40 +1630,50 @@ void ide_port_scan(ide_hwif_t *hwif)
} }
EXPORT_SYMBOL_GPL(ide_port_scan); EXPORT_SYMBOL_GPL(ide_port_scan);
int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config) static void ide_legacy_init_one(u8 *idx, hw_regs_t *hw, u8 port_no,
const struct ide_port_info *d,
unsigned long config)
{ {
ide_hwif_t *hwif, *mate; ide_hwif_t *hwif;
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; unsigned long base, ctl;
hw_regs_t hw[2]; int irq;
memset(&hw, 0, sizeof(hw));
ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); if (port_no == 0) {
hw[0].irq = 14; base = 0x1f0;
ctl = 0x3f6;
irq = 14;
} else {
base = 0x170;
ctl = 0x376;
irq = 15;
}
ide_std_init_ports(&hw[1], 0x170, 0x376); ide_std_init_ports(hw, base, ctl);
hw[1].irq = 15; hw->irq = irq;
hwif = ide_find_port_slot(d); hwif = ide_find_port_slot(d);
if (hwif) { if (hwif) {
u8 j = (d->host_flags & IDE_HFLAG_QD_2ND_PORT) ? 1 : 0; ide_init_port_hw(hwif, hw);
ide_init_port_hw(hwif, &hw[j]);
if (config) if (config)
hwif->config_data = config; hwif->config_data = config;
idx[j] = hwif->index; idx[port_no] = hwif->index;
} }
}
if (hwif == NULL && (d->host_flags & IDE_HFLAG_SINGLE)) int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config)
return -ENOENT; {
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
hw_regs_t hw[2];
mate = ide_find_port_slot(d); memset(&hw, 0, sizeof(hw));
if (mate) {
ide_init_port_hw(mate, &hw[1]); if ((d->host_flags & IDE_HFLAG_QD_2ND_PORT) == 0)
if (config) ide_legacy_init_one(idx, &hw[0], 0, d, config);
mate->config_data = config; ide_legacy_init_one(idx, &hw[1], 1, d, config);
idx[1] = mate->index;
} 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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册