diff options
Diffstat (limited to 'drivers/ide/ide.c')
-rw-r--r-- | drivers/ide/ide.c | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 97894abd9ebc..ab9ca2b5b66c 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -1,7 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/ide.c Version 7.00beta2 Mar 05 2003 | 2 | * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) |
3 | * | 3 | * Copyrifht (C) 2003-2005, 2007 Bartlomiej Zolnierkiewicz |
4 | * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) | ||
5 | */ | 4 | */ |
6 | 5 | ||
7 | /* | 6 | /* |
@@ -46,7 +45,6 @@ | |||
46 | */ | 45 | */ |
47 | 46 | ||
48 | #define REVISION "Revision: 7.00alpha2" | 47 | #define REVISION "Revision: 7.00alpha2" |
49 | #define VERSION "Id: ide.c 7.00a2 20020906" | ||
50 | 48 | ||
51 | #define _IDE_C /* Tell ide.h it's really us */ | 49 | #define _IDE_C /* Tell ide.h it's really us */ |
52 | 50 | ||
@@ -242,22 +240,12 @@ static int ide_system_bus_speed(void) | |||
242 | #define pci_default 0 | 240 | #define pci_default 0 |
243 | #endif /* CONFIG_PCI */ | 241 | #endif /* CONFIG_PCI */ |
244 | 242 | ||
245 | if (!system_bus_speed) { | 243 | /* user supplied value */ |
246 | if (idebus_parameter) { | 244 | if (idebus_parameter) |
247 | /* user supplied value */ | 245 | return idebus_parameter; |
248 | system_bus_speed = idebus_parameter; | 246 | |
249 | } else if (pci_dev_present(pci_default)) { | 247 | /* safe default value for PCI or VESA and PCI*/ |
250 | /* safe default value for PCI */ | 248 | return pci_dev_present(pci_default) ? 33 : 50; |
251 | system_bus_speed = 33; | ||
252 | } else { | ||
253 | /* safe default value for VESA and PCI */ | ||
254 | system_bus_speed = 50; | ||
255 | } | ||
256 | printk(KERN_INFO "ide: Assuming %dMHz system bus speed " | ||
257 | "for PIO modes%s\n", system_bus_speed, | ||
258 | idebus_parameter ? "" : "; override with idebus=xx"); | ||
259 | } | ||
260 | return system_bus_speed; | ||
261 | } | 249 | } |
262 | 250 | ||
263 | ide_hwif_t * ide_find_port(unsigned long base) | 251 | ide_hwif_t * ide_find_port(unsigned long base) |
@@ -405,8 +393,9 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif) | |||
405 | hwif->chipset = tmp_hwif->chipset; | 393 | hwif->chipset = tmp_hwif->chipset; |
406 | hwif->hold = tmp_hwif->hold; | 394 | hwif->hold = tmp_hwif->hold; |
407 | 395 | ||
396 | hwif->dev = tmp_hwif->dev; | ||
397 | |||
408 | #ifdef CONFIG_BLK_DEV_IDEPCI | 398 | #ifdef CONFIG_BLK_DEV_IDEPCI |
409 | hwif->pci_dev = tmp_hwif->pci_dev; | ||
410 | hwif->cds = tmp_hwif->cds; | 399 | hwif->cds = tmp_hwif->cds; |
411 | #endif | 400 | #endif |
412 | 401 | ||
@@ -472,6 +461,41 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif) | |||
472 | hwif->hwif_data = tmp_hwif->hwif_data; | 461 | hwif->hwif_data = tmp_hwif->hwif_data; |
473 | } | 462 | } |
474 | 463 | ||
464 | void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) | ||
465 | { | ||
466 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | ||
467 | |||
468 | spin_lock_irq(&ide_lock); | ||
469 | /* | ||
470 | * Remove us from the hwgroup, and free | ||
471 | * the hwgroup if we were the only member | ||
472 | */ | ||
473 | if (hwif->next == hwif) { | ||
474 | BUG_ON(hwgroup->hwif != hwif); | ||
475 | kfree(hwgroup); | ||
476 | } else { | ||
477 | /* There is another interface in hwgroup. | ||
478 | * Unlink us, and set hwgroup->drive and ->hwif to | ||
479 | * something sane. | ||
480 | */ | ||
481 | ide_hwif_t *g = hwgroup->hwif; | ||
482 | |||
483 | while (g->next != hwif) | ||
484 | g = g->next; | ||
485 | g->next = hwif->next; | ||
486 | if (hwgroup->hwif == hwif) { | ||
487 | /* Chose a random hwif for hwgroup->hwif. | ||
488 | * It's guaranteed that there are no drives | ||
489 | * left in the hwgroup. | ||
490 | */ | ||
491 | BUG_ON(hwgroup->drive != NULL); | ||
492 | hwgroup->hwif = g; | ||
493 | } | ||
494 | BUG_ON(hwgroup->hwif == hwif); | ||
495 | } | ||
496 | spin_unlock_irq(&ide_lock); | ||
497 | } | ||
498 | |||
475 | /** | 499 | /** |
476 | * ide_unregister - free an IDE interface | 500 | * ide_unregister - free an IDE interface |
477 | * @index: index of interface (will change soon to a pointer) | 501 | * @index: index of interface (will change soon to a pointer) |
@@ -539,43 +563,8 @@ void ide_unregister(unsigned int index) | |||
539 | if (irq_count == 1) | 563 | if (irq_count == 1) |
540 | free_irq(hwif->irq, hwgroup); | 564 | free_irq(hwif->irq, hwgroup); |
541 | 565 | ||
542 | spin_lock_irq(&ide_lock); | 566 | ide_remove_port_from_hwgroup(hwif); |
543 | /* | ||
544 | * Note that we only release the standard ports, | ||
545 | * and do not even try to handle any extra ports | ||
546 | * allocated for weird IDE interface chipsets. | ||
547 | */ | ||
548 | ide_hwif_release_regions(hwif); | ||
549 | |||
550 | /* | ||
551 | * Remove us from the hwgroup, and free | ||
552 | * the hwgroup if we were the only member | ||
553 | */ | ||
554 | if (hwif->next == hwif) { | ||
555 | BUG_ON(hwgroup->hwif != hwif); | ||
556 | kfree(hwgroup); | ||
557 | } else { | ||
558 | /* There is another interface in hwgroup. | ||
559 | * Unlink us, and set hwgroup->drive and ->hwif to | ||
560 | * something sane. | ||
561 | */ | ||
562 | g = hwgroup->hwif; | ||
563 | while (g->next != hwif) | ||
564 | g = g->next; | ||
565 | g->next = hwif->next; | ||
566 | if (hwgroup->hwif == hwif) { | ||
567 | /* Chose a random hwif for hwgroup->hwif. | ||
568 | * It's guaranteed that there are no drives | ||
569 | * left in the hwgroup. | ||
570 | */ | ||
571 | BUG_ON(hwgroup->drive != NULL); | ||
572 | hwgroup->hwif = g; | ||
573 | } | ||
574 | BUG_ON(hwgroup->hwif == hwif); | ||
575 | } | ||
576 | 567 | ||
577 | /* More messed up locking ... */ | ||
578 | spin_unlock_irq(&ide_lock); | ||
579 | device_unregister(&hwif->gendev); | 568 | device_unregister(&hwif->gendev); |
580 | wait_for_completion(&hwif->gendev_rel_comp); | 569 | wait_for_completion(&hwif->gendev_rel_comp); |
581 | 570 | ||
@@ -601,6 +590,13 @@ void ide_unregister(unsigned int index) | |||
601 | hwif->extra_ports = 0; | 590 | hwif->extra_ports = 0; |
602 | } | 591 | } |
603 | 592 | ||
593 | /* | ||
594 | * Note that we only release the standard ports, | ||
595 | * and do not even try to handle any extra ports | ||
596 | * allocated for weird IDE interface chipsets. | ||
597 | */ | ||
598 | ide_hwif_release_regions(hwif); | ||
599 | |||
604 | /* copy original settings */ | 600 | /* copy original settings */ |
605 | tmp_hwif = *hwif; | 601 | tmp_hwif = *hwif; |
606 | 602 | ||
@@ -913,7 +909,7 @@ static int set_unmaskirq(ide_drive_t *drive, int arg) | |||
913 | 909 | ||
914 | int system_bus_clock (void) | 910 | int system_bus_clock (void) |
915 | { | 911 | { |
916 | return((int) ((!system_bus_speed) ? ide_system_bus_speed() : system_bus_speed )); | 912 | return system_bus_speed; |
917 | } | 913 | } |
918 | 914 | ||
919 | EXPORT_SYMBOL(system_bus_clock); | 915 | EXPORT_SYMBOL(system_bus_clock); |
@@ -1668,6 +1664,10 @@ static int __init ide_init(void) | |||
1668 | printk(KERN_INFO "Uniform Multi-Platform E-IDE driver " REVISION "\n"); | 1664 | printk(KERN_INFO "Uniform Multi-Platform E-IDE driver " REVISION "\n"); |
1669 | system_bus_speed = ide_system_bus_speed(); | 1665 | system_bus_speed = ide_system_bus_speed(); |
1670 | 1666 | ||
1667 | printk(KERN_INFO "ide: Assuming %dMHz system bus speed " | ||
1668 | "for PIO modes%s\n", system_bus_speed, | ||
1669 | idebus_parameter ? "" : "; override with idebus=xx"); | ||
1670 | |||
1671 | ret = bus_register(&ide_bus_type); | 1671 | ret = bus_register(&ide_bus_type); |
1672 | if (ret < 0) { | 1672 | if (ret < 0) { |
1673 | printk(KERN_WARNING "IDE: bus_register error: %d\n", ret); | 1673 | printk(KERN_WARNING "IDE: bus_register error: %d\n", ret); |