[PATCH] PCI device-node failure detection

Jake Moilanen moilanen at austin.ibm.com
Fri Jun 10 00:31:12 EST 2005


> Besides, if you really want to export it, considering that it's
> "standard" enough to be in generic code, then it should be rather called
> something like.
> 
>     int of_device_failed(...)
> 
> And finally, i'd rather have it backward, that is something like
> of_device_available().

I finally got around to fixing this up.

Signed-off-by: Jake Moilanen <moilanen at austin.ibm.com>

Index: 2.6.12-maui/arch/ppc64/kernel/pSeries_pci.c
===================================================================
--- 2.6.12-maui.orig/arch/ppc64/kernel/pSeries_pci.c	2005-06-02 14:47:20.000000000 -0500
+++ 2.6.12-maui/arch/ppc64/kernel/pSeries_pci.c	2005-06-09 13:54:06.000000000 -0500
@@ -62,6 +62,21 @@
 	return 0;
 }
 
+static int of_device_available(struct device_node * dn)
+{
+        char * status;
+
+        status = get_property(dn, "status", NULL);
+
+        if (!status)
+                return 1;
+
+        if (!strcmp(status, "okay"))
+                return 1;
+
+        return 0;
+}
+
 static int rtas_read_config(struct device_node *dn, int where, int size, u32 *val)
 {
 	int returnval = -1;
@@ -107,7 +122,7 @@
 
 	/* Search only direct children of the bus */
 	for (dn = busdn->child; dn; dn = dn->sibling)
-		if (dn->devfn == devfn)
+		if (dn->devfn == devfn && of_device_available(dn))
 			return rtas_read_config(dn, where, size, val);
 	return PCIBIOS_DEVICE_NOT_FOUND;
 }
@@ -150,7 +165,7 @@
 
 	/* Search only direct children of the bus */
 	for (dn = busdn->child; dn; dn = dn->sibling)
-		if (dn->devfn == devfn)
+		if (dn->devfn == devfn && of_device_available(dn))
 			return rtas_write_config(dn, where, size, val);
 	return PCIBIOS_DEVICE_NOT_FOUND;
 }



More information about the Linuxppc64-dev mailing list