[parisc-linux-cvs] linux tsbogend

Thomas Bogendoerfer tsbogend@alpha.franken.de
Tue, 29 Jan 2002 00:30:53 +0100


On Mon, Jan 28, 2002 at 03:58:39PM -0700, Thomas Bogendoerfer wrote:
> CVSROOT:	/var/cvs
> Module name:	linux
> Changes by:	tsbogend	02/01/28 15:58:39
> 
> Modified files:
> 	.              : Makefile 
> 
> Log message:
> 2.4.17-pa16
> reworked *_hwpath; use print_pa_hwpath() and print_pci_hwpath() (willy)
> bugfix for printing of additional device addresses (me)


Index: arch/parisc/kernel/drivers.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/drivers.c,v
retrieving revision 1.37
diff -u -p -r1.37 drivers.c
--- arch/parisc/kernel/drivers.c	2002/01/26 21:17:09	1.37
+++ arch/parisc/kernel/drivers.c	2002/01/28 21:48:16
@@ -17,6 +17,7 @@
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/pci.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
 #include <asm/hardware.h>
@@ -193,10 +194,22 @@ static struct parisc_device *find_device
 	return NULL;
 }
 
+struct parisc_device *find_pa_parent_type(struct parisc_device *dev, int type)
+{
+	do {
+		dev = dev->parent;
+		if (dev->id.hw_type == type)
+			return dev;
+	} while (dev != &root);
+
+	return NULL;
+}
+
 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);
 	while (dev != &root) {
 		path->bc[i--] = dev->hw_path;
@@ -204,23 +217,80 @@ get_node_path(struct parisc_device *dev,
 	}
 }
 
-/* print_hwpath - Returns hardware path for PA devices
+static char *print_hwpath(struct hardware_path *path, char *output)
+{
+	int i;
+	for (i = 0; i < 6; i++) {
+		if (path->bc[i] == -1)
+			continue;
+		output += sprintf(output, "%d/", path->bc[i]);
+	}
+	output += sprintf(output, "%d", path->mod);
+	return output;
+}
+
+/**
+ * print_pa_hwpath - Returns hardware path for PA devices
  * dev: The device to return the path for
  * output: Pointer to a previously-allocated array to place the path in.
+ *
+ * This function fills in the output array with a human-readable path
+ * to a PA device.  This string is compatible with that used by PDC, and
+ * may be printed on the outside of the box.
  */
-char *print_hwpath(struct parisc_device *dev, char *output)
+char *print_pa_hwpath(struct parisc_device *dev, char *output)
 {
-	int i;
 	struct hardware_path path;
 
-	get_node_path(dev->parent, &path);
-	for (i = 0; i < 6; i++) {
-		if (path.bc[i] == -1)
-			continue;
-		output += sprintf(output, "%d/", path.bc[i]);
+	get_node_path(dev, &path);
+	return print_hwpath(&path, output);
+}
+
+/**
+ * get_pci_node_path - Returns hardware path for PCI devices
+ * dev: The device to return the path for
+ * output: Pointer to a previously-allocated array to place the path in.
+ *
+ * This function fills in the hardware_path structure with the route to
+ * the specified PCI device.  This structure is suitable for passing to
+ * PDC calls.
+ */
+void get_pci_node_path(struct pci_dev *dev, struct hardware_path *path)
+{
+	struct pci_bus *bus;
+	const struct parisc_device *padev;
+	int i = 5;
+
+	memset(&path->bc, -1, 6);
+	path->mod = PCI_FUNC(dev->devfn);
+	path->bc[i--] = PCI_SLOT(dev->devfn);
+	for (bus = dev->bus; bus->parent; bus = bus->parent) {
+		unsigned int devfn = bus->self->devfn;
+		path->bc[i--] = PCI_SLOT(devfn) | (PCI_FUNC(devfn) << 5);
 	}
-	output += sprintf(output, "%d", dev->hw_path);
-	return output;
+
+	padev = HBA_DATA(bus->sysdata)->dev;
+	while (padev != &root) {
+		path->bc[i--] = padev->hw_path;
+		padev = padev->parent;
+	}
+}
+
+/**
+ * print_pci_hwpath - Returns hardware path for PCI devices
+ * dev: The device to return the path for
+ * output: Pointer to a previously-allocated array to place the path in.
+ *
+ * This function fills in the output array with a human-readable path
+ * to a PCI device.  This string is compatible with that used by PDC, and
+ * may be printed on the outside of the box.
+ */
+char *print_pci_hwpath(struct pci_dev *dev, char *output)
+{
+	struct hardware_path path;
+
+	get_pci_node_path(dev, &path);
+	return print_hwpath(&path, output);
 }
 
 struct parisc_device * create_tree_node(char id, struct parisc_device *parent,
@@ -300,7 +370,7 @@ alloc_pa_dev(unsigned long hpa, struct h
 	dev = find_parisc_device(mod_path);
 	if (dev->id.hw_type != HPHW_FAULTY) {
 		char p[64];
-		print_hwpath(dev, p);
+		print_pa_hwpath(dev, p);
 		printk("Two devices have hardware path %s.  Please file a bug with HP.\n"
 			"In the meantime, you could try rearranging your cards.\n", p);
 		return NULL;
@@ -450,15 +520,15 @@ static void print_parisc_device(struct p
 	char hw_path[64];
 	static int count;
 
-	print_hwpath(dev, hw_path);
+	print_pa_hwpath(dev, hw_path);
 	printk(KERN_INFO "%d. %s (%d) at 0x%lx [%s], versions 0x%x, 0x%x, 0x%x",
 		++count, dev->name, dev->id.hw_type, dev->hpa, hw_path,
 		dev->id.hversion, dev->id.hversion_rev, dev->id.sversion);
 
-	if (dev->num_addrs > 1) {
+	if (dev->num_addrs) {
 		int k;
 		printk(",  additional addresses: ");
-		for (k = 1; k < dev->num_addrs; k++)
+		for (k = 0; k < dev->num_addrs; k++)
 			printk("0x%lx ", dev->addr[k]);
 	}
 	printk("\n");
Index: arch/parisc/kernel/pci.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/pci.c,v
retrieving revision 1.33
diff -u -p -r1.33 pci.c
--- arch/parisc/kernel/pci.c	2002/01/26 21:18:05	1.33
+++ arch/parisc/kernel/pci.c	2002/01/28 21:48:16
@@ -14,14 +14,11 @@
 #include <linux/kernel.h>
 #include <linux/init.h>		/* for __init and __devinit */
 #include <linux/pci.h>
-#include <linux/spinlock.h>
-#include <linux/string.h>	/* for memcpy() */
 #include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/system.h>
 #include <asm/cache.h>		/* for L1_CACHE_BYTES */
-#include <asm/pdc.h>         /* for is_pdc_pat() macro */
 
 #define DEBUG_RESOURCES 0
 #define DEBUG_CONFIG 0
@@ -509,27 +506,4 @@ void pcibios_register_hba(struct pci_hba
 	/* pci_port->in/out() uses parisc_pci_hba to lookup parameter. */
 	parisc_pci_hba[pci_hba_count] = hba;
 	hba->hba_num = pci_hba_count++;
-}
-
-/* pci_hwpath - Returns hardware path for PCI devices
- *
- */
-void pci_hwpath(struct pci_dev *dev, char *path)
-{
-	int i = 0;
-	unsigned char pci_path[6];
-	struct pci_bus *root;
-
-	pci_path[i++] = PCI_FUNC(dev->devfn);
-	pci_path[i++] = PCI_SLOT(dev->devfn);
-	for (root = dev->bus; root->parent; root = root->parent) {
-		pci_path[i++] = root->number;
-		if (i == 6)
-			break;
-	}
-
-	path = print_hwpath(HBA_DATA(root->sysdata)->dev, path);
-	while (i > 0) {
-		path += sprintf (path, "/%d", pci_path[--i]);
-	}
 }
Index: drivers/video/sti/sticore.c
===================================================================
RCS file: /home/cvs/parisc/linux/drivers/video/sti/sticore.c,v
retrieving revision 1.32
diff -u -p -r1.32 sticore.c
--- drivers/video/sti/sticore.c	2002/01/26 21:19:55	1.32
+++ drivers/video/sti/sticore.c	2002/01/28 21:48:16
@@ -792,7 +792,7 @@ test_rom:
 		i = __raw_readl(address+0x04);
 		if (i != 1) {
 			/* FIXME: The ROM could have multiple architecture 
-			 * dependend images (e.g. iA32, parisc,...) */
+			 * dependent images (e.g. i386, parisc,...) */
 			printk(KERN_WARNING 
 				"%s: PCI ROM is not a STI ROM type image (0x%8x)\n",
 				__FILE__, i);
@@ -896,7 +896,7 @@ static int __init sticore_pa_init(struct
 	if (!sti)
 		return 1;
 	
-	print_hwpath (dev, pa_path);
+	print_pa_hwpath(dev, pa_path);
 	sticore_check_for_default_sti (sti, pa_path);
 	return 0;
 }
@@ -951,7 +951,7 @@ static int __devinit sticore_pci_init(st
 		sti = sti_try_rom_generic(rom_base, fb_base, pd);
 		if (sti) {
 			char pa_path[30];
-			pci_hwpath(pd, pa_path);
+			print_pci_hwpath(pd, pa_path);
 			sticore_check_for_default_sti(sti, pa_path);
 		}
 		break;
Index: include/asm-parisc/hardware.h
===================================================================
RCS file: /home/cvs/parisc/linux/include/asm-parisc/hardware.h,v
retrieving revision 1.32
diff -u -p -r1.32 hardware.h
--- include/asm-parisc/hardware.h	2002/01/26 21:16:06	1.32
+++ include/asm-parisc/hardware.h	2002/01/28 21:48:16
@@ -132,6 +132,7 @@ struct bc_module {
 extern const char *parisc_hardware_description(struct parisc_device_id *id);
 extern enum cpu_type parisc_get_cpu_type(unsigned long hversion);
 
+struct pci_dev;
 
 /* drivers.c: */
 extern struct parisc_device *alloc_pa_dev(unsigned long hpa,
@@ -144,7 +145,8 @@ extern void fixup_child_irqs(struct pari
 		int (*choose)(struct parisc_device *parent));
 extern void print_subdevices(struct parisc_device *dev);
 extern void print_parisc_devices(void);
-extern char *print_hwpath(struct parisc_device *dev, char *path);
+extern char *print_pa_hwpath(struct parisc_device *dev, char *path);
+extern char *print_pci_hwpath(struct pci_dev *dev, char *path);
 
 /* inventory.c: */
 extern void do_memory_inventory(void);
Index: include/asm-parisc/pci.h
===================================================================
RCS file: /home/cvs/parisc/linux/include/asm-parisc/pci.h,v
retrieving revision 1.42
diff -u -p -r1.42 pci.h
--- include/asm-parisc/pci.h	2002/01/26 21:15:27	1.42
+++ include/asm-parisc/pci.h	2002/01/28 21:48:16
@@ -243,8 +243,6 @@ extern inline void pcibios_register_hba(
 /* Return the index of the PCI controller for device PDEV. */
 #define pci_controller_num(PDEV)	(0)
 
-void pci_hwpath(struct pci_dev *dev, char *path);
-
 #define GET_IOC(dev) ((struct ioc *)(HBA_DATA(dev->sysdata)->iommu))
 
 #ifdef CONFIG_IOMMU_CCIO

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                 [ Alexander Viro on linux-kernel ]