Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: Constify sysfs attribute_group structures

attribute_groups are not supposed to change at runtime. All functions
working with attribute_groups provided by <linux/sysfs.h> work with const
attribute_group. So mark the non-const structs as const.

File size before:
text data bss dec hex filename
8480 2024 4 10508 290c drivers/pci/pci-sysfs.o

File size After adding 'const':
text data bss dec hex filename
8736 1768 4 10508 290c drivers/pci/pci-sysfs.o

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Arvind Yadav and committed by
Bjorn Helgaas
e7ea9825 16f73eb0

+5 -5
+5 -5
drivers/pci/pci-sysfs.c
··· 1735 1735 NULL, 1736 1736 }; 1737 1737 1738 - static struct attribute_group pci_dev_hp_attr_group = { 1738 + static const struct attribute_group pci_dev_hp_attr_group = { 1739 1739 .attrs = pci_dev_hp_attrs, 1740 1740 .is_visible = pci_dev_hp_attrs_are_visible, 1741 1741 }; ··· 1759 1759 return a->mode; 1760 1760 } 1761 1761 1762 - static struct attribute_group sriov_dev_attr_group = { 1762 + static const struct attribute_group sriov_dev_attr_group = { 1763 1763 .attrs = sriov_dev_attrs, 1764 1764 .is_visible = sriov_attrs_are_visible, 1765 1765 }; 1766 1766 #endif /* CONFIG_PCI_IOV */ 1767 1767 1768 - static struct attribute_group pci_dev_attr_group = { 1768 + static const struct attribute_group pci_dev_attr_group = { 1769 1769 .attrs = pci_dev_dev_attrs, 1770 1770 .is_visible = pci_dev_attrs_are_visible, 1771 1771 }; 1772 1772 1773 - static struct attribute_group pci_bridge_attr_group = { 1773 + static const struct attribute_group pci_bridge_attr_group = { 1774 1774 .attrs = pci_bridge_attrs, 1775 1775 .is_visible = pci_bridge_attrs_are_visible, 1776 1776 }; 1777 1777 1778 - static struct attribute_group pcie_dev_attr_group = { 1778 + static const struct attribute_group pcie_dev_attr_group = { 1779 1779 .attrs = pcie_dev_attrs, 1780 1780 .is_visible = pcie_dev_attrs_are_visible, 1781 1781 };