Skip to content

Commit e277f91

Browse files
committed
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>
1 parent fe80b93 commit e277f91

8 files changed

Lines changed: 122 additions & 81 deletions

File tree

‎drivers/ide/ide-probe.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,9 @@ ide_hwif_t *ide_find_port_slot(const struct ide_port_info *d)
14681468
* ports 0x1f0/0x170 (the ide0/ide1 defaults).
14691469
*/
14701470
if (bootable) {
1471-
for (i = 0; i < MAX_HWIFS; i++) {
1471+
i = (d && (d->host_flags & IDE_HFLAG_QD_2ND_PORT)) ? 1 : 0;
1472+
1473+
for (; i < MAX_HWIFS; i++) {
14721474
hwif = &ide_hwifs[i];
14731475
if (hwif->chipset == ide_unknown)
14741476
return hwif;

‎drivers/ide/legacy/ali14xx.c‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ static const struct ide_port_info ali14xx_port_info = {
199199

200200
static int __init ali14xx_probe(void)
201201
{
202-
static u8 idx[4] = { 0, 1, 0xff, 0xff };
202+
ide_hwif_t *hwif, *mate;
203+
static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
203204
hw_regs_t hw[2];
204205

205206
printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n",
@@ -219,11 +220,19 @@ static int __init ali14xx_probe(void)
219220
ide_std_init_ports(&hw[1], 0x170, 0x376);
220221
hw[1].irq = 15;
221222

222-
ide_init_port_hw(&ide_hwifs[0], &hw[0]);
223-
ide_init_port_hw(&ide_hwifs[1], &hw[1]);
223+
hwif = ide_find_port();
224+
if (hwif) {
225+
ide_init_port_hw(hwif, &hw[0]);
226+
hwif->set_pio_mode = &ali14xx_set_pio_mode;
227+
idx[0] = hwif->index;
228+
}
224229

225-
ide_hwifs[0].set_pio_mode = &ali14xx_set_pio_mode;
226-
ide_hwifs[1].set_pio_mode = &ali14xx_set_pio_mode;
230+
mate = ide_find_port();
231+
if (mate) {
232+
ide_init_port_hw(mate, &hw[1]);
233+
mate->set_pio_mode = &ali14xx_set_pio_mode;
234+
idx[1] = mate->index;
235+
}
227236

228237
ide_device_add(idx, &ali14xx_port_info);
229238

‎drivers/ide/legacy/dtc2278.c‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,9 @@ static int __init dtc2278_probe(void)
102102
{
103103
unsigned long flags;
104104
ide_hwif_t *hwif, *mate;
105-
static u8 idx[4] = { 0, 1, 0xff, 0xff };
105+
static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
106106
hw_regs_t hw[2];
107107

108-
hwif = &ide_hwifs[0];
109-
mate = &ide_hwifs[1];
110-
111-
if (hwif->chipset != ide_unknown || mate->chipset != ide_unknown)
112-
return 1;
113-
114108
local_irq_save(flags);
115109
/*
116110
* This enables the second interface
@@ -137,10 +131,18 @@ static int __init dtc2278_probe(void)
137131
ide_std_init_ports(&hw[1], 0x170, 0x376);
138132
hw[1].irq = 15;
139133

140-
ide_init_port_hw(hwif, &hw[0]);
141-
ide_init_port_hw(mate, &hw[1]);
134+
hwif = ide_find_port();
135+
if (hwif) {
136+
ide_init_port_hw(hwif, &hw[0]);
137+
hwif->set_pio_mode = dtc2278_set_pio_mode;
138+
idx[0] = hwif->index;
139+
}
142140

143-
hwif->set_pio_mode = &dtc2278_set_pio_mode;
141+
mate = ide_find_port();
142+
if (mate) {
143+
ide_init_port_hw(mate, &hw[1]);
144+
idx[1] = mate->index;
145+
}
144146

145147
ide_device_add(idx, &dtc2278_port_info);
146148

‎drivers/ide/legacy/ht6560b.c‎

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,12 @@ static const struct ide_port_info ht6560b_port_info __initdata = {
340340
static int __init ht6560b_init(void)
341341
{
342342
ide_hwif_t *hwif, *mate;
343-
static u8 idx[4] = { 0, 1, 0xff, 0xff };
343+
static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
344344
hw_regs_t hw[2];
345345

346346
if (probe_ht6560b == 0)
347347
return -ENODEV;
348348

349-
hwif = &ide_hwifs[0];
350-
mate = &ide_hwifs[1];
351-
352349
if (!request_region(HT_CONFIG_PORT, 1, DRV_NAME)) {
353350
printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n",
354351
__FUNCTION__);
@@ -368,17 +365,23 @@ static int __init ht6560b_init(void)
368365
ide_std_init_ports(&hw[1], 0x170, 0x376);
369366
hw[1].irq = 15;
370367

371-
ide_init_port_hw(hwif, &hw[0]);
372-
ide_init_port_hw(mate, &hw[1]);
373-
374-
hwif->selectproc = &ht6560b_selectproc;
375-
hwif->set_pio_mode = &ht6560b_set_pio_mode;
376-
377-
mate->selectproc = &ht6560b_selectproc;
378-
mate->set_pio_mode = &ht6560b_set_pio_mode;
368+
hwif = ide_find_port();
369+
if (hwif) {
370+
ide_init_port_hw(hwif, &hw[0]);
371+
hwif->selectproc = ht6560b_selectproc;
372+
hwif->set_pio_mode = ht6560b_set_pio_mode;
373+
hwif->port_init_devs = ht6560b_port_init_devs;
374+
idx[0] = hwif->index;
375+
}
379376

380-
hwif->port_init_devs = ht6560b_port_init_devs;
381-
mate->port_init_devs = ht6560b_port_init_devs;
377+
mate = ide_find_port();
378+
if (mate) {
379+
ide_init_port_hw(mate, &hw[1]);
380+
mate->selectproc = ht6560b_selectproc;
381+
mate->set_pio_mode = ht6560b_set_pio_mode;
382+
mate->port_init_devs = ht6560b_port_init_devs;
383+
idx[1] = mate->index;
384+
}
382385

383386
ide_device_add(idx, &ht6560b_port_info);
384387

‎drivers/ide/legacy/ide-4drives.c‎

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,37 @@ MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port");
1212
static int __init ide_4drives_init(void)
1313
{
1414
ide_hwif_t *hwif, *mate;
15-
u8 idx[4] = { 0, 1, 0xff, 0xff };
15+
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
1616
hw_regs_t hw;
1717

1818
if (probe_4drives == 0)
1919
return -ENODEV;
2020

21-
hwif = &ide_hwifs[0];
22-
mate = &ide_hwifs[1];
23-
2421
memset(&hw, 0, sizeof(hw));
2522

2623
ide_std_init_ports(&hw, 0x1f0, 0x3f6);
2724
hw.irq = 14;
2825
hw.chipset = ide_4drives;
2926

30-
ide_init_port_hw(hwif, &hw);
31-
ide_init_port_hw(mate, &hw);
32-
33-
mate->drives[0].select.all ^= 0x20;
34-
mate->drives[1].select.all ^= 0x20;
35-
36-
hwif->mate = mate;
37-
mate->mate = hwif;
38-
39-
hwif->serialized = mate->serialized = 1;
27+
hwif = ide_find_port();
28+
if (hwif) {
29+
ide_init_port_hw(hwif, &hw);
30+
idx[0] = hwif->index;
31+
}
32+
33+
mate = ide_find_port();
34+
if (mate) {
35+
ide_init_port_hw(mate, &hw);
36+
mate->drives[0].select.all ^= 0x20;
37+
mate->drives[1].select.all ^= 0x20;
38+
idx[1] = mate->index;
39+
40+
if (hwif) {
41+
hwif->mate = mate;
42+
mate->mate = hwif;
43+
hwif->serialized = mate->serialized = 1;
44+
}
45+
}
4046

4147
ide_device_add(idx, NULL);
4248

‎drivers/ide/legacy/qd65xx.c‎

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ static int __init qd_probe(int base)
355355
u8 config, unit;
356356
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
357357
hw_regs_t hw[2];
358+
struct ide_port_info d = qd65xx_port_info;
358359

359360
config = inb(QD_CONFIG_PORT);
360361

@@ -363,6 +364,9 @@ static int __init qd_probe(int base)
363364

364365
unit = ! (config & QD_CONFIG_IDE_BASEPORT);
365366

367+
if (unit)
368+
d.host_flags |= IDE_HFLAG_QD_2ND_PORT;
369+
366370
memset(&hw, 0, sizeof(hw));
367371

368372
ide_std_init_ports(&hw[0], 0x1f0, 0x3f6);
@@ -378,26 +382,29 @@ static int __init qd_probe(int base)
378382

379383
/* qd6500 found */
380384

381-
hwif = &ide_hwifs[unit];
382-
printk(KERN_NOTICE "%s: qd6500 at %#x\n", hwif->name, base);
383-
printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n",
384-
config, QD_ID3);
385-
386385
if (config & QD_CONFIG_DISABLED) {
387386
printk(KERN_WARNING "qd6500 is disabled !\n");
388387
return -ENODEV;
389388
}
390389

390+
printk(KERN_NOTICE "qd6500 at %#x\n", base);
391+
printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n",
392+
config, QD_ID3);
393+
394+
hwif = ide_find_port_slot(&d);
395+
if (hwif == NULL)
396+
return -ENOENT;
397+
391398
ide_init_port_hw(hwif, &hw[unit]);
392399

393400
qd_setup(hwif, base, config);
394401

395402
hwif->port_init_devs = qd6500_port_init_devs;
396403
hwif->set_pio_mode = &qd6500_set_pio_mode;
397404

398-
idx[unit] = unit;
405+
idx[unit] = hwif->index;
399406

400-
ide_device_add(idx, &qd65xx_port_info);
407+
ide_device_add(idx, &d);
401408

402409
return 1;
403410
}
@@ -423,9 +430,11 @@ static int __init qd_probe(int base)
423430
if (control & QD_CONTR_SEC_DISABLED) {
424431
/* secondary disabled */
425432

426-
hwif = &ide_hwifs[unit];
427-
printk(KERN_INFO "%s: qd6580: single IDE board\n",
428-
hwif->name);
433+
printk(KERN_INFO "qd6580: single IDE board\n");
434+
435+
hwif = ide_find_port_slot(&d);
436+
if (hwif == NULL)
437+
return -ENOENT;
429438

430439
ide_init_port_hw(hwif, &hw[unit]);
431440

@@ -434,35 +443,34 @@ static int __init qd_probe(int base)
434443
hwif->port_init_devs = qd6580_port_init_devs;
435444
hwif->set_pio_mode = &qd6580_set_pio_mode;
436445

437-
idx[unit] = unit;
446+
idx[unit] = hwif->index;
438447

439-
ide_device_add(idx, &qd65xx_port_info);
448+
ide_device_add(idx, &d);
440449

441450
return 1;
442451
} else {
443452
ide_hwif_t *mate;
444453

445-
hwif = &ide_hwifs[0];
446-
mate = &ide_hwifs[1];
447454
/* secondary enabled */
448-
printk(KERN_INFO "%s&%s: qd6580: dual IDE board\n",
449-
hwif->name, mate->name);
450-
451-
ide_init_port_hw(hwif, &hw[0]);
452-
ide_init_port_hw(mate, &hw[1]);
453-
454-
qd_setup(hwif, base, config | (control << 8));
455-
456-
hwif->port_init_devs = qd6580_port_init_devs;
457-
hwif->set_pio_mode = &qd6580_set_pio_mode;
458-
459-
qd_setup(mate, base, config | (control << 8));
460-
461-
mate->port_init_devs = qd6580_port_init_devs;
462-
mate->set_pio_mode = &qd6580_set_pio_mode;
463-
464-
idx[0] = 0;
465-
idx[1] = 1;
455+
printk(KERN_INFO "qd6580: dual IDE board\n");
456+
457+
hwif = ide_find_port();
458+
if (hwif) {
459+
ide_init_port_hw(hwif, &hw[0]);
460+
qd_setup(hwif, base, config | (control << 8));
461+
hwif->port_init_devs = qd6580_port_init_devs;
462+
hwif->set_pio_mode = qd6580_set_pio_mode;
463+
idx[0] = hwif->index;
464+
}
465+
466+
mate = ide_find_port();
467+
if (mate) {
468+
ide_init_port_hw(mate, &hw[1]);
469+
qd_setup(mate, base, config | (control << 8));
470+
mate->port_init_devs = qd6580_port_init_devs;
471+
mate->set_pio_mode = qd6580_set_pio_mode;
472+
idx[1] = mate->index;
473+
}
466474

467475
ide_device_add(idx, &qd65xx_port_info);
468476

‎drivers/ide/legacy/umc8672.c‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ static const struct ide_port_info umc8672_port_info __initdata = {
128128

129129
static int __init umc8672_probe(void)
130130
{
131+
ide_hwif_t *hwif, *mate;
131132
unsigned long flags;
132-
static u8 idx[4] = { 0, 1, 0xff, 0xff };
133+
static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
133134
hw_regs_t hw[2];
134135

135136
if (!request_region(0x108, 2, "umc8672")) {
@@ -157,11 +158,19 @@ static int __init umc8672_probe(void)
157158
ide_std_init_ports(&hw[1], 0x170, 0x376);
158159
hw[1].irq = 15;
159160

160-
ide_init_port_hw(&ide_hwifs[0], &hw[0]);
161-
ide_init_port_hw(&ide_hwifs[1], &hw[1]);
161+
hwif = ide_find_port();
162+
if (hwif) {
163+
ide_init_port_hw(hwif, &hw[0]);
164+
hwif->set_pio_mode = umc_set_pio_mode;
165+
idx[0] = hwif->index;
166+
}
162167

163-
ide_hwifs[0].set_pio_mode = &umc_set_pio_mode;
164-
ide_hwifs[1].set_pio_mode = &umc_set_pio_mode;
168+
mate = ide_find_port();
169+
if (mate) {
170+
ide_init_port_hw(mate, &hw[1]);
171+
mate->set_pio_mode = umc_set_pio_mode;
172+
idx[1] = mate->index;
173+
}
165174

166175
ide_device_add(idx, &umc8672_port_info);
167176

‎include/linux/ide.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,8 @@ enum {
10331033
IDE_HFLAG_SINGLE = (1 << 1),
10341034
/* don't use legacy PIO blacklist */
10351035
IDE_HFLAG_PIO_NO_BLACKLIST = (1 << 2),
1036+
/* set for the second port of QD65xx */
1037+
IDE_HFLAG_QD_2ND_PORT = (1 << 3),
10361038
/* use PIO8/9 for prefetch off/on */
10371039
IDE_HFLAG_ABUSE_PREFETCH = (1 << 4),
10381040
/* use PIO6/7 for fast-devsel off/on */

0 commit comments

Comments
 (0)