Skip to contentSkip to conversation

i2c: i2c-boardinfo: Annotate code used in init phase only

PATCH Applied Heiner Kallweit 3 participants 7 messages Sep 14, 2025 – Oct 18, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: i2c-boardinfo: Annotate code used in init phase only

Annotate two places in boardinfo code:
- __i2c_first_dynamic_bus_num is set in init phase. Annotate it as __ro_after_init to prevent later changes.
- i2c_register_board_info() is used in init phase only, so annotate it as __init, allowing to free the memory after init phase. This is safe, see comment: "done in board-specific init code near arch_initcall() time"

---
 drivers/i2c/i2c-boardinfo.c | 4 ++--
 include/linux/i2c.h         | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/i2c-boardinfo.c +2 -2
index 4df8ad092..338800321 100644
@@ -22,7 +22,7 @@ EXPORT_SYMBOL_GPL(__i2c_board_lock);
 LIST_HEAD(__i2c_board_list);
 EXPORT_SYMBOL_GPL(__i2c_board_list);
 
-int __i2c_first_dynamic_bus_num;
+int __i2c_first_dynamic_bus_num __ro_after_init;
 EXPORT_SYMBOL_GPL(__i2c_first_dynamic_bus_num);
 
 
@@ -48,7 +48,7 @@ EXPORT_SYMBOL_GPL(__i2c_first_dynamic_bus_num);
  * The board info passed can safely be __initdata, but be careful of embedded
  * pointers (for platform_data, functions, etc) since that won't be copied.
  */
-int i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned len)
+int __init i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned len)
 {
 	int status;
 
include/linux/i2c.h +1 -1
index 20fd41b51..11a19241e 100644
@@ -499,7 +499,7 @@ static inline struct i2c_client *i2c_verify_client(struct device *dev)
  * Modules for add-on boards must use other calls.
  */
 #ifdef CONFIG_I2C_BOARDINFO
-int
+int __init
 i2c_register_board_info(int busnum, struct i2c_board_info const *info,
 			unsigned n);
 #else
Signature · 1 line
2.51.0
Applied
#1 lore raw
Quoted 9 lines · Heiner Kallweit

Annotate two places in boardinfo code:
- __i2c_first_dynamic_bus_num is set in init phase. Annotate it as __ro_after_init to prevent later changes.
- i2c_register_board_info() is used in init phase only, so annotate it as __init, allowing to free the memory after init phase. This is safe, see comment: "done in board-specific init code near arch_initcall() time"

Applied to for-next, thanks!

The other patch needs some more time to look at.

#2 lore raw
In reply to Heiner Kallweit
Quoted 10 lines · Heiner Kallweit

Annotate two places in boardinfo code:
- __i2c_first_dynamic_bus_num is set in init phase. Annotate it as __ro_after_init to prevent later changes.
- i2c_register_board_info() is used in init phase only, so annotate it as __init, allowing to free the memory after init phase. This is safe, see comment: "done in board-specific init code near arch_initcall() time"

---

Hi, this seems to break booting on Qualcomm X1E80100 Surface Laptop 7 (arm64/boot/dts/qcom/x1e80100-microsoft-romulus.dtsi)

gcc-14.2 and clang-20.x

Funnily enough when I build this (albeit on another computer, but also with clang-20.x) and boot another X1E80100-based device (x1-crd.dtsi in the same DT dir), it boots up fine

Konrad

#3 lore raw

Hi Konrad,

Quoted 8 lines

Hi, this seems to break booting on Qualcomm X1E80100 Surface Laptop 7 (arm64/boot/dts/qcom/x1e80100-microsoft-romulus.dtsi)

gcc-14.2 and clang-20.x

Funnily enough when I build this (albeit on another computer, but also with clang-20.x) and boot another X1E80100-based device (x1-crd.dtsi in the same DT dir), it boots up fine

I reverted the commit now, but please if you can find out more details about the boot regression, this would be extremly helpful (maybe earlycon helps?).

All the best,

Wolfram

#4 lore raw
Quoted 7 lines · Wolfram Sang

Hi Konrad,

Quoted 5 lines

Hi, this seems to break booting on Qualcomm X1E80100 Surface Laptop 7 (arm64/boot/dts/qcom/x1e80100-microsoft-romulus.dtsi)

gcc-14.2 and clang-20.x

Quoted 7 lines
Quoted 3 lines

Funnily enough when I build this (albeit on another computer, but also with clang-20.x) and boot another X1E80100-based device (x1-crd.dtsi in the same DT dir), it boots up fine

I reverted the commit now, but please if you can find out more details about the boot regression, this would be extremly helpful (maybe earlycon helps?).

I'll try to poke at it the upcoming week, thanks

Konrad

#5 lore raw
Quoted 12 lines · Konrad Dybcio
Quoted 11 lines · Wolfram Sang

Hi Konrad,

Quoted 8 lines

Hi, this seems to break booting on Qualcomm X1E80100 Surface Laptop 7 (arm64/boot/dts/qcom/x1e80100-microsoft-romulus.dtsi)

gcc-14.2 and clang-20.x

Funnily enough when I build this (albeit on another computer, but also with clang-20.x) and boot another X1E80100-based device (x1-crd.dtsi in the same DT dir), it boots up fine

Quoted 6 lines
Quoted 3 lines

I reverted the commit now, but please if you can find out more details about the boot regression, this would be extremly helpful (maybe earlycon helps?).

I'll try to poke at it the upcoming week, thanks

Any result? It's somewhat unfortunate to revert a change just because of a vague report w/o evidence / logs / bisect results.

Quoted 1 line

Konrad

#6 lore raw
In reply to Konrad Dybcio
Quoted 9 lines · Konrad Dybcio
Quoted 8 lines · Heiner Kallweit

Annotate two places in boardinfo code:
- __i2c_first_dynamic_bus_num is set in init phase. Annotate it as __ro_after_init to prevent later changes.
- i2c_register_board_info() is used in init phase only, so annotate it as __init, allowing to free the memory after init phase. This is safe, see comment: "done in board-specific init code near arch_initcall() time"

Quoted 6 lines
Quoted 2 lines

---

Hi, this seems to break booting on Qualcomm X1E80100 Surface Laptop 7 (arm64/boot/dts/qcom/x1e80100-microsoft-romulus.dtsi)

What means "seems to break"? Is it or not? Did you bisect? Where exactly does the boot break/stop?
Can you provide a full dmesg log for success and error case on this device?

Quoted 7 lines

gcc-14.2 and clang-20.x

Funnily enough when I build this (albeit on another computer, but also with clang-20.x) and boot another X1E80100-based device (x1-crd.dtsi in the same DT dir), it boots up fine

Konrad