]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Export OF device path for PCI devices
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tue, 10 Feb 2004 00:11:44 +0000 (16:11 -0800)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tue, 10 Feb 2004 00:11:44 +0000 (16:11 -0800)
Here's a new version of the patch according to our discussion.

This allows the platform to add its own platform files to the
sysfs PCI device node through a "pcibios_add_platform_entries()"
call.

I added an empty pcibios_add_platform_entries() inline to all
archs that apparently have PCI and implemented the OF stuff for
ppc and ppc64. The name is still "devspec" for now, I doubt
it will conflict and that's consistent with our use of the
"devspec" name in other places.

19 files changed:
arch/ppc/kernel/pci.c
arch/ppc64/kernel/pci.c
drivers/pci/pci-sysfs.c
include/asm-alpha/pci.h
include/asm-arm/pci.h
include/asm-h8300/pci.h
include/asm-i386/pci.h
include/asm-ia64/pci.h
include/asm-m68k/pci.h
include/asm-m68knommu/pci.h
include/asm-mips/pci.h
include/asm-parisc/pci.h
include/asm-ppc/pci.h
include/asm-ppc64/pci.h
include/asm-sh/pci.h
include/asm-sparc/pci.h
include/asm-sparc64/pci.h
include/asm-v850/pci.h
include/asm-x86_64/pci.h

index bb1a29201330646793dbebd250a52c9c71135f4f..3c57648569d8ffcc2f40011d979a2e70f653c942 100644 (file)
@@ -1022,8 +1022,31 @@ pci_create_OF_bus_map(void)
                prom_add_property(find_path_device("/"), of_prop);
        }
 }
+
+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 */
 
+/* Add sysfs properties */
+void pcibios_add_platform_entries(struct pci_dev *dev)
+{
+#ifdef CONFIG_PPC_OF
+       device_create_file(&pdev->dev, &dev_attr_devspec);
+#endif /* CONFIG_PPC_OF */
+}
+
+
 #ifdef CONFIG_PPC_PMAC
 /*
  * This set of routines checks for PCI<->PCI bridges that have closed
index 2dc7b69b84265393aa293d5b80fef0232ec7ef4e..f37fc0aa3f2f0759fca3ef049e2563f3f29b3995 100644 (file)
@@ -540,3 +540,25 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
 
        return ret;
 }
+
+#ifdef CONFIG_PPC_PSERIES
+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_PSERIES */
+
+void pcibios_add_platform_entries(struct pci_dev *pdev)
+{
+#ifdef CONFIG_PPC_PSERIES
+       device_create_file(&pdev->dev, &dev_attr_devspec);
+#endif /* CONFIG_PPC_PSERIES */
+}
index fd94569cd9104e0811352c96c6b744e7d8f1f145..bffe34b22a6af1b24b1459d23f5f7d374a5510f4 100644 (file)
@@ -180,4 +180,7 @@ void pci_create_sysfs_dev_files (struct pci_dev *pdev)
        device_create_file (dev, &dev_attr_irq);
        device_create_file (dev, &dev_attr_resource);
        sysfs_create_bin_file(&dev->kobj, &pci_config_attr);
+
+       /* add platform-specific attributes */
+       pcibios_add_platform_entries(pdev);
 }
index faeee03035188dfef8992f0b301c1f7b883e5daf..8eba57310ad248826f58a258b93097db9a7c46d0 100644 (file)
@@ -208,6 +208,10 @@ static inline int pci_name_bus(char *name, struct pci_bus *bus)
        return 0;
 }
 
+static inline void pcibios_add_platform_entries(struct pci_dev *dev)
+{
+}
+
 #endif /* __KERNEL__ */
 
 /* Values for the `which' argument to sys_pciconfig_iobase.  */
index 5280c8fa574dc4f2e12554eaa101a78e0fb6be64..6456092a5ab8df4dd363a9f11f2607bc32b4a099 100644 (file)
@@ -186,6 +186,10 @@ extern void
 pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
                         struct resource *res);
 
+static inline void pcibios_add_platform_entries(struct pci_dev *dev)
+{
+}
+
 #endif /* __KERNEL__ */
  
 #endif
index f4813f0a9021dd4ab8bf27989e1ec8f7dfbfaa66..d032729b19df40aa62717dbb99146ee0e0b37ff6 100644 (file)
@@ -22,4 +22,8 @@ extern inline void pcibios_penalize_isa_irq(int irq)
 
 #define PCI_DMA_BUS_IS_PHYS    (1)
 
+static inline void pcibios_add_platform_entries(struct pci_dev *dev)
+{
+}
+
 #endif /* _ASM_H8300_PCI_H */
index 83aede6ce59525aeb953e8a145cbe092054a505d..909a2c152862588f24e0a84feb13f3a322fcb991 100644 (file)
@@ -89,6 +89,11 @@ pci_dac_dma_sync_single(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len,
 extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
                               enum pci_mmap_state mmap_state, int write_combine);
 
+
+static inline void pcibios_add_platform_entries(struct pci_dev *dev)
+{
+}
+
 #endif /* __KERNEL__ */
 
 /* implement the pci_ DMA API in terms of the generic device dma_ one */
index 42f66dda432bbc528ad8a1a61b12e5b683c5f856..cbf5c0d9529cd4f97fff3ea81fe4c8107fe71d26 100644 (file)
@@ -112,6 +112,10 @@ static inline int pci_name_bus(char *name, struct pci_bus *bus)
        return 0;
 }
 
+static inline void pcibios_add_platform_entries(struct pci_dev *dev)
+{
+}
+
 /* generic pci stuff */
 #include <asm-generic/pci.h>
 
index 57e1487bac3f3cd7086713d6dca033fda756b1f0..9e7d79ab5d13cb74f6bd8e865cf76dfc625fc55d 100644 (file)
@@ -54,4 +54,8 @@ static inline void pcibios_penalize_isa_irq(int irq)
  */
 #define PCI_DMA_BUS_IS_PHYS    (1)
 
+static inline void pcibios_add_platform_entries(struct pci_dev *dev)
+{
+}
+
 #endif /* _ASM_M68K_PCI_H */
index a99ce768f4a68cf003563e00d3b3d54c77bee0ff..e04c77e1184da3bb8dcce624e70db0fc4281fed8 100644 (file)
@@ -30,6 +30,10 @@ static inline int pci_dma_supported(struct pci_dev *hwdev, u64 mask)
  */
 #define pci_dac_dma_supported(pci_dev, mask) (0)
 
+static inline void pcibios_add_platform_entries(struct pci_dev *dev)
+{
+}
+
 #endif /* CONFIG_COMEMPCI */
 
 #endif /* M68KNOMMU_PCI_H */
index 3943c111647ea0f930136cc806f10c7eba80e2c2..75a2b5536bb0325c91e80bf63016815de043b77d 100644 (file)
@@ -120,6 +120,10 @@ static inline void pci_dac_dma_sync_single(struct pci_dev *pdev,
        dma_cache_wback_inv(addr, len);
 }
 
+static inline void pcibios_add_platform_entries(struct pci_dev *dev)
+{
+}
+
 #endif /* __KERNEL__ */
 
 /* implement the pci_ DMA API in terms of the generic device dma_ one */
index d5dca01282f09392d48112db4f74093e6bf858c0..6d803a9e8967f2bb565cf52f520acbbf3e7e1fed 100644 (file)
@@ -196,4 +196,8 @@ extern void
 pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
                         struct resource *res);
 
+static inline void pcibios_add_platform_entries(struct pci_dev *dev)
+{
+}
+
 #endif /* __ASM_PARISC_PCI_H */
index 16d61750824266481182d14279c0fe22d11052e4..0228e6e40e05c7403f5df6cd949d2ecdcdb97bb3 100644 (file)
@@ -282,6 +282,8 @@ extern void
 pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
                        struct resource *res);
 
+extern void pcibios_add_platform_entries(struct pci_dev *dev);
+
 #endif /* __KERNEL__ */
 
 #endif /* __PPC_PCI_H */
index 60d3832dd93445744173b85e2075b5975d97e663..835b882fb18dc45de74e2d58ac92cfbec19fa45c 100644 (file)
@@ -152,6 +152,8 @@ pcibios_fixup_device_resources(struct pci_dev *dev, struct pci_bus *bus);
 
 extern int pci_read_irq_line(struct pci_dev *dev);
 
+extern void pcibios_add_platform_entries(struct pci_dev *dev);
+
 #endif /* __KERNEL__ */
 
 #endif /* __PPC64_PCI_H */
index fe2c08b2e7cdf7f415a92474e446ec153c5c35b2..b16a62e61771d5c8a8703fc5a4bebcfc4ad43e7d 100644 (file)
@@ -256,6 +256,10 @@ extern void pcibios_fixup_irqs(void);
 extern int pciauto_assign_resources(int busno, struct pci_channel *hose);
 #endif
 
+static inline void pcibios_add_platform_entries(struct pci_dev *dev)
+{
+}
+
 #endif /* __KERNEL__ */
 
 /* generic pci stuff */
index e97afc5a44db5a247b2aef0dbd56847187aca9a4..e78d2cbf042683ffa28f2df3cc99fc01f2f40bba 100644 (file)
@@ -141,6 +141,10 @@ extern inline int pci_dma_supported(struct pci_dev *hwdev, u64 mask)
 
 #define pci_dac_dma_supported(dev, mask)       (0)
 
+static inline void pcibios_add_platform_entries(struct pci_dev *dev)
+{
+}
+
 #endif /* __KERNEL__ */
 
 /* generic pci stuff */
index ea722dcb49d83b080f9793160ad8851e416ac301..e64c30c45b107561c74d9b52bd2a252ac8e2a879 100644 (file)
@@ -215,6 +215,10 @@ extern void
 pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
                        struct pci_bus_region *region);
 
+static inline void pcibios_add_platform_entries(struct pci_dev *dev)
+{
+}
+
 #endif /* __KERNEL__ */
 
 #endif /* __SPARC64_PCI_H */
index 81addb7df017e0ad007c9d9dd1cd6b7d2cbf9f03..e3a33920e69321b4f03923be6a2348bd88de011f 100644 (file)
@@ -76,4 +76,8 @@ extern void
 pci_free_consistent (struct pci_dev *pdev, size_t size, void *cpu_addr,
                     dma_addr_t dma_addr);
 
+static inline void pcibios_add_platform_entries(struct pci_dev *dev)
+{
+}
+
 #endif /* __V850_PCI_H__ */
index 6feb36107d64fd117429c13e1a935c85f47e0c2d..1ba95e06f32f2ab4bc0a56f111282300a68623de 100644 (file)
@@ -263,6 +263,10 @@ pci_dac_dma_sync_single(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len,
 extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
                               enum pci_mmap_state mmap_state, int write_combine);
 
+static inline void pcibios_add_platform_entries(struct pci_dev *dev)
+{
+}
+
 #endif /* __KERNEL__ */
 
 /* generic pci stuff */