aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/legacy/qd65xx.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-04-26 11:36:36 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-04-26 11:36:36 -0400
commite277f91fef8a0ff7726ad33eb79c6f0d0c6229a8 (patch)
treed275b5e0c720c5db73efa446c86a2437fd93dca2 /drivers/ide/legacy/qd65xx.c
parentfe80b937c9917887e4fbfaaf52f498b5ac3a6999 (diff)
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.c72
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)
355 u8 config, unit; 355 u8 config, unit;
356 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 356 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
357 hw_regs_t hw[2]; 357 hw_regs_t hw[2];
358 struct ide_port_info d = qd65xx_port_info;
358 359
359 config = inb(QD_CONFIG_PORT); 360 config = inb(QD_CONFIG_PORT);
360 361
@@ -363,6 +364,9 @@ static int __init qd_probe(int base)
363 364
364 unit = ! (config & QD_CONFIG_IDE_BASEPORT); 365 unit = ! (config & QD_CONFIG_IDE_BASEPORT);
365 366
367 if (unit)
368 d.host_flags |= IDE_HFLAG_QD_2ND_PORT;
369
366 memset(&hw, 0, sizeof(hw)); 370 memset(&hw, 0, sizeof(hw));
367 371
368 ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); 372 ide_std_init_ports(&hw[0], 0x1f0, 0x3f6);
@@ -378,16 +382,19 @@ static int __init qd_probe(int base)
378 382
379 /* qd6500 found */ 383 /* qd6500 found */
380 384
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
386 if (config & QD_CONFIG_DISABLED) { 385 if (config & QD_CONFIG_DISABLED) {
387 printk(KERN_WARNING "qd6500 is disabled !\n"); 386 printk(KERN_WARNING "qd6500 is disabled !\n");
388 return -ENODEV; 387 return -ENODEV;
389 } 388 }
390 389
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
391 ide_init_port_hw(hwif, &hw[unit]); 398 ide_init_port_hw(hwif, &hw[unit]);
392 399
393 qd_setup(hwif, base, config); 400 qd_setup(hwif, base, config);
@@ -395,9 +402,9 @@ static int __init qd_probe(int base)
395 hwif->port_init_devs = qd6500_port_init_devs; 402 hwif->port_init_devs = qd6500_port_init_devs;
396 hwif->set_pio_mode = &qd6500_set_pio_mode; 403 hwif->set_pio_mode = &qd6500_set_pio_mode;
397 404
398 idx[unit] = unit; 405 idx[unit] = hwif->index;
399 406
400 ide_device_add(idx, &qd65xx_port_info); 407 ide_device_add(idx, &d);
401 408
402 return 1; 409 return 1;
403 } 410 }
@@ -423,9 +430,11 @@ static int __init qd_probe(int base)
423 if (control & QD_CONTR_SEC_DISABLED) { 430 if (control & QD_CONTR_SEC_DISABLED) {
424 /* secondary disabled */ 431 /* secondary disabled */
425 432
426 hwif = &ide_hwifs[unit]; 433 printk(KERN_INFO "qd6580: single IDE board\n");
427 printk(KERN_INFO "%s: qd6580: single IDE board\n", 434
428 hwif->name); 435 hwif = ide_find_port_slot(&d);
436 if (hwif == NULL)
437 return -ENOENT;
429 438
430 ide_init_port_hw(hwif, &hw[unit]); 439 ide_init_port_hw(hwif, &hw[unit]);
431 440
@@ -434,35 +443,34 @@ static int __init qd_probe(int base)
434 hwif->port_init_devs = qd6580_port_init_devs; 443 hwif->port_init_devs = qd6580_port_init_devs;
435 hwif->set_pio_mode = &qd6580_set_pio_mode; 444 hwif->set_pio_mode = &qd6580_set_pio_mode;
436 445
437 idx[unit] = unit; 446 idx[unit] = hwif->index;
438 447
439 ide_device_add(idx, &qd65xx_port_info); 448 ide_device_add(idx, &d);
440 449
441 return 1; 450 return 1;
442 } else { 451 } else {
443 ide_hwif_t *mate; 452 ide_hwif_t *mate;
444 453
445 hwif = &ide_hwifs[0];
446 mate = &ide_hwifs[1];
447 /* secondary enabled */ 454 /* secondary enabled */
448 printk(KERN_INFO "%s&%s: qd6580: dual IDE board\n", 455 printk(KERN_INFO "qd6580: dual IDE board\n");
449 hwif->name, mate->name); 456
450 457 hwif = ide_find_port();
451 ide_init_port_hw(hwif, &hw[0]); 458 if (hwif) {
452 ide_init_port_hw(mate, &hw[1]); 459 ide_init_port_hw(hwif, &hw[0]);
453 460 qd_setup(hwif, base, config | (control << 8));
454 qd_setup(hwif, base, config | (control << 8)); 461 hwif->port_init_devs = qd6580_port_init_devs;
455 462 hwif->set_pio_mode = qd6580_set_pio_mode;
456 hwif->port_init_devs = qd6580_port_init_devs; 463 idx[0] = hwif->index;
457 hwif->set_pio_mode = &qd6580_set_pio_mode; 464 }
458 465
459 qd_setup(mate, base, config | (control << 8)); 466 mate = ide_find_port();
460 467 if (mate) {
461 mate->port_init_devs = qd6580_port_init_devs; 468 ide_init_port_hw(mate, &hw[1]);
462 mate->set_pio_mode = &qd6580_set_pio_mode; 469 qd_setup(mate, base, config | (control << 8));
463 470 mate->port_init_devs = qd6580_port_init_devs;
464 idx[0] = 0; 471 mate->set_pio_mode = qd6580_set_pio_mode;
465 idx[1] = 1; 472 idx[1] = mate->index;
473 }
466 474
467 ide_device_add(idx, &qd65xx_port_info); 475 ide_device_add(idx, &qd65xx_port_info);
468 476