diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-04-17 18:46:22 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-04-17 18:46:22 -0400 |
commit | 71bf9f6fe822397e2cce781a2408c658a776fd68 (patch) | |
tree | a278d80c140e95f37b745f2ce65b61afc203803f /drivers/ide | |
parent | 5b0c4b30a625927340a3e7f565aa4de8b60489cc (diff) |
ide: factor out code unregistering devices from ide_unregister()
Factor out code unregistering devices from ide_unregister() to
ide_port_unregister_devices().
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index bd5ff7d987d0..31bc28aacdc9 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -490,6 +490,23 @@ void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) | |||
490 | spin_unlock_irq(&ide_lock); | 490 | spin_unlock_irq(&ide_lock); |
491 | } | 491 | } |
492 | 492 | ||
493 | /* Called with ide_lock held. */ | ||
494 | static void ide_port_unregister_devices(ide_hwif_t *hwif) | ||
495 | { | ||
496 | int i; | ||
497 | |||
498 | for (i = 0; i < MAX_DRIVES; i++) { | ||
499 | ide_drive_t *drive = &hwif->drives[i]; | ||
500 | |||
501 | if (drive->present) { | ||
502 | spin_unlock_irq(&ide_lock); | ||
503 | device_unregister(&drive->gendev); | ||
504 | wait_for_completion(&drive->gendev_rel_comp); | ||
505 | spin_lock_irq(&ide_lock); | ||
506 | } | ||
507 | } | ||
508 | } | ||
509 | |||
493 | /** | 510 | /** |
494 | * ide_unregister - free an IDE interface | 511 | * ide_unregister - free an IDE interface |
495 | * @index: index of interface (will change soon to a pointer) | 512 | * @index: index of interface (will change soon to a pointer) |
@@ -516,11 +533,10 @@ void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) | |||
516 | 533 | ||
517 | void ide_unregister(unsigned int index, int init_default, int restore) | 534 | void ide_unregister(unsigned int index, int init_default, int restore) |
518 | { | 535 | { |
519 | ide_drive_t *drive; | ||
520 | ide_hwif_t *hwif, *g; | 536 | ide_hwif_t *hwif, *g; |
521 | static ide_hwif_t tmp_hwif; /* protected by ide_cfg_mtx */ | 537 | static ide_hwif_t tmp_hwif; /* protected by ide_cfg_mtx */ |
522 | ide_hwgroup_t *hwgroup; | 538 | ide_hwgroup_t *hwgroup; |
523 | int irq_count = 0, unit; | 539 | int irq_count = 0; |
524 | 540 | ||
525 | BUG_ON(index >= MAX_HWIFS); | 541 | BUG_ON(index >= MAX_HWIFS); |
526 | 542 | ||
@@ -531,15 +547,7 @@ void ide_unregister(unsigned int index, int init_default, int restore) | |||
531 | hwif = &ide_hwifs[index]; | 547 | hwif = &ide_hwifs[index]; |
532 | if (!hwif->present) | 548 | if (!hwif->present) |
533 | goto abort; | 549 | goto abort; |
534 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | 550 | ide_port_unregister_devices(hwif); |
535 | drive = &hwif->drives[unit]; | ||
536 | if (!drive->present) | ||
537 | continue; | ||
538 | spin_unlock_irq(&ide_lock); | ||
539 | device_unregister(&drive->gendev); | ||
540 | wait_for_completion(&drive->gendev_rel_comp); | ||
541 | spin_lock_irq(&ide_lock); | ||
542 | } | ||
543 | hwif->present = 0; | 551 | hwif->present = 0; |
544 | 552 | ||
545 | spin_unlock_irq(&ide_lock); | 553 | spin_unlock_irq(&ide_lock); |