Messages in this thread Patch in this message | | | Subject | [PATCH] PCI / OF linkage in sysfs | From | Benjamin Herrenschmidt <> | Date | Wed, 04 Feb 2004 18:12:08 +1100 |
| |
Hi !
This patch adds a "devspec" property to all PCI entries in sysfs that provides the full "Open Firmware" path to each device on PPC and PPC64 platforms that have Open Firmware support.
For various reasons, the OF path is and will still be different than the sysfs path, and userland needs the OF path for various things, ranging from bootloader setup to XFree needing to access some OF properties provided by the graphic card F-Code driver, etc...
The "devspec" name is what we already use for "macio" type devices, it doesn't clash with anything else.
If you are happy with it, please apply (independently of the rest of the PowerMac patch), I need that to fix various things in XFree (among others), so it would be nice to have it in by 2.6.3 final
Regards, Ben.
diff -urN linux-2.5/drivers/pci/pci-sysfs.c linuxppc-2.5-benh/drivers/pci/pci-sysfs.c --- linux-2.5/drivers/pci/pci-sysfs.c 2004-02-02 13:09:08.000000000 +1100 +++ linuxppc-2.5-benh/drivers/pci/pci-sysfs.c 2004-02-04 17:57:05.000000000 +1100 @@ -20,6 +20,24 @@ #include "pci.h" +#ifdef CONFIG_PPC_OF +#include <asm/prom.h> +#include <asm/pci-bridge.h> + +static ssize_t pci_show_devspec(struct device *dev, char *buf) +{ + struct pci_dev *pdev; + struct device_node *np; + + pdev = to_pci_dev (dev); + np = pci_device_to_OF_node(pdev); + if (np == NULL || np->full_name == NULL) + return 0; + return sprintf(buf, "%s", np->full_name); +} +static DEVICE_ATTR(devspec, S_IRUGO, pci_show_devspec, NULL); +#endif /* CONFIG_PPC_OF */ + /* show configuration fields */ #define pci_config_attr(field, format_string) \ static ssize_t \ @@ -179,5 +197,8 @@ device_create_file (dev, &dev_attr_class); device_create_file (dev, &dev_attr_irq); device_create_file (dev, &dev_attr_resource); +#ifdef CONFIG_PPC_OF + device_create_file (dev, &dev_attr_devspec); +#endif sysfs_create_bin_file(&dev->kobj, &pci_config_attr); }
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |