Export OF device path for PCI devices take 2
PATCH 1/1 Export OF device path for PCI devices take 2
Hi !
Here's a new version of the patch according to our discussion.
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.
Please apply unless something is wrong :)
drivers/pci/pci-sysfs.c +3 -0
@@ -180,4 +180,7 @@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); }
include/asm-alpha/pci.h +4 -0
@@ -208,6 +208,10 @@ return 0; } +static inline void pcibios_add_platform_entries (struct pci_dev *dev) +{ +} +#endif /* __KERNEL__ */ /* Values for the `which' argument to sys_pciconfig_iobase. */
include/asm-arm/pci.h +4 -0
@@ -186,6 +186,10 @@ 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
include/asm-h8300/pci.h +4 -0
@@ -22,4 +22,8 @@#define PCI_DMA_BUS_IS_PHYS (1) +static inline void pcibios_add_platform_entries (struct pci_dev *dev) +{ +} +#endif /* _ASM_H8300_PCI_H */
include/asm-i386/pci.h +5 -0
@@ -89,6 +89,11 @@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 */
include/asm-ia64/pci.h +4 -0
@@ -112,6 +112,10 @@return 0 ; } +static inline void pcibios_add_platform_entries (struct pci_dev *dev) +{ +} +/* generic pci stuff */ #include <asm-generic/pci.h>
include/asm-m68k/pci.h +4 -0
@@ -54,4 +54,8 @@*/ #define PCI_DMA_BUS_IS_PHYS (1) +static inline void pcibios_add_platform_entries (struct pci_dev *dev) +{ +} +#endif /* _ASM_M68K_PCI_H */
include/asm-m68knommu/pci.h +4 -0
@@ -30,6 +30,10 @@*/ #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 */
include/asm-mips/pci.h +4 -0
@@ -120,6 +120,10 @@ 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 */
include/asm-parisc/pci.h +4 -0
@@ -196,4 +196,8 @@ 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 */
include/asm-ppc/pci.h +2 -0
@@ -282,6 +282,8 @@ 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 */
include/asm-ppc64/pci.h +2 -0
@@ -152,6 +152,8 @@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 */
include/asm-sh/pci.h +4 -0
@@ -256,6 +256,10 @@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 */
include/asm-sparc/pci.h +4 -0
@@ -141,6 +141,10 @@#define pci_dac_dma_supported (dev, mask) (0) +static inline void pcibios_add_platform_entries (struct pci_dev *dev) +{ +} +#endif /* __KERNEL__ */ /* generic pci stuff */
include/asm-sparc64/pci.h +4 -0
@@ -215,6 +215,10 @@ 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 */
include/asm-v850/pci.h +4 -0
@@ -76,4 +76,8 @@ 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__ */
include/asm-x86_64/pci.h +4 -0
@@ -263,6 +263,10 @@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 */
arch/ppc/kernel/pci.c +23 -0
@@ -1022,8 +1022,31 @@ 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
arch/ppc64/kernel/pci.c +22 -0
@@ -540,3 +540,25 @@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 *dev) +{ +#ifdef CONFIG_PPC_PSERIES +device_create_file (&pdev->dev, &dev_attr_devspec); +#endif /* CONFIG_PPC_PSERIES */ +}
Quoted 3 lines · Benjamin Herrenschmidt
Hi !
Here's a new version of the patch according to our discussion.
Argh.. flu is no good with me... Here's one without a typo preventing build on ppc ;)
drivers/pci/pci-sysfs.c +3 -0
@@ -180,4 +180,7 @@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); }
include/asm-alpha/pci.h +4 -0
@@ -208,6 +208,10 @@ return 0; } +static inline void pcibios_add_platform_entries (struct pci_dev *dev) +{ +} +#endif /* __KERNEL__ */ /* Values for the `which' argument to sys_pciconfig_iobase. */
include/asm-arm/pci.h +4 -0
@@ -186,6 +186,10 @@ 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
include/asm-h8300/pci.h +4 -0
@@ -22,4 +22,8 @@#define PCI_DMA_BUS_IS_PHYS (1) +static inline void pcibios_add_platform_entries (struct pci_dev *dev) +{ +} +#endif /* _ASM_H8300_PCI_H */
include/asm-i386/pci.h +5 -0
@@ -89,6 +89,11 @@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 */
include/asm-ia64/pci.h +4 -0
@@ -112,6 +112,10 @@return 0 ; } +static inline void pcibios_add_platform_entries (struct pci_dev *dev) +{ +} +/* generic pci stuff */ #include <asm-generic/pci.h>
include/asm-m68k/pci.h +4 -0
@@ -54,4 +54,8 @@*/ #define PCI_DMA_BUS_IS_PHYS (1) +static inline void pcibios_add_platform_entries (struct pci_dev *dev) +{ +} +#endif /* _ASM_M68K_PCI_H */
include/asm-m68knommu/pci.h +4 -0
@@ -30,6 +30,10 @@*/ #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 */
include/asm-mips/pci.h +4 -0
@@ -120,6 +120,10 @@ 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 */
include/asm-parisc/pci.h +4 -0
@@ -196,4 +196,8 @@ 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 */
include/asm-ppc/pci.h +2 -0
@@ -282,6 +282,8 @@ 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 */
include/asm-ppc64/pci.h +2 -0
@@ -152,6 +152,8 @@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 */
include/asm-sh/pci.h +4 -0
@@ -256,6 +256,10 @@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 */
include/asm-sparc/pci.h +4 -0
@@ -141,6 +141,10 @@#define pci_dac_dma_supported (dev, mask) (0) +static inline void pcibios_add_platform_entries (struct pci_dev *dev) +{ +} +#endif /* __KERNEL__ */ /* generic pci stuff */
include/asm-sparc64/pci.h +4 -0
@@ -215,6 +215,10 @@ 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 */
include/asm-v850/pci.h +4 -0
@@ -76,4 +76,8 @@ 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__ */
include/asm-x86_64/pci.h +4 -0
@@ -263,6 +263,10 @@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 */
arch/ppc/kernel/pci.c +23 -0
@@ -1022,8 +1022,31 @@ 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
arch/ppc64/kernel/pci.c +22 -0
@@ -540,3 +540,25 @@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 */ +}