History

PCI/sysfs: Remove pci_create_legacy_files() and pci_sysfs_init()

Currently, pci_create_legacy_files() and pci_remove_legacy_files() are no-op stubs. With legacy attributes now handled by static groups registered via pcibus_groups[], no call site needs them. Remove both functions, their declarations, and the call sites in pci_register_host_bridge(), pci_alloc_child_bus(), and pci_remove_bus(). Remove the pci_sysfs_init() late_initcall and sysfs_initialized. The late_initcall originally existed to create all the dynamic PCI sysfs files, but with both resource and legacy attributes now handled by static groups, it is no longer needed. Remove the legacy_io and legacy_mem fields from struct pci_bus which were used to track the dynamically allocated legacy attributes.

Krzysztof Wilczyński committed 6 months ago

Commit 2800a911 parent 4e14b965 files · +0 −39Browse files

Unified · Split

5 files
  1. drivers/pci/pci-sysfs.c +0 −21
  2. drivers/pci/pci.h +0 −8
  3. drivers/pci/probe.c +0 −6
  4. drivers/pci/remove.c +0 −2
  5. include/linux/pci.h +0 −2
drivers/pci/pci-sysfs.c+0−21
@@ -37,10 +37,6 @@ · 36 unmodified lines
37#define ARCH_PCI_DEV_GROUPS37#define ARCH_PCI_DEV_GROUPS
38#endif38#endif
39 39
40#ifdef HAVE_PCI_LEGACY
41static int sysfs_initialized; /* = 0 */
42#endif
43
44/* show configuration fields */40/* show configuration fields */
45#define pci_config_attr(field, format_string) \41#define pci_config_attr(field, format_string) \
46static ssize_t \42static ssize_t \
@@ -1094,8 +1090,6 @@ static const struct attribute_group pci_legacy_mem_sparse_group = { · 1047 unmodified lines
1094 .is_bin_visible = pci_legacy_mem_sparse_is_visible,1090 .is_bin_visible = pci_legacy_mem_sparse_is_visible,
1095};1091};
1096 1092
1097void pci_create_legacy_files(struct pci_bus *b) { }
1098void pci_remove_legacy_files(struct pci_bus *b) { }
1099#endif /* HAVE_PCI_LEGACY */1093#endif /* HAVE_PCI_LEGACY */
1100 1094
1101const struct attribute_group *pcibus_groups[] = {1095const struct attribute_group *pcibus_groups[] = {
@@ -1782,21 +1776,6 @@ static const struct attribute_group pci_dev_resource_resize_attr_group = { · 680 unmodified lines
1782 .is_visible = resource_resize_attr_is_visible,1776 .is_visible = resource_resize_attr_is_visible,
1783};1777};
1784 1778
1785#ifdef HAVE_PCI_LEGACY
1786static int __init pci_sysfs_init(void)
1787{
1788 struct pci_bus *pbus = NULL;
1789
1790 sysfs_initialized = 1;
1791
1792 while ((pbus = pci_find_next_bus(pbus)))
1793 pci_create_legacy_files(pbus);
1794
1795 return 0;
1796}
1797late_initcall(pci_sysfs_init);
1798#endif
1799
1800static struct attribute *pci_dev_dev_attrs[] = {1779static struct attribute *pci_dev_dev_attrs[] = {
1801 &dev_attr_boot_vga.attr,1780 &dev_attr_boot_vga.attr,
1802 &dev_attr_serial_number.attr,1781 &dev_attr_serial_number.attr,
drivers/pci/pci.h+0−8
@@ -358,14 +358,6 @@ static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; } · 357 unmodified lines
358int pci_hp_add_bridge(struct pci_dev *dev);358int pci_hp_add_bridge(struct pci_dev *dev);
359bool pci_hp_spurious_link_change(struct pci_dev *pdev);359bool pci_hp_spurious_link_change(struct pci_dev *pdev);
360 360
361#if defined(CONFIG_SYSFS) && defined(HAVE_PCI_LEGACY)
362void pci_create_legacy_files(struct pci_bus *bus);
363void pci_remove_legacy_files(struct pci_bus *bus);
364#else
365static inline void pci_create_legacy_files(struct pci_bus *bus) { }
366static inline void pci_remove_legacy_files(struct pci_bus *bus) { }
367#endif
368
369/* Lock for read/write access to pci device and bus lists */361/* Lock for read/write access to pci device and bus lists */
370extern struct rw_semaphore pci_bus_sem;362extern struct rw_semaphore pci_bus_sem;
371extern struct mutex pci_slot_mutex;363extern struct mutex pci_slot_mutex;
drivers/pci/probe.c+0−6
@@ -1073,9 +1073,6 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) · 1072 unmodified lines
1073 dev_err(&bus->dev, "failed to add bus: %d\n", err);1073 dev_err(&bus->dev, "failed to add bus: %d\n", err);
1074 }1074 }
1075 1075
1076 /* Create legacy_io and legacy_mem files for this bus */
1077 pci_create_legacy_files(bus);
1078
1079 if (parent)1076 if (parent)
1080 dev_info(parent, "PCI host bridge to bus %s\n", name);1077 dev_info(parent, "PCI host bridge to bus %s\n", name);
1081 else1078 else
@@ -1281,9 +1278,6 @@ add_dev: · 199 unmodified lines
1281 dev_err(&child->dev, "failed to add bus: %d\n", ret);1278 dev_err(&child->dev, "failed to add bus: %d\n", ret);
1282 }1279 }
1283 1280
1284 /* Create legacy_io and legacy_mem files for this bus */
1285 pci_create_legacy_files(child);
1286
1287 return child;1281 return child;
1288}1282}
1289 1283
drivers/pci/remove.c+0−2
@@ -65,8 +65,6 @@ void pci_remove_bus(struct pci_bus *bus) · 64 unmodified lines
65 list_del(&bus->node);65 list_del(&bus->node);
66 pci_bus_release_busn_res(bus);66 pci_bus_release_busn_res(bus);
67 up_write(&pci_bus_sem);67 up_write(&pci_bus_sem);
68 pci_remove_legacy_files(bus);
69
70 if (bus->ops->remove_bus)68 if (bus->ops->remove_bus)
71 bus->ops->remove_bus(bus);69 bus->ops->remove_bus(bus);
72 70
include/linux/pci.h+0−2
@@ -726,8 +726,6 @@ struct pci_bus { · 725 unmodified lines
726 pci_bus_flags_t bus_flags; /* Inherited by child buses */726 pci_bus_flags_t bus_flags; /* Inherited by child buses */
727 struct device *bridge;727 struct device *bridge;
728 struct device dev;728 struct device dev;
729 struct bin_attribute *legacy_io; /* Legacy I/O for this bus */
730 struct bin_attribute *legacy_mem; /* Legacy mem */
731 unsigned int is_added:1;729 unsigned int is_added:1;
732 unsigned int unsafe_warn:1; /* warned about RW1C config write */730 unsigned int unsafe_warn:1; /* warned about RW1C config write */
733 unsigned int flit_mode:1; /* Link in Flit mode */731 unsigned int flit_mode:1; /* Link in Flit mode */