aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-probe.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:58 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:58 -0400
commit6059143ae34f30bb49ec8733468315284f78e2da (patch)
treec891300d24bb78664464e44a3924293c6c85a5c1 /drivers/ide/ide-probe.c
parent8cdf310025bff8c5ef78564f525a8f347952237b (diff)
ide: move ide_remove_port_from_hwgroup() to ide-probe.c
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r--drivers/ide/ide-probe.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index fdf00cde9fce..21cdd9ca14d1 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -992,6 +992,41 @@ static void ide_port_setup_devices(ide_hwif_t *hwif)
992 mutex_unlock(&ide_cfg_mtx); 992 mutex_unlock(&ide_cfg_mtx);
993} 993}
994 994
995void ide_remove_port_from_hwgroup(ide_hwif_t *hwif)
996{
997 ide_hwgroup_t *hwgroup = hwif->hwgroup;
998
999 spin_lock_irq(&ide_lock);
1000 /*
1001 * Remove us from the hwgroup, and free
1002 * the hwgroup if we were the only member
1003 */
1004 if (hwif->next == hwif) {
1005 BUG_ON(hwgroup->hwif != hwif);
1006 kfree(hwgroup);
1007 } else {
1008 /* There is another interface in hwgroup.
1009 * Unlink us, and set hwgroup->drive and ->hwif to
1010 * something sane.
1011 */
1012 ide_hwif_t *g = hwgroup->hwif;
1013
1014 while (g->next != hwif)
1015 g = g->next;
1016 g->next = hwif->next;
1017 if (hwgroup->hwif == hwif) {
1018 /* Chose a random hwif for hwgroup->hwif.
1019 * It's guaranteed that there are no drives
1020 * left in the hwgroup.
1021 */
1022 BUG_ON(hwgroup->drive != NULL);
1023 hwgroup->hwif = g;
1024 }
1025 BUG_ON(hwgroup->hwif == hwif);
1026 }
1027 spin_unlock_irq(&ide_lock);
1028}
1029
995/* 1030/*
996 * This routine sets up the irq for an ide interface, and creates a new 1031 * This routine sets up the irq for an ide interface, and creates a new
997 * hwgroup for the irq/hwif if none was previously assigned. 1032 * hwgroup for the irq/hwif if none was previously assigned.