Skip to contentSkip to conversation

PCI: Annotate pci_cache_line_size variables as __ro_after_init

PATCH Applied Heiner Kallweit 2 participants 2 messages Apr 18, 2024 PCI

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 PCI: Annotate pci_cache_line_size variables as __ro_after_init

Annotate both variables as __ro_after_init, enforcing that they can't be changed after the init phase.

---
v2:
- remove annotation from extern declaration in pci.h

---
 drivers/pci/pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/pci.c +2 -2
index 5f8edba78..59aaebb67 100644
@@ -142,8 +142,8 @@ enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_DEFAULT;
  * the dfl or actual value as it sees fit.  Don't forget this is
  * measured in 32-bit words, not bytes.
  */
-u8 pci_dfl_cache_line_size = L1_CACHE_BYTES >> 2;
-u8 pci_cache_line_size;
+u8 pci_dfl_cache_line_size __ro_after_init = L1_CACHE_BYTES >> 2;
+u8 pci_cache_line_size __ro_after_init ;
 
 /*
  * If we set up a device for bus mastering, we need to check the latency
Signature · 1 line
2.44.0
#1 lore raw
Quoted 4 lines · Heiner Kallweit

Annotate both variables as __ro_after_init, enforcing that they can't be changed after the init phase.

Applied to pci/misc for v6.10, thanks!

Quoted 24 lines

---
v2:
- remove annotation from extern declaration in pci.h

---
 drivers/pci/pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/pci.c +2 -2
index 5f8edba78..59aaebb67 100644
@@ -142,8 +142,8 @@ enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_DEFAULT;
  * the dfl or actual value as it sees fit.  Don't forget this is
  * measured in 32-bit words, not bytes.
  */
-u8 pci_dfl_cache_line_size = L1_CACHE_BYTES >> 2;
-u8 pci_cache_line_size;
+u8 pci_dfl_cache_line_size __ro_after_init = L1_CACHE_BYTES >> 2;
+u8 pci_cache_line_size __ro_after_init ;
 
 /*
  * If we set up a device for bus mastering, we need to check the latency
Signature · 1 line
2.44.0