Commit cf69eab231bb748b5c34912412a8fc8c763bcf57

Authored by Fabio Massimo Di Nitto
Committed by David S. Miller
1 parent d18d7682c1

[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>

Showing 2 changed files with 41 additions and 2 deletions Side-by-side Diff

arch/sparc64/kernel/pci_common.c
... ... @@ -7,6 +7,8 @@
7 7 #include <linux/string.h>
8 8 #include <linux/slab.h>
9 9 #include <linux/init.h>
  10 +#include <linux/pci.h>
  11 +#include <linux/device.h>
10 12  
11 13 #include <asm/pbm.h>
12 14 #include <asm/prom.h>
... ... @@ -129,6 +131,20 @@
129 131 }
130 132 }
131 133  
  134 +static ssize_t
  135 +show_pciobppath_attr(struct device * dev, struct device_attribute * attr, char * buf)
  136 +{
  137 + struct pci_dev *pdev;
  138 + struct pcidev_cookie *sysdata;
  139 +
  140 + pdev = to_pci_dev(dev);
  141 + sysdata = pdev->sysdata;
  142 +
  143 + return snprintf (buf, PAGE_SIZE, "%s\n", sysdata->prom_node->full_name);
  144 +}
  145 +
  146 +static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH, show_pciobppath_attr, NULL);
  147 +
132 148 /* Fill in the PCI device cookie sysdata for the given
133 149 * PCI device. This cookie is the means by which one
134 150 * can get to OBP and PCI controller specific information
... ... @@ -142,7 +158,7 @@
142 158 struct pcidev_cookie *pcp;
143 159 struct device_node *dp;
144 160 struct property *prop;
145   - int nregs, len;
  161 + int nregs, len, err;
146 162  
147 163 dp = find_device_prom_node(pbm, pdev, bus_node,
148 164 &pregs, &nregs);
... ... @@ -215,6 +231,13 @@
215 231 fixup_obp_assignments(pdev, pcp);
216 232  
217 233 pdev->sysdata = pcp;
  234 +
  235 + /* we don't really care if we can create this file or not,
  236 + * but we need to assign the result of the call or the world will fall
  237 + * under alien invasion and everybody will be frozen on a spaceship
  238 + * ready to be eaten on alpha centauri by some green and jelly humanoid.
  239 + */
  240 + err = sysfs_create_file(&pdev->dev.kobj, &dev_attr_obppath.attr);
218 241 }
219 242  
220 243 void __init pci_fill_in_pbm_cookies(struct pci_bus *pbus,
... ... @@ -7,6 +7,7 @@
7 7 #include <linux/slab.h>
8 8 #include <linux/init.h>
9 9 #include <linux/pci.h>
  10 +#include <linux/device.h>
10 11  
11 12 #include <asm/system.h>
12 13 #include <asm/sbus.h>
13 14  
... ... @@ -17,13 +18,25 @@
17 18 #include <asm/bpp.h>
18 19 #include <asm/irq.h>
19 20  
  21 +static ssize_t
  22 +show_sbusobppath_attr(struct device * dev, struct device_attribute * attr, char * buf)
  23 +{
  24 + struct sbus_dev *sbus;
  25 +
  26 + sbus = to_sbus_device(dev);
  27 +
  28 + return snprintf (buf, PAGE_SIZE, "%s\n", sbus->ofdev.node->full_name);
  29 +}
  30 +
  31 +static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH, show_sbusobppath_attr, NULL);
  32 +
20 33 struct sbus_bus *sbus_root;
21 34  
22 35 static void __init fill_sbus_device(struct device_node *dp, struct sbus_dev *sdev)
23 36 {
24 37 unsigned long base;
25 38 void *pval;
26   - int len;
  39 + int len, err;
27 40  
28 41 sdev->prom_node = dp->node;
29 42 strcpy(sdev->prom_name, dp->name);
... ... @@ -66,6 +79,9 @@
66 79 if (of_device_register(&sdev->ofdev) != 0)
67 80 printk(KERN_DEBUG "sbus: device registration error for %s!\n",
68 81 dp->path_component_name);
  82 +
  83 + /* WE HAVE BEEN INVADED BY ALIENS! */
  84 + err = sysfs_create_file(&sdev->ofdev.dev.kobj, &dev_attr_obppath.attr);
69 85 }
70 86  
71 87 static void __init sbus_bus_ranges_init(struct device_node *dp, struct sbus_bus *sbus)