|
@@ -992,6 +992,41 @@ static void ide_port_setup_devices(ide_hwif_t *hwif)
|
|
|
mutex_unlock(&ide_cfg_mtx);
|
|
|
}
|
|
|
|
|
|
+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);
|
|
|
+}
|
|
|
+
|
|
|
/*
|
|
|
* This routine sets up the irq for an ide interface, and creates a new
|
|
|
* hwgroup for the irq/hwif if none was previously assigned.
|