From 746f06e1a584bb4f91aaf9f8b6cda2e2a9a7e55c Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Fri, 1 Feb 2008 23:09:35 +0100 Subject: [PATCH] --- yaml --- r: 82159 b: refs/heads/master c: 96e5ad309c423bc0793e746337d5632ee5a49769 h: refs/heads/master i: 82157: c1d021422d701c0efa536f0ee64ff2610c4c70d4 82155: 6f25614e0f00e77e221174153afbd5c9ef8a8676 82151: 5ac71adc4090a342bb78742ccccc006a055dbed3 82143: 24b94cc9de40369e81ad3044df7501783727050b v: v3 --- [refs] | 2 +- trunk/drivers/ide/ide.c | 65 +++++++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/[refs] b/[refs] index af03b463bca7..18a3367195d7 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 7cba97f12963721eca648d6901b294750a1fa3bd +refs/heads/master: 96e5ad309c423bc0793e746337d5632ee5a49769 diff --git a/trunk/drivers/ide/ide.c b/trunk/drivers/ide/ide.c index ea7512d99dec..1a3c89471175 100644 --- a/trunk/drivers/ide/ide.c +++ b/trunk/drivers/ide/ide.c @@ -461,6 +461,41 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif) hwif->hwif_data = tmp_hwif->hwif_data; } +static void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) +{ + ide_hwgroup_t *hwgroup = hwif->hwgroup; + + spin_lock_irq(&ide_lock); + /* + * Remove us from the hwgroup, and free + * the hwgroup if we were the only member + */ + if (hwif->next == hwif) { + BUG_ON(hwgroup->hwif != hwif); + kfree(hwgroup); + } else { + /* There is another interface in hwgroup. + * Unlink us, and set hwgroup->drive and ->hwif to + * something sane. + */ + ide_hwif_t *g = hwgroup->hwif; + + while (g->next != hwif) + g = g->next; + g->next = hwif->next; + if (hwgroup->hwif == hwif) { + /* Chose a random hwif for hwgroup->hwif. + * It's guaranteed that there are no drives + * left in the hwgroup. + */ + BUG_ON(hwgroup->drive != NULL); + hwgroup->hwif = g; + } + BUG_ON(hwgroup->hwif == hwif); + } + spin_unlock_irq(&ide_lock); +} + /** * ide_unregister - free an IDE interface * @index: index of interface (will change soon to a pointer) @@ -528,36 +563,8 @@ void ide_unregister(unsigned int index) if (irq_count == 1) free_irq(hwif->irq, hwgroup); - spin_lock_irq(&ide_lock); - /* - * Remove us from the hwgroup, and free - * the hwgroup if we were the only member - */ - if (hwif->next == hwif) { - BUG_ON(hwgroup->hwif != hwif); - kfree(hwgroup); - } else { - /* There is another interface in hwgroup. - * Unlink us, and set hwgroup->drive and ->hwif to - * something sane. - */ - g = hwgroup->hwif; - while (g->next != hwif) - g = g->next; - g->next = hwif->next; - if (hwgroup->hwif == hwif) { - /* Chose a random hwif for hwgroup->hwif. - * It's guaranteed that there are no drives - * left in the hwgroup. - */ - BUG_ON(hwgroup->drive != NULL); - hwgroup->hwif = g; - } - BUG_ON(hwgroup->hwif == hwif); - } + ide_remove_port_from_hwgroup(hwif); - /* More messed up locking ... */ - spin_unlock_irq(&ide_lock); device_unregister(&hwif->gendev); wait_for_completion(&hwif->gendev_rel_comp);