>From 4435354e0d99e409d0140256d8162c0046139843 Mon Sep 17 00:00:00 2001 From: Dirk Gouders Date: Fri, 12 Sep 2014 21:25:18 +0200 Subject: [PATCH 3/4] PCI, sysfs: Add pcie attrs for pcie device under pci dev dir. Will put link_disable and link_retrain Signed-off-by: Yinghai Lu --- drivers/pci/Makefile | 2 +- drivers/pci/pci-sysfs.c | 1 + drivers/pci/pci.h | 1 + drivers/pci/pcie-sysfs.c | 23 +++++++++++++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 drivers/pci/pcie-sysfs.c diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index eab9feb..43523dd 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -4,7 +4,7 @@ obj-y += access.o bus.o probe.o host-bridge.o remove.o pci.o \ pci-driver.o search.o pci-sysfs.o rom.o setup-res.o \ - irq.o vpd.o setup-bus.o pcie-link.o vc.o + irq.o vpd.o setup-bus.o pcie-link.o pcie-sysfs.o vc.o obj-$(CONFIG_PROC_FS) += proc.o obj-$(CONFIG_SYSFS) += slot.o diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 9ff0a90..6f20e5d 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -1566,6 +1566,7 @@ static struct attribute_group pci_dev_attr_group = { static const struct attribute_group *pci_dev_attr_groups[] = { &pci_dev_attr_group, + &pci_dev_pcie_attr_group, &pci_dev_hp_attr_group, #ifdef CONFIG_PCI_IOV &sriov_dev_attr_group, diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 0601890..cc2977c 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -152,6 +152,7 @@ static inline int pci_no_d1d2(struct pci_dev *dev) extern const struct attribute_group *pci_dev_groups[]; extern const struct attribute_group *pcibus_groups[]; extern struct device_type pci_dev_type; +extern struct attribute_group pci_dev_pcie_attr_group; extern const struct attribute_group *pci_bus_groups[]; diff --git a/drivers/pci/pcie-sysfs.c b/drivers/pci/pcie-sysfs.c new file mode 100644 index 0000000..b65e065 --- /dev/null +++ b/drivers/pci/pcie-sysfs.c @@ -0,0 +1,23 @@ +#include +#include + +static struct attribute *pci_dev_pcie_dev_attrs[] = { + NULL, +}; + +static umode_t pci_dev_pcie_attrs_are_visible(struct kobject *kobj, + struct attribute *a, int n) +{ + struct device *dev = container_of(kobj, struct device, kobj); + struct pci_dev *pdev = to_pci_dev(dev); + + if (!pci_is_pcie(pdev)) + return 0; + + return a->mode; +} + +struct attribute_group pci_dev_pcie_attr_group = { + .is_visible = pci_dev_pcie_attrs_are_visible, + .attrs = pci_dev_pcie_dev_attrs, +}; -- 2.1.0