Skip to contentSkip to conversation

i3c: fix module_i3c_i2c_driver() with I3C=n

PATCH Applied Arnd Bergmann 5 participants 5 messages Jul 25, 2025 – Jul 30, 2025 I3C

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i3c: fix module_i3c_i2c_driver() with I3C=n

From: Arnd Bergmann <[email protected]>

When CONFIG_I3C is disabled and the i3c_i2c_driver_register() happens to not be inlined, any driver calling it still references the i3c_driver instance, which then causes a link failure:

x86_64-linux-ld: drivers/hwmon/lm75.o: in function `lm75_i3c_reg_read':
lm75.c:(.text+0xc61): undefined reference to `i3cdev_to_dev'
x86_64-linux-ld: lm75.c:(.text+0xd25): undefined reference to `i3c_device_do_priv_xfers'
x86_64-linux-ld: lm75.c:(.text+0xdd8): undefined reference to `i3c_device_do_priv_xfers'

This issue was part of the original i3c code, but only now caused problems when i3c support got added to lm75.

Change the 'inline' annotations in the header to '__always_inline' to ensure that the dead-code-elimination pass in the compiler can optimize it out as intended.

Fixes 6071d10413ff ("hwmon: (lm75) add I3C support for P3T1755")
Fixes 3a379bbcea0a ("i3c: Add core I3C infrastructure")
---
 include/linux/i3c/device.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/i3c/device.h +2 -2
index b674f64d0822..7f136de4b73e 100644
@@ -245,7 +245,7 @@ void i3c_driver_unregister(struct i3c_driver *drv);
  *
  * Return: 0 if both registrations succeeds, a negative error code otherwise.
  */
-static inline int i3c_i2c_driver_register(struct i3c_driver *i3cdrv,
+static __always_inline int i3c_i2c_driver_register(struct i3c_driver *i3cdrv,
 					  struct i2c_driver *i2cdrv)
 {
 	int ret;
@@ -270,7 +270,7 @@ static inline int i3c_i2c_driver_register(struct i3c_driver *i3cdrv,
  * Note that when CONFIG_I3C is not enabled, this function only unregisters the
  * @i2cdrv.
  */
-static inline void i3c_i2c_driver_unregister(struct i3c_driver *i3cdrv,
+static __always_inline void i3c_i2c_driver_unregister(struct i3c_driver *i3cdrv,
 					     struct i2c_driver *i2cdrv)
 {
 	if (IS_ENABLED(CONFIG_I3C))
Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When CONFIG_I3C is disabled and the i3c_i2c_driver_register() happens to not be inlined, any driver calling it still references the i3c_driver instance, which then causes a link failure:

x86_64-linux-ld: drivers/hwmon/lm75.o: in function `lm75_i3c_reg_read':
lm75.c:(.text+0xc61): undefined reference to `i3cdev_to_dev'
x86_64-linux-ld: lm75.c:(.text+0xd25): undefined reference to `i3c_device_do_priv_xfers'
x86_64-linux-ld: lm75.c:(.text+0xdd8): undefined reference to `i3c_device_do_priv_xfers'

This issue was part of the original i3c code, but only now caused problems when i3c support got added to lm75.

Quoted 7 lines

Change the 'inline' annotations in the header to '__always_inline' to ensure that the dead-code-elimination pass in the compiler can optimize it out as intended.

Fixes 6071d10413ff ("hwmon: (lm75) add I3C support for P3T1755")
Fixes 3a379bbcea0a ("i3c: Add core I3C infrastructure")
Quoted 26 lines
---
  include/linux/i3c/device.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/i3c/device.h +2 -2
index b674f64d0822..7f136de4b73e 100644
@@ -245,7 +245,7 @@ void i3c_driver_unregister(struct i3c_driver *drv);
   *
   * Return: 0 if both registrations succeeds, a negative error code otherwise.
   */
-static inline int i3c_i2c_driver_register(struct i3c_driver *i3cdrv,
+static __always_inline int i3c_i2c_driver_register(struct i3c_driver *i3cdrv,
  					  struct i2c_driver *i2cdrv)
  {
  	int ret;
@@ -270,7 +270,7 @@ static inline int i3c_i2c_driver_register(struct i3c_driver *i3cdrv,
   * Note that when CONFIG_I3C is not enabled, this function only unregisters the
   * @i2cdrv.
   */
-static inline void i3c_i2c_driver_unregister(struct i3c_driver *i3cdrv,
+static __always_inline void i3c_i2c_driver_unregister(struct i3c_driver *i3cdrv,
  					     struct i2c_driver *i2cdrv)
  {
  	if (IS_ENABLED(CONFIG_I3C))
reviewer Reviewed-by
#2 lore raw
Quoted 15 lines · Guenter Roeck
Quoted 14 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When CONFIG_I3C is disabled and the i3c_i2c_driver_register() happens to not be inlined, any driver calling it still references the i3c_driver instance, which then causes a link failure:

x86_64-linux-ld: drivers/hwmon/lm75.o: in function `lm75_i3c_reg_read':
lm75.c:(.text+0xc61): undefined reference to `i3cdev_to_dev'
x86_64-linux-ld: lm75.c:(.text+0xd25): undefined reference to `i3c_device_do_priv_xfers'
x86_64-linux-ld: lm75.c:(.text+0xdd8): undefined reference to `i3c_device_do_priv_xfers'

This issue was part of the original i3c code, but only now caused problems when i3c support got added to lm75.

Quoted 7 lines
Quoted 7 lines

Change the 'inline' annotations in the header to '__always_inline' to ensure that the dead-code-elimination pass in the compiler can optimize it out as intended.

Fixes 6071d10413ff ("hwmon: (lm75) add I3C support for P3T1755")
Fixes 3a379bbcea0a ("i3c: Add core I3C infrastructure")
Quoted 35 lines
Quoted 18 lines
---
  include/linux/i3c/device.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/i3c/device.h +1 -1
index b674f64d0822..7f136de4b73e 100644
@@ -245,7 +245,7 @@ void i3c_driver_unregister(struct i3c_driver *drv);
   *
   * Return: 0 if both registrations succeeds, a negative error code otherwise.
   */
-static inline int i3c_i2c_driver_register(struct i3c_driver *i3cdrv,
+static __always_inline int i3c_i2c_driver_register(struct i3c_driver *i3cdrv,
  					  struct i2c_driver *i2cdrv)
  {
  	int ret;

include/linux/i3c/device.h static inline int i3c_i2c_driver_register(struct i3c_driver *i3cdrv, · line 276

Quoted 8 lines
include/linux/i3c/device.h +1 -1
@@ -270,7 +270,7 @@ static inline int i3c_i2c_driver_register(struct i3c_driver *i3cdrv,
   * Note that when CONFIG_I3C is not enabled, this function only unregisters the
   * @i2cdrv.
   */
-static inline void i3c_i2c_driver_unregister(struct i3c_driver *i3cdrv,
+static __always_inline void i3c_i2c_driver_unregister(struct i3c_driver *i3cdrv,
  					     struct i2c_driver *i2cdrv)
  {
  	if (IS_ENABLED(CONFIG_I3C))

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Reviewed-by Tested-by on v1 1/1
#3 lore raw
In reply to Arnd Bergmann
Quoted 14 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When CONFIG_I3C is disabled and the i3c_i2c_driver_register() happens to not be inlined, any driver calling it still references the i3c_driver instance, which then causes a link failure:

x86_64-linux-ld: drivers/hwmon/lm75.o: in function `lm75_i3c_reg_read':
lm75.c:(.text+0xc61): undefined reference to `i3cdev_to_dev'
x86_64-linux-ld: lm75.c:(.text+0xd25): undefined reference to `i3c_device_do_priv_xfers'
x86_64-linux-ld: lm75.c:(.text+0xdd8): undefined reference to `i3c_device_do_priv_xfers'

This issue was part of the original i3c code, but only now caused problems when i3c support got added to lm75.

Quoted 7 lines

Change the 'inline' annotations in the header to '__always_inline' to ensure that the dead-code-elimination pass in the compiler can optimize it out as intended.

Fixes 6071d10413ff ("hwmon: (lm75) add I3C support for P3T1755")
Fixes 3a379bbcea0a ("i3c: Add core I3C infrastructure")

Thanks.

Quoted 26 lines
---
 include/linux/i3c/device.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/i3c/device.h +2 -2
index b674f64d0822..7f136de4b73e 100644
@@ -245,7 +245,7 @@ void i3c_driver_unregister(struct i3c_driver *drv);
  *
  * Return: 0 if both registrations succeeds, a negative error code otherwise.
  */
-static inline int i3c_i2c_driver_register(struct i3c_driver *i3cdrv,
+static __always_inline int i3c_i2c_driver_register(struct i3c_driver *i3cdrv,
 					  struct i2c_driver *i2cdrv)
 {
 	int ret;
@@ -270,7 +270,7 @@ static inline int i3c_i2c_driver_register(struct i3c_driver *i3cdrv,
  * Note that when CONFIG_I3C is not enabled, this function only unregisters the
  * @i2cdrv.
  */
-static inline void i3c_i2c_driver_unregister(struct i3c_driver *i3cdrv,
+static __always_inline void i3c_i2c_driver_unregister(struct i3c_driver *i3cdrv,
 					     struct i2c_driver *i2cdrv)
 {
 	if (IS_ENABLED(CONFIG_I3C))
maintainer Applied
#4 lore raw
In reply to Arnd Bergmann
Quoted 10 lines · Arnd Bergmann

When CONFIG_I3C is disabled and the i3c_i2c_driver_register() happens to not be inlined, any driver calling it still references the i3c_driver instance, which then causes a link failure:

x86_64-linux-ld: drivers/hwmon/lm75.o: in function `lm75_i3c_reg_read':
lm75.c:(.text+0xc61): undefined reference to `i3cdev_to_dev'
x86_64-linux-ld: lm75.c:(.text+0xd25): undefined reference to `i3c_device_do_priv_xfers'
x86_64-linux-ld: lm75.c:(.text+0xdd8): undefined reference to `i3c_device_do_priv_xfers'

[...]

Applied, thanks!

[1/1] i3c: fix module_i3c_i2c_driver() with I3C=n

      https://git.kernel.org/abelloni/c/5523a466e905

Best regards,

Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com