summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-04-18 00:46:22 +0200
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-04-18 00:46:22 +0200
commit71bf9f6fe822397e2cce781a2408c658a776fd68 (patch)
treea278d80c140e95f37b745f2ce65b61afc203803f /drivers
parent5b0c4b30a625927340a3e7f565aa4de8b60489cc (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')
-rw-r--r--drivers/ide/ide.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index bd5ff7d987d..31bc28aacdc 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)
spin_unlock_irq(&ide_lock);
}
+/* Called with ide_lock held. */
+static void ide_port_unregister_devices(ide_hwif_t *hwif)
+{
+ int i;
+
+ for (i = 0; i < MAX_DRIVES; i++) {
+ ide_drive_t *drive = &hwif->drives[i];
+
+ if (drive->present) {
+ spin_unlock_irq(&ide_lock);
+ device_unregister(&drive->gendev);
+ wait_for_completion(&drive->gendev_rel_comp);
+ spin_lock_irq(&ide_lock);
+ }
+ }
+}
+
/**
* ide_unregister - free an IDE interface
* @index: index of interface (will change soon to a pointer)
@@ -516,11 +533,10 @@ void ide_remove_port_from_hwgroup(ide_hwif_t *hwif)
void ide_unregister(unsigned int index, int init_default, int restore)
{
- ide_drive_t *drive;
ide_hwif_t *hwif, *g;
static ide_hwif_t tmp_hwif; /* protected by ide_cfg_mtx */
ide_hwgroup_t *hwgroup;
- int irq_count = 0, unit;
+ int irq_count = 0;
BUG_ON(index >= MAX_HWIFS);
@@ -531,15 +547,7 @@ void ide_unregister(unsigned int index, int init_default, int restore)
hwif = &ide_hwifs[index];
if (!hwif->present)
goto abort;
- for (unit = 0; unit < MAX_DRIVES; ++unit) {
- drive = &hwif->drives[unit];
- if (!drive->present)
- continue;
- spin_unlock_irq(&ide_lock);
- device_unregister(&drive->gendev);
- wait_for_completion(&drive->gendev_rel_comp);
- spin_lock_irq(&ide_lock);
- }
+ ide_port_unregister_devices(hwif);
hwif->present = 0;
spin_unlock_irq(&ide_lock);