[PATCH 11/12] ide: cleanup ide_match_hwif()

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-ide@...>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@...>, <linux-kernel@...>
Date: Saturday, February 16, 2008 - 12:40 pm

* Remove no longer needed matching against I/O base and 'io_base' argument.

* Move printk() to the caller and remove 'name' argument.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/setup-pci.c |   47 +++++++++++++++--------------------------------
 1 file changed, 15 insertions(+), 32 deletions(-)

Index: b/drivers/ide/setup-pci.c
===================================================================
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -22,42 +22,20 @@
 
 
 /**
- *	ide_match_hwif	-	match a PCI IDE against an ide_hwif
- *	@io_base: I/O base of device
- *	@bootable: set if its bootable
- *	@name: name of device
+ *	ide_match_hwif	-	find free ide_hwifs[] slot
+ *	@bootable: bootable flag
  *
- *	Match a PCI IDE port against an entry in ide_hwifs[],
- *	based on io_base port if possible. Return the matching hwif,
- *	or a new hwif. If we find an error (clashing, out of devices, etc)
- *	return NULL
- *
- *	FIXME: we need to handle mmio matches here too
+ *	Return the new hwif.  If we are out of free slots return NULL.
  */
 
-static ide_hwif_t *ide_match_hwif(unsigned long io_base, u8 bootable, const char *name)
+static ide_hwif_t *ide_match_hwif(u8 bootable)
 {
-	int h;
 	ide_hwif_t *hwif;
+	int h;
 
 	/*
-	 * Look for a hwif with matching io_base default value.
-	 * If chipset is "ide_unknown", then claim that hwif slot.
-	 * Otherwise, some other chipset has already claimed it..  :(
-	 */
-	for (h = 0; h < MAX_HWIFS; ++h) {
-		hwif = &ide_hwifs[h];
-		if (hwif->io_ports[IDE_DATA_OFFSET] == io_base) {
-			if (hwif->chipset == ide_unknown)
-				return hwif; /* match */
-			printk(KERN_ERR "%s: port 0x%04lx already claimed by %s\n",
-				name, io_base, hwif->name);
-			return NULL;	/* already claimed */
-		}
-	}
-	/*
-	 * Okay, there is no hwif matching our io_base,
-	 * so we'll just claim an unassigned slot.
+	 * Claim an unassigned slot.
+	 *
 	 * Give preference to claiming other slots before claiming ide0/ide1,
 	 * just in case there's another interface yet-to-be-scanned
 	 * which uses ports 1f0/170 (the ide0/ide1 defaults).
@@ -83,7 +61,7 @@ static ide_hwif_t *ide_match_hwif(unsign
 		if (hwif->chipset == ide_unknown)
 			return hwif;	/* pick an unused entry */
 	}
-	printk(KERN_ERR "%s: too many IDE interfaces, no room in table\n", name);
+
 	return NULL;
 }
 
@@ -367,8 +345,13 @@ static ide_hwif_t *ide_hwif_configure(st
 		ctl = port ? 0x374 : 0x3f4;
 		base = port ? 0x170 : 0x1f0;
 	}
-	if ((hwif = ide_match_hwif(base, bootable, d->name)) == NULL)
-		return NULL;	/* no room in ide_hwifs[] */
+
+	hwif = ide_match_hwif(bootable);
+	if (hwif == NULL) {
+		printk(KERN_ERR "%s: too many IDE interfaces, no room in "
+				"table\n", d->name);
+		return NULL;
+	}
 
 	memset(&hw, 0, sizeof(hw));
 	hw.irq = irq;
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 01/12] ide: remove ide_default_io_ctl() macro, Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 12:38 pm)
[PATCH 12/12] ide: cleanup ide_find_port(), Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 12:40 pm)
[PATCH 11/12] ide: cleanup ide_match_hwif(), Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 12:40 pm)
[PATCH 10/12] ide: remove ide_init_default_irq() macro, Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 12:40 pm)
[PATCH 09/12] ide: move default IDE ports setup to ide_gener..., Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 12:39 pm)
[PATCH 08/12] ide: remove needless hwif-&gt;irq check from i..., Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 12:39 pm)
[PATCH 07/12] ide: init hwif-&gt;{io_ports,irq} explicitly i..., Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 12:39 pm)
[PATCH 06/12] ide: limit legacy VLB host drivers to alpha, x..., Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 12:39 pm)
[PATCH 05/12] cmd640: init hwif-&gt;{io_ports,irq} explicitly, Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 12:39 pm)
[PATCH 04/12] cmd640: cleanup setup_device_ptrs(), Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 12:39 pm)
[PATCH 03/12] ide: add ide-4drives host driver, Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 12:39 pm)
Re: [PATCH 03/12] ide: add ide-4drives host driver, Sergei Shtylyov, (Tue Feb 19, 9:03 am)
Re: [PATCH 03/12] ide: add ide-4drives host driver, Bartlomiej Zolnierkiewicz..., (Tue Feb 19, 5:24 pm)
Re: [PATCH 03/12] ide: add ide-4drives host driver, Randy Dunlap, (Sat Feb 16, 1:26 pm)
Re: [PATCH 03/12] ide: add ide-4drives host driver, Bartlomiej Zolnierkiewicz..., (Sun Feb 17, 1:12 pm)
[PATCH 02/12] ide: remove ppc ifdef from init_ide_data(), Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 12:39 pm)