Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cae5c820 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz
Browse files

ide: prepare init_irq() for using ide_remove_port_from_hwgroup()



* BUG_ON() early if 'hwif->next == hwif' and there is a 'match' hwgroup.

* Remove printk() for impossible condition and add a BUG_ON(hwgroup->drive)
  to match code in ide_unregister().

Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 96e5ad30
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -996,6 +996,7 @@ static int init_irq (ide_hwif_t *hwif)
		spin_lock_irq(&ide_lock);
		spin_lock_irq(&ide_lock);
		hwif->next = hwgroup->hwif->next;
		hwif->next = hwgroup->hwif->next;
		hwgroup->hwif->next = hwif;
		hwgroup->hwif->next = hwif;
		BUG_ON(hwif->next == hwif);
		spin_unlock_irq(&ide_lock);
		spin_unlock_irq(&ide_lock);
	} else {
	} else {
		hwgroup = kmalloc_node(sizeof(*hwgroup), GFP_KERNEL|__GFP_ZERO,
		hwgroup = kmalloc_node(sizeof(*hwgroup), GFP_KERNEL|__GFP_ZERO,
@@ -1075,7 +1076,6 @@ static int init_irq (ide_hwif_t *hwif)
out_unlink:
out_unlink:
	spin_lock_irq(&ide_lock);
	spin_lock_irq(&ide_lock);
	if (hwif->next == hwif) {
	if (hwif->next == hwif) {
		BUG_ON(match);
		BUG_ON(hwgroup->hwif != hwif);
		BUG_ON(hwgroup->hwif != hwif);
		kfree(hwgroup);
		kfree(hwgroup);
	} else {
	} else {
@@ -1085,8 +1085,7 @@ out_unlink:
			g = g->next;
			g = g->next;
		g->next = hwif->next;
		g->next = hwif->next;
		if (hwgroup->hwif == hwif) {
		if (hwgroup->hwif == hwif) {
			/* Impossible. */
			BUG_ON(hwgroup->drive);
			printk(KERN_ERR "Duh. Uninitialized hwif listed as active hwif.\n");
			hwgroup->hwif = g;
			hwgroup->hwif = g;
		}
		}
		BUG_ON(hwgroup->hwif == hwif);
		BUG_ON(hwgroup->hwif == hwif);