[parisc-linux-cvs] pa23: random cleanups

Matthew Wilcox willy@ldl.fc.hp.com
Sat, 9 Feb 2002 20:16:45 -0700 (MST)


 * Stop checking hversion_rev in match_device.  All drivers specify
   HVERSION_REV_ANY_ID anyway.
 * Don't print a warning if a driver declines to claim a device.  That's
   allowed.
 * Revert get_node_path to its previous form.  I found another bug in
   doing the inventory and adding another hack would have been silly.
 * Neaten up walk_native_bus a little, I have moral objections to the
   previous code.
 * Fix a bug in fixup_child_irqs.  If the device had no children, it
   would assign irqs to siblings instead, which led to the bogus serial
   port being detected on Cujo.
 * A few more Dino -> Cujo changes.  Print a little more information when
   we get a stuck interrupt.
 * Make the GSC serial driver return silently for Cujo's serial port (if
   it's unassigned).  Improve the error message and make it not dependent
   on any CONFIG options.
 * Clean up a comment and remove the A180's serial port from the
   serial1_tbl.

 * Call request_mem_region for each successful device/driver claim.
 * Make gsc_common_irqsetup a little more sensible about what regions
   it claims.
 * Delete request/release regions from lasi700.c, parport_gsc.c, harmony.c

Index: arch/parisc/kernel/drivers.c
===================================================================
RCS file: /var/cvs/linux/arch/parisc/kernel/drivers.c,v
retrieving revision 1.42
diff -u -p -r1.42 drivers.c
--- arch/parisc/kernel/drivers.c	2002/02/09 06:44:23	1.42
+++ arch/parisc/kernel/drivers.c	2002/02/09 20:31:02
@@ -92,15 +92,17 @@ static int match_device(struct parisc_dr
 		    (ids->hversion != dev->id.hversion))
 			continue;
 
-		if ((ids->hversion_rev != HVERSION_REV_ANY_ID) &&
-		    (ids->hversion_rev != dev->id.hversion_rev))
-			continue;
-
 		return 1;
 	}
 	return 0;
 }
 
+static void claim_device(struct parisc_driver *driver, struct parisc_device *dev)
+{
+	dev->driver = driver;
+	request_mem_region(dev->hpa, 0x1000, driver->name);
+}
+
 /**
  * register_parisc_driver - Register this driver if it can handle a device
  * @driver: the PA-RISC driver to try
@@ -122,14 +124,9 @@ int register_parisc_driver(struct parisc
 		if (!match_device(driver, device))
 			continue;
 
-		if (driver->probe(device) == 0) {
-			device->driver = driver;
-		} else {
-			printk(KERN_WARNING "Warning : device (%d, 0x%x, 0x%x, 0x%x) NOT claimed by %s\n",
-				device->id.hw_type, device->id.hversion,
-				device->id.hversion_rev, device->id.sversion,
-				driver->name);
-		}
+		if (driver->probe(device) < 0)
+			continue;
+		claim_device(driver, device);
 	}
 
 	/* Note that the list is in reverse order of registration.  This
@@ -220,12 +217,10 @@ static void
 get_node_path(struct parisc_device *dev, struct hardware_path *path)
 {
 	int i = 5;
-	path->mod = dev->hw_path;
 	memset(&path->bc, -1, 6);
-	if (dev == &root)
-		return;
-	for (dev = dev->parent; dev != &root; dev = dev->parent) {
+	while (dev != &root) {
 		path->bc[i--] = dev->hw_path;
+		dev = dev->parent;
 	}
 }
 
@@ -254,7 +249,8 @@ char *print_pa_hwpath(struct parisc_devi
 {
 	struct hardware_path path;
 
-	get_node_path(dev, &path);
+	get_node_path(dev->parent, &path);
+	path.mod = dev->hw_path;
 	return print_hwpath(&path, output);
 }
 
@@ -433,7 +429,9 @@ int register_parisc_device(struct parisc
 			break;
 	}
 
-	dev->driver = driver;
+	if (driver != NULL) {
+		claim_device(driver, dev);
+	}
 	spin_unlock(&pa_lock);
 	return driver != NULL;
 }
@@ -486,19 +484,16 @@ static void walk_native_bus(unsigned lon
 		unsigned long hpa = (addr + i * NATIVE_DEVICE_OFFSET);
 		struct parisc_device *dev;
 
-		/* Was the device added by Firmware? */
+		/* Was the device already added by Firmware? */
 		dev = find_device_by_addr(hpa);
-		if(dev) {
-			walk_lower_bus(dev);
-			continue;
-		}
+		if (!dev) {
+			path.mod = i;
+			dev = alloc_pa_dev(hpa, &path);
+			if (!dev)
+				continue;
 
-		path.mod = i;
-		dev = alloc_pa_dev(hpa, &path);
-		if (!dev)
-			continue;
-
-		register_parisc_device(dev);
+			register_parisc_device(dev);
+		}
 		walk_lower_bus(dev);
 	}
 }
@@ -520,7 +515,11 @@ void fixup_child_irqs(struct parisc_devi
 			int (*choose_irq)(struct parisc_device *))
 {
 	struct parisc_device *dev;
-	for (dev = next_dev(parent); dev; dev = dev->sibling) {
+
+	if (!parent->child)
+		return;
+
+	for (dev = check_dev(parent->child); dev; dev = dev->sibling) {
 		int irq = choose_irq(dev);
 		if (irq > 0) {
 #ifdef __LP64__
Index: drivers/gsc/dino.c
===================================================================
RCS file: /var/cvs/linux/drivers/gsc/dino.c,v
retrieving revision 1.56
diff -u -p -r1.56 dino.c
--- drivers/gsc/dino.c	2002/02/09 06:42:19	1.56
+++ drivers/gsc/dino.c	2002/02/09 20:31:02
@@ -436,7 +436,7 @@ ilr_again:
 	if (mask) {
 		if (--ilr_loop > 0)
 			goto ilr_again;
-		printk("Dino: stuck interrupt %d\n", mask);
+		printk("Dino %lx: stuck interrupt %d\n", dino_dev->hba.base_addr, mask);
 	}
 }
 
@@ -692,8 +692,8 @@ dino_bridge_init(struct dino_device *din
 	return 0;
 }
 
-static int __init
-dino_common_init(struct parisc_device *dev, struct dino_device *dino_dev)
+static int __init dino_common_init(struct parisc_device *dev,
+		struct dino_device *dino_dev, const char *name)
 {
 	int status;
 	u32 eim;
@@ -722,15 +722,14 @@ dino_common_init(struct parisc_device *d
 	** arch/parisc/kernel/irq.c returns an EIRR bit.
 	*/
 	if (dino_dev->irq < 0) {
-		printk(KERN_WARNING "Dino %lx: gsc_alloc_irq() failed\n", 
-			dino_dev->hba.base_addr);
+		printk(KERN_WARNING "%s: gsc_alloc_irq() failed\n", name);
 		return 1;
 	}
 
-	status = request_irq(dino_dev->irq, dino_isr, 0,"dino", dino_dev);
+	status = request_irq(dino_dev->irq, dino_isr, 0, name, dino_dev);
 	if (status) {
-		printk(KERN_WARNING "Dino %lx: request_irq() failed with %d\n", 
-			dino_dev->hba.base_addr, status);
+		printk(KERN_WARNING "%s: request_irq() failed with %d\n", 
+			name, status);
 		return 1;
 	}
 
@@ -739,11 +738,10 @@ dino_common_init(struct parisc_device *d
 	** be checked in the interrupt handler.
 	*/
 	dino_dev->dino_region = alloc_irq_region(DINO_IRQS, &dino_irq_ops,
-						"dino", dino_dev);
+						name, dino_dev);
 
 	if (NULL == dino_dev->dino_region) {
-		printk(KERN_WARNING "Dino %lx: alloc_irq_region() failed\n", 
-			dino_dev->hba.base_addr);
+		printk(KERN_WARNING "%s: alloc_irq_region() failed\n", name);
 		return 1;
 	}
 
@@ -780,8 +778,8 @@ dino_common_init(struct parisc_device *d
 	res->end = res->start + (HBA_PORT_SPACE_SIZE - 1);
 	res->flags = IORESOURCE_IO; /* do not mark it busy ! */
 	if (request_resource(&ioport_resource, res) < 0) {
-		printk(KERN_ERR "DINO: request I/O Port region failed 0x%lx/%lx (hpa 0x%lx)\n"
-			, res->start, res->end, dino_dev->hba.base_addr);
+		printk(KERN_ERR "%s: request I/O Port region failed 0x%lx/%lx (hpa 0x%lx)\n",
+				name, res->start, res->end, dino_dev->hba.base_addr);
 		return 1;
 	}
 
@@ -889,7 +887,7 @@ dino_driver_callback(struct parisc_devic
 		dino_bridge_init(dino_dev, name);
 	}
 
-	if (dino_common_init(dev, dino_dev))
+	if (dino_common_init(dev, dino_dev, name))
 		return 1;
 
 	/*
Index: drivers/gsc/gsc.c
===================================================================
RCS file: /var/cvs/linux/drivers/gsc/gsc.c,v
retrieving revision 1.30
diff -u -p -r1.30 gsc.c
--- drivers/gsc/gsc.c	2002/01/12 19:01:28	1.30
+++ drivers/gsc/gsc.c	2002/02/09 20:31:02
@@ -171,15 +171,9 @@ int gsc_common_irqsetup(struct parisc_de
 		return -ENOMEM;
 
 	/* allocate resource region */
-	res = kmalloc(sizeof(struct resource), GFP_KERNEL);
+	res = request_mem_region(busdev->hpa, 0x100000, busdev->name);
 	if (res) {
-		res->name = busdev->name;
-		res->start = busdev->hpa;
-		res->end = res->start + 0xfffff;
 		res->flags = IORESOURCE_MEM; 	/* do not mark it busy ! */
-		res->child = NULL;
-		request_resource(&iomem_resource, res);
-		request_mem_region(res->start, OFFSET_IAR + sizeof(int), "reserved");
 	}
 
 #if 0
Index: drivers/gsc/serial.c
===================================================================
RCS file: /var/cvs/linux/drivers/gsc/serial.c,v
retrieving revision 1.23
diff -u -p -r1.23 serial.c
--- drivers/gsc/serial.c	2001/10/29 18:38:21	1.23
+++ drivers/gsc/serial.c	2002/02/09 20:31:02
@@ -40,13 +40,10 @@ serial_init_chip(struct parisc_device *d
 	struct serial_struct *serial;
 
 	if (!dev->irq) {
-#ifndef CONFIG_GSC_WAX
-		if (serial_line_nr == 1) {
-			printk(KERN_INFO "This kernel was compiled without WAX support, but apparently you will need to\n"
-			"enable WAX support in order to use the 2nd serial port (ttyS1) on this machine.\n");
-		} else
-#endif
-			printk(KERN_WARNING "IRQ not found for serial device at 0x%lx\n", dev->hpa);
+		if (dev->parent->id.hw_type != HPHW_IOA) {
+			printk(KERN_INFO "Serial: device 0x%lx not configured.\n"
+				"Enable support for Wax, Lasi, Asp or Dino.\n", dev->hpa);
+		}
 		return -ENODEV;
 	}
 
@@ -87,9 +84,9 @@ static struct parisc_device_id serial_tb
 	{ 0 }
 };
 
-/* Hack.  PDC reports the second serial port first on some machines.
- * So we register this driver which knows about the _first_ serial port
- * only on those machines.  This needs to get fixed properly somehow.
+/* Hack.  Dino's serial port will get listed first on some machines.
+ * So we register this driver first which knows about Lasi's serial port.
+ * This needs to get fixed properly somehow.
  */
 static struct parisc_device_id serial1_tbl[] = {
 	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x03B, 0x0008C }, /* C1xx/C1xxL */
@@ -101,7 +98,6 @@ static struct parisc_device_id serial1_t
 	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x047, 0x0008C }, /* Rocky2 150 */
 	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x04E, 0x0008C }, /* Kiji L2 132 */
 	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x056, 0x0008C }, /* Raven+ */
-	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x05F, 0x0008C }, /* A-class 180 */
 	{ 0 }
 };
 
Index: drivers/parport/parport_gsc.c
===================================================================
RCS file: /var/cvs/linux/drivers/parport/parport_gsc.c,v
retrieving revision 1.21
diff -u -p -r1.21 parport_gsc.c
--- drivers/parport/parport_gsc.c	2001/12/27 20:59:33	1.21
+++ drivers/parport/parport_gsc.c	2002/02/09 20:31:02
@@ -349,9 +349,6 @@ struct parport *__devinit parport_gsc_pr
 	struct parport tmp;
 	struct parport *p = &tmp;
 
-	if (check_mem_region(base, 3)) 
-	    return NULL;
-
 	priv = kmalloc (sizeof (struct parport_gsc_private), GFP_KERNEL);
 	if (!priv) {
 		printk (KERN_DEBUG "parport (0x%lx): no memory!\n", base);
@@ -428,12 +425,6 @@ struct parport *__devinit parport_gsc_pr
 	printk("]\n");
 	parport_proc_register(p);
 
-	request_mem_region (p->base, 3, p->name);
-	if (p->size > 3)
-		request_mem_region (p->base + 3, p->size - 3, p->name);
-	if (p->modes & PARPORT_MODE_ECP)
-		request_mem_region (p->base_hi, 3, p->name);
-
 	if (p->irq != PARPORT_IRQ_NONE) {
 		if (request_irq (p->irq, parport_gsc_interrupt,
 				 0, p->name, p)) {
@@ -502,7 +493,7 @@ static struct parisc_device_id parport_t
 MODULE_DEVICE_TABLE(parisc, parport_tbl);
 
 static struct parisc_driver parport_driver = {
-	name:		"parallel device",
+	name:		"Parallel",
 	id_table:	parport_tbl,
 	probe:		parport_init_chip,
 };
@@ -524,11 +515,6 @@ static void __devexit parport_gsc_exit(v
 				free_dma(p->dma);
 			if (p->irq != PARPORT_IRQ_NONE)
 				free_irq(p->irq, p);
-			release_mem_region(p->base, 3);
-			if (p->size > 3)
-				release_mem_region(p->base + 3, p->size - 3);
-			if (p->modes & PARPORT_MODE_ECP)
-				release_mem_region(p->base_hi, 3);
 			parport_proc_unregister(p);
 			if (priv->dma_buf)
 				pci_free_consistent(priv->dev, PAGE_SIZE,
Index: drivers/scsi/lasi700.c
===================================================================
RCS file: /var/cvs/linux/drivers/scsi/lasi700.c,v
retrieving revision 1.6
diff -u -p -r1.6 lasi700.c
--- drivers/scsi/lasi700.c	2001/12/29 05:35:13	1.6
+++ drivers/scsi/lasi700.c	2002/02/09 20:31:02
@@ -152,12 +152,6 @@ lasi700_driver_callback(struct parisc_de
 		return 1;
 	}
 	memset(hostdata, 0, sizeof(struct NCR_700_Host_Parameters));
-	if(request_mem_region(base, 64, driver_name) == NULL) {
-		printk(KERN_ERR "%s: Failed to claim memory region\n",
-		       driver_name);
-		kfree(hostdata);
-		return 1;
-	}
 	hostdata->base = base;
 	hostdata->differential = 0;
 	if(dev->id.sversion == LASI_700_SVERSION) {
@@ -172,7 +166,6 @@ lasi700_driver_callback(struct parisc_de
 	hostdata->pci_dev = ccio_get_fake(dev);
 	if((host = NCR_700_detect(host_tpnt, hostdata)) == NULL) {
 		kfree(hostdata);
-		release_mem_region(host->base, 64);
 		return 1;
 	}
 	host->irq = dev->irq;
@@ -196,7 +189,6 @@ lasi700_release(struct Scsi_Host *host)
 	NCR_700_release(host);
 	kfree(hostdata);
 	free_irq(host->irq, host);
-	release_mem_region(host->base, 64);
 	unregister_parisc_driver(&lasi700_driver);
 	return 1;
 }
Index: drivers/sound/harmony.c
===================================================================
RCS file: /var/cvs/linux/drivers/sound/harmony.c,v
retrieving revision 1.23
diff -u -p -r1.23 harmony.c
--- drivers/sound/harmony.c	2002/01/15 02:37:01	1.23
+++ drivers/sound/harmony.c	2002/02/09 20:31:02
@@ -1229,8 +1229,6 @@ harmony_driver_callback(struct parisc_de
 	if ((ret=harmony_audio_init())) 
 		goto out_err;
 
-	request_mem_region(dev->hpa, sizeof(struct harmony_hpa), "harmony");
-
 	return 0;
 
 out_err:
@@ -1265,8 +1263,6 @@ static void __exit cleanup_harmony(void)
 	free_irq(harmony.irq, &harmony);
 	unregister_sound_mixer(harmony.mixer_unit);
 	unregister_sound_dsp(harmony.dsp_unit);
-	release_mem_region((unsigned long)harmony.hpa,
-			sizeof(struct harmony_hpa));
 	harmony_free_buffer(&played_buf);
 	harmony_free_buffer(&recorded_buf);
 	harmony_free_buffer(&graveyard);
Index: drivers/net/lasi_82596.c
===================================================================
RCS file: /var/cvs/linux/drivers/net/lasi_82596.c,v
retrieving revision 1.27
diff -u -p -u -r1.27 lasi_82596.c
--- drivers/net/lasi_82596.c	2001/11/09 23:36:03	1.27
+++ drivers/net/lasi_82596.c	2002/02/10 02:54:01
@@ -196,8 +196,6 @@ static int rx_copybreak = 100;
 #define PKT_BUF_SZ	1536
 #define MAX_MC_CNT	64
 
-#define I596_TOTAL_SIZE 17
-
 #define I596_NULL ((void *)0xffffffff)
 
 #define CMD_EOL		0x8000	/* The last command of the list, stop. */
@@ -1025,8 +1023,6 @@ static int i596_open(struct net_device *
 		goto out_remove_rx_bufs;
 	}
 
-	request_mem_region(dev->base_addr, I596_TOTAL_SIZE, "i82596");
-
 	netif_start_queue(dev);
 
 	return 0;
@@ -1418,8 +1414,6 @@ static int i596_close(struct net_device 
 
 	free_irq(dev->irq, dev);
 	remove_rx_bufs(dev);
-
-	release_mem_region(dev->base_addr, I596_TOTAL_SIZE);
 
 	MOD_DEC_USE_COUNT;