linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i3c: fix module_i3c_i2c_driver() with I3C=n
@ 2025-07-25  9:06 Arnd Bergmann
  2025-07-25  9:19 ` Guenter Roeck
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Arnd Bergmann @ 2025-07-25  9:06 UTC (permalink / raw)
  To: Alexandre Belloni, Wolfram Sang, Guenter Roeck, Boris Brezillon,
	Arnd Bergmann, Greg Kroah-Hartman
  Cc: Frank Li, Geert Uytterhoeven, linux-i3c, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 include/linux/i3c/device.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
index b674f64d0822..7f136de4b73e 100644
--- a/include/linux/i3c/device.h
+++ b/include/linux/i3c/device.h
@@ -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))
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] i3c: fix module_i3c_i2c_driver() with I3C=n
  2025-07-25  9:06 [PATCH] i3c: fix module_i3c_i2c_driver() with I3C=n Arnd Bergmann
@ 2025-07-25  9:19 ` Guenter Roeck
  2025-07-25 13:28   ` Frank Li
  2025-07-30  0:12 ` Randy Dunlap
  2025-07-30 23:40 ` Alexandre Belloni
  2 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2025-07-25  9:19 UTC (permalink / raw)
  To: Arnd Bergmann, Alexandre Belloni, Wolfram Sang, Boris Brezillon,
	Arnd Bergmann, Greg Kroah-Hartman
  Cc: Frank Li, Geert Uytterhoeven, linux-i3c, linux-kernel

On 7/25/25 02:06, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> 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")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   include/linux/i3c/device.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
> index b674f64d0822..7f136de4b73e 100644
> --- a/include/linux/i3c/device.h
> +++ b/include/linux/i3c/device.h
> @@ -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))


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] i3c: fix module_i3c_i2c_driver() with I3C=n
  2025-07-25  9:19 ` Guenter Roeck
@ 2025-07-25 13:28   ` Frank Li
  0 siblings, 0 replies; 5+ messages in thread
From: Frank Li @ 2025-07-25 13:28 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Arnd Bergmann, Alexandre Belloni, Wolfram Sang, Boris Brezillon,
	Arnd Bergmann, Greg Kroah-Hartman, Geert Uytterhoeven, linux-i3c,
	linux-kernel

On Fri, Jul 25, 2025 at 02:19:19AM -0700, Guenter Roeck wrote:
> On 7/25/25 02:06, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > 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")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
>
> > ---
> >   include/linux/i3c/device.h | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
> > index b674f64d0822..7f136de4b73e 100644
> > --- a/include/linux/i3c/device.h
> > +++ b/include/linux/i3c/device.h
> > @@ -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))
>
>
> --
> linux-i3c mailing list
> linux-i3c@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] i3c: fix module_i3c_i2c_driver() with I3C=n
  2025-07-25  9:06 [PATCH] i3c: fix module_i3c_i2c_driver() with I3C=n Arnd Bergmann
  2025-07-25  9:19 ` Guenter Roeck
@ 2025-07-30  0:12 ` Randy Dunlap
  2025-07-30 23:40 ` Alexandre Belloni
  2 siblings, 0 replies; 5+ messages in thread
From: Randy Dunlap @ 2025-07-30  0:12 UTC (permalink / raw)
  To: Arnd Bergmann, Alexandre Belloni, Wolfram Sang, Guenter Roeck,
	Boris Brezillon, Arnd Bergmann, Greg Kroah-Hartman
  Cc: Frank Li, Geert Uytterhoeven, linux-i3c, linux-kernel

On 7/25/25 2:06 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> 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")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>

Thanks.

> ---
>  include/linux/i3c/device.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
> index b674f64d0822..7f136de4b73e 100644
> --- a/include/linux/i3c/device.h
> +++ b/include/linux/i3c/device.h
> @@ -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))

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] i3c: fix module_i3c_i2c_driver() with I3C=n
  2025-07-25  9:06 [PATCH] i3c: fix module_i3c_i2c_driver() with I3C=n Arnd Bergmann
  2025-07-25  9:19 ` Guenter Roeck
  2025-07-30  0:12 ` Randy Dunlap
@ 2025-07-30 23:40 ` Alexandre Belloni
  2 siblings, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2025-07-30 23:40 UTC (permalink / raw)
  To: Wolfram Sang, Guenter Roeck, Boris Brezillon, Arnd Bergmann,
	Greg Kroah-Hartman, Arnd Bergmann
  Cc: Frank Li, Geert Uytterhoeven, linux-i3c, linux-kernel

On Fri, 25 Jul 2025 11:06:03 +0200, Arnd Bergmann wrote:
> 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,

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-30 23:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-25  9:06 [PATCH] i3c: fix module_i3c_i2c_driver() with I3C=n Arnd Bergmann
2025-07-25  9:19 ` Guenter Roeck
2025-07-25 13:28   ` Frank Li
2025-07-30  0:12 ` Randy Dunlap
2025-07-30 23:40 ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).