[SPARC64]: Add obppath sysfs attribute for SBUS and PCI devices.

Signed-off-by: Fabio Massimo Di Nitto <fabbione@ubuntu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/arch/sparc64/kernel/pci_common.c b/arch/sparc64/kernel/pci_common.c
index 827ae30..5a92cb9 100644
--- a/arch/sparc64/kernel/pci_common.c
+++ b/arch/sparc64/kernel/pci_common.c
@@ -7,6 +7,8 @@
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/device.h>
 
 #include <asm/pbm.h>
 #include <asm/prom.h>
@@ -129,6 +131,20 @@
 	}
 }
 
+static ssize_t
+show_pciobppath_attr(struct device * dev, struct device_attribute * attr, char * buf)
+{
+	struct pci_dev *pdev;
+	struct pcidev_cookie *sysdata;
+
+	pdev = to_pci_dev(dev);
+	sysdata = pdev->sysdata;
+
+	return snprintf (buf, PAGE_SIZE, "%s\n", sysdata->prom_node->full_name);
+}
+
+static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH, show_pciobppath_attr, NULL);
+
 /* Fill in the PCI device cookie sysdata for the given
  * PCI device.  This cookie is the means by which one
  * can get to OBP and PCI controller specific information
@@ -142,7 +158,7 @@
 	struct pcidev_cookie *pcp;
 	struct device_node *dp;
 	struct property *prop;
-	int nregs, len;
+	int nregs, len, err;
 
 	dp = find_device_prom_node(pbm, pdev, bus_node,
 				   &pregs, &nregs);
@@ -215,6 +231,13 @@
 	fixup_obp_assignments(pdev, pcp);
 
 	pdev->sysdata = pcp;
+
+	/* we don't really care if we can create this file or not,
+	 * but we need to assign the result of the call or the world will fall
+	 * under alien invasion and everybody will be frozen on a spaceship
+	 * ready to be eaten on alpha centauri by some green and jelly humanoid.
+	 */
+	err = sysfs_create_file(&pdev->dev.kobj, &dev_attr_obppath.attr);
 }
 
 void __init pci_fill_in_pbm_cookies(struct pci_bus *pbus,