PCI/sysfs: Demacrofy pci_dev_resource_resize_attr(n) functions
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 22 Feb 2024 11:46:06 +0000 (13:46 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 5 Mar 2024 22:10:17 +0000 (16:10 -0600)
commitf6c73999837820f98519bf0146df44e58f20f89c
tree1df8728e690737ada86f304b075beb30fd5646cd
parent2ea548a3c01de873b54390dc07ef0a72d9b4a5f3
PCI/sysfs: Demacrofy pci_dev_resource_resize_attr(n) functions

pci_dev_resource_resize_attr(n) macro is invoked for six resources,
creating a large footprint function for each resource.

Rework the macro to only create a function that calls a helper function so
the compiler can decide if it warrants to inline the function or not.

With x86_64 defconfig, this saves roughly 2.5kB:

  $ scripts/bloat-o-meter drivers/pci/pci-sysfs.o{.old,.new}
  add/remove: 1/0 grow/shrink: 0/6 up/down: 512/-2934 (-2422)
  Function                                     old     new   delta
  __resource_resize_store                        -     512    +512
  resource5_resize_store                       503      14    -489
  resource4_resize_store                       503      14    -489
  resource3_resize_store                       503      14    -489
  resource2_resize_store                       503      14    -489
  resource1_resize_store                       503      14    -489
  resource0_resize_store                       500      11    -489
  Total: Before=13399, After=10977, chg -18.08%

(The compiler seemingly chose to still inline __resource_resize_show()
which is fine, those functions are not very complex/large.)

Link: https://lore.kernel.org/r/20240222114607.1837-1-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pci-sysfs.c