From: Yinghai Lu <yinghai.lu@oracle.com>
To: Greg KH <gregkh@suse.de>, Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH -v4 8_1/8] PCI, sys: Use device_type and attr_groups with pci dev
Date: Mon, 17 Oct 2011 11:27:18 -0700 [thread overview]
Message-ID: <4E9C7386.6090607@oracle.com> (raw)
In-Reply-To: <20111017014527.GA7322@suse.de>
We want to create rescan in sys only for pci bridge instead of all pci dev.
We could use attribute_groups/is_visible method to do that.
Now pci dev does not use device type yet. So add pci_dev_type to take
attr_groups with it.
Add pci_dev_bridge_attrs_are_visible() to control attr_bridge_group only create
attr for bridge.
This is the framework related change, later could attr to bridge_attr_group,
to make those attr only show up on pci bridge device.
Also We could add more attr groups with is_visible to reduce messness in
pci_create_sysfs_dev_files. ( at least for boot_vga one )
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/pci-sysfs.c | 30 ++++++++++++++++++++++++++++++
drivers/pci/pci.h | 1 +
drivers/pci/probe.c | 1 +
3 files changed, 32 insertions(+)
Index: linux-2.6/drivers/pci/pci-sysfs.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci-sysfs.c
+++ linux-2.6/drivers/pci/pci-sysfs.c
@@ -1319,3 +1319,33 @@ static int __init pci_sysfs_init(void)
}
late_initcall(pci_sysfs_init);
+
+static struct attribute *pci_dev_bridge_attrs[] = {
+ NULL,
+};
+
+static mode_t pci_dev_bridge_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 (!pdev->subordinate)
+ return 0;
+
+ return a->mode;
+}
+
+static struct attribute_group pci_dev_bridge_attr_group = {
+ .attrs = pci_dev_bridge_attrs,
+ .is_visible = pci_dev_bridge_attrs_are_visible,
+};
+
+static const struct attribute_group *pci_dev_attr_groups[] = {
+ &pci_dev_bridge_attr_group,
+ NULL,
+};
+
+struct device_type pci_dev_type = {
+ .groups = pci_dev_attr_groups,
+};
Index: linux-2.6/drivers/pci/pci.h
===================================================================
--- linux-2.6.orig/drivers/pci/pci.h
+++ linux-2.6/drivers/pci/pci.h
@@ -159,6 +159,7 @@ static inline int pci_no_d1d2(struct pci
}
extern struct device_attribute pci_dev_attrs[];
extern struct device_attribute pcibus_dev_attrs[];
+extern struct device_type pci_dev_type;
#ifdef CONFIG_HOTPLUG
extern struct bus_attribute pci_bus_attrs[];
#else
Index: linux-2.6/drivers/pci/probe.c
===================================================================
--- linux-2.6.orig/drivers/pci/probe.c
+++ linux-2.6/drivers/pci/probe.c
@@ -902,6 +902,7 @@ int pci_setup_device(struct pci_dev *dev
dev->sysdata = dev->bus->sysdata;
dev->dev.parent = dev->bus->bridge;
dev->dev.bus = &pci_bus_type;
+ dev->dev.type = &pci_dev_type;
dev->hdr_type = hdr_type & 0x7f;
dev->multifunction = !!(hdr_type & 0x80);
dev->error_state = pci_channel_io_normal;
next prev parent reply other threads:[~2011-10-17 18:28 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4E9A3092.4080309@oracle.com>
2011-10-16 1:31 ` [PATCH 1/8] pci: Make sriov work with hotplug removal Yinghai Lu
2011-10-17 17:16 ` Bjorn Helgaas
2011-10-17 18:08 ` Yinghai Lu
2011-10-17 22:12 ` Bjorn Helgaas
2011-10-17 22:24 ` Yinghai Lu
2011-10-18 16:49 ` Bjorn Helgaas
2011-10-18 17:02 ` Yinghai Lu
2011-10-25 12:34 ` Kenji Kaneshige
2011-10-25 15:52 ` Yinghai Lu
2011-11-11 21:00 ` [RESEND PATCH] PCI: Make sriov work with hotplug remove Yinghai Lu
2011-11-16 5:54 ` Kenji Kaneshige
2011-11-16 21:23 ` Yinghai Lu
2011-11-23 1:58 ` Kenji Kaneshige
2011-11-23 5:01 ` [PATCH -v4] " Yinghai Lu
2011-10-16 1:31 ` [PATCH 2/8] pci: Calculate right add_size Yinghai Lu
2011-10-16 1:32 ` [PATCH 3/8] pci: Try to assign required+option size at first Yinghai Lu
2011-10-16 1:32 ` [PATCH 4/8] PCI: Using add_list in pcie hotplug path Yinghai Lu
2011-10-16 1:32 ` [PATCH 5/8] PCI: Make rescan bus could increase bridge resource size if needed Yinghai Lu
2011-10-16 1:32 ` [PATCH 6/8] PCI: Make pci_rescan_bus handle add_list Yinghai Lu
2011-10-16 1:32 ` [PATCH 7/8] PCI, sysfs: merge dev and bus cpuaffinity show handling Yinghai Lu
2011-10-16 1:32 ` [PATCH 8/8] PCI, sys: only create rescan under /sys/.../pci/devices/... for pci bridges Yinghai Lu
2011-10-16 2:39 ` Greg KH
2011-10-16 5:34 ` Yinghai Lu
2011-10-16 15:55 ` Greg KH
2011-10-16 23:35 ` Yinghai Lu
2011-10-17 1:45 ` Greg KH
2011-10-17 18:27 ` Yinghai Lu [this message]
2011-10-17 18:38 ` [PATCH -v4 8_1/8] PCI, sys: Use device_type and attr_groups with pci dev Greg KH
2011-10-17 18:29 ` [PATCH -v4 8_2/8] PCI, sys: only create rescan under /sys/.../pci/devices/... for pci bridges Yinghai Lu
2011-10-17 18:33 ` [PATCH -v4 8_3/8] PCI, sys: Use is_visable() with boot_vga attribute for pci_dev Yinghai Lu
2011-10-17 18:36 ` [PATCH 8/8] PCI, sys: only create rescan under /sys/.../pci/devices/... for pci bridges Yinghai Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E9C7386.6090607@oracle.com \
--to=yinghai.lu@oracle.com \
--cc=gregkh@suse.de \
--cc=jbarnes@virtuousgeek.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).