PCI: Add pci_device_type to pdev's device struct
authorYinghai Lu <yinghai@kernel.org>
Mon, 5 Nov 2012 20:20:34 +0000 (15:20 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Sat, 10 Nov 2012 03:07:31 +0000 (20:07 -0700)
Need type filled in device structure so it can be used for visible
attribute control in sysfs for pci_dev.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pci-sysfs.c
drivers/pci/pci.h
drivers/pci/probe.c

index 02d107b152818e948cc3e561d276bf24126ac997..3d160aa608c178d08add06416e6462b5f5aafec0 100644 (file)
@@ -1411,3 +1411,27 @@ static int __init pci_sysfs_init(void)
 }
 
 late_initcall(pci_sysfs_init);
+
+static struct attribute *pci_dev_dev_attrs[] = {
+       NULL,
+};
+
+static umode_t pci_dev_attrs_are_visible(struct kobject *kobj,
+                                               struct attribute *a, int n)
+{
+       return a->mode;
+}
+
+static struct attribute_group pci_dev_attr_group = {
+       .attrs = pci_dev_dev_attrs,
+       .is_visible = pci_dev_attrs_are_visible,
+};
+
+static const struct attribute_group *pci_dev_attr_groups[] = {
+       &pci_dev_attr_group,
+       NULL,
+};
+
+struct device_type pci_dev_type = {
+       .groups = pci_dev_attr_groups,
+};
index bacbcba69cf386dd2971b8b94e6ddd383888b471..6f6cd145bb7e0c1d3f9eed6f2538beed11aa9e26 100644 (file)
@@ -157,6 +157,7 @@ static inline int pci_no_d1d2(struct pci_dev *dev)
 }
 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 ec909afa90b6a67b8f27b8336d2987e0687a914d..0312f1c48b3cc89d933ff36e7136cd9dc9f47942 100644 (file)
@@ -975,6 +975,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;