@@ -367,6 +367,9 @@ remove_store(struct device *dev, struct device_attribute *dummy,
return schedule_hp_callback(dev, buf, count, remove_callback);
}
+static struct device_attribute pci_dev_remove_attr =
+ __ATTR(remove, (S_IWUSR|S_IWGRP), NULL, remove_store);
+
static void dev_bus_rescan_callback(struct device *dev)
{
struct pci_bus *bus = to_pci_bus(dev);
@@ -389,6 +392,8 @@ dev_bus_rescan_store(struct device *dev, struct device_attribute *attr,
return schedule_hp_callback(dev, buf, count, dev_bus_rescan_callback);
}
+static struct device_attribute pci_dev_rescan_attr =
+ __ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_rescan_store);
#endif
struct device_attribute pci_dev_attrs[] = {
@@ -411,10 +416,6 @@ struct device_attribute pci_dev_attrs[] = {
__ATTR(broken_parity_status,(S_IRUGO|S_IWUSR),
broken_parity_status_show,broken_parity_status_store),
__ATTR(msi_bus, 0644, msi_bus_show, msi_bus_store),
-#ifdef CONFIG_HOTPLUG
- __ATTR(remove, (S_IWUSR|S_IWGRP), NULL, remove_store),
- __ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_rescan_store),
-#endif
__ATTR_NULL,
};
@@ -1350,6 +1351,30 @@ static int __init pci_sysfs_init(void)
late_initcall(pci_sysfs_init);
+static struct attribute *pci_dev_phys_attrs[] = {
+#ifdef CONFIG_HOTPLUG
+ &pci_dev_remove_attr.attr,
+ &pci_dev_rescan_attr.attr,
+#endif
+ NULL
+};
+
+static umode_t pci_dev_phys_attrs_are_visible(struct kobject *kobj,
+ struct attribute *a, int n)
+{
+ struct device *dev = container_of(kobj, struct device, kobj);
+
+ if (dev_is_pf(dev))
+ return a->mode;
+
+ return 0;
+}
+
+static struct attribute_group pci_dev_phys_attr_group = {
+ .attrs = pci_dev_phys_attrs,
+ .is_visible = pci_dev_phys_attrs_are_visible,
+};
+
static struct attribute *pci_dev_bridge_attrs[] = {
NULL,
};
@@ -1373,6 +1398,7 @@ static struct attribute_group pci_dev_bridge_attr_group = {
static const struct attribute_group *pci_dev_attr_groups[] = {
&pci_dev_bridge_attr_group,
+ &pci_dev_phys_attr_group,
NULL,
};
@@ -692,7 +692,8 @@ extern void pci_stop_bus_device(struct pci_dev *dev);
void pci_setup_cardbus(struct pci_bus *bus);
extern void pci_sort_breadthfirst(void);
#define dev_is_pci(d) ((d)->bus == &pci_bus_type)
-#define dev_is_pf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_physfn : false))
+#define dev_is_vf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_virtfn : false))
+#define dev_is_pf(d) (!dev_is_vf(d))
#define dev_num_vf(d) ((dev_is_pci(d) ? pci_num_vf(to_pci_dev(d)) : 0))
/* Generic PCI functions exported to card drivers */
@@ -1343,6 +1344,7 @@ static inline int pci_domain_nr(struct pci_bus *bus)
#define dev_is_pci(d) (false)
#define dev_is_pf(d) (false)
+#define dev_is_vf(d) (false)
#define dev_num_vf(d) (0)
#endif /* CONFIG_PCI */