Skip to contentSkip to conversation

i3c, iio: fix i3c driver dependencies

PATCH Superseded Arnd Bergmann 3 participants 3 messages Feb 2

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i3c, iio: fix i3c driver dependencies

From: Arnd Bergmann <[email protected]>

All combined i2c/i3c drivers appear to suffer from the same link time problem when CONFIG_I3C is set to 'm':

arm-linux-gnueabi-ld: drivers/iio/magnetometer/mmc5633.o: in function `mmc5633_i3c_driver_init':
mmc5633.c:(.init.text+0x30): undefined reference to `i3c_driver_register_with_owner'

This was previously fixed several times by marking individual drivers as 'depends on I2C; depends on I3C || !I3C', but this gets tedious and is somewhat confusing.

Add a Kconfig symbol 'I3C_OR_I2C' to help replace those dependencies, and use this in all the existing drivers that had already fixed it as well as the new mmc5633 driver.

Fixes 6e5f6bf2e3f0 ("iio: magnetometer: Add mmc5633 sensor")
---
 drivers/hwmon/Kconfig            | 17 ++---------------
 drivers/i3c/Kconfig              | 12 ++++++++++++
 drivers/iio/magnetometer/Kconfig |  2 +-
 drivers/misc/amd-sbi/Kconfig     |  3 +--
 4 files changed, 16 insertions(+), 18 deletions(-)
drivers/hwmon/Kconfig +2 -15
index 41c381764c2b..1ddb3f73fdc0 100644
@@ -1493,8 +1493,7 @@ config SENSORS_LM73
 
 config SENSORS_LM75
 	tristate "National Semiconductor LM75 and compatibles"
-	depends on I2C
-	depends on I3C || !I3C
+	depends on I3C_OR_I2C
 	select REGMAP_I2C
 	select REGMAP_I3C if I3C
 	help
@@ -2381,19 +2380,7 @@ config SENSORS_TMP102
 
 config SENSORS_TMP103
 	tristate "Texas Instruments TMP103"
-	depends on I2C
-	select REGMAP_I2C
-	help
-	  If you say yes here you get support for Texas Instruments TMP103
-	  sensor chips.
-
-	  This driver can also be built as a module. If so, the module
-	  will be called tmp103.
-
-config SENSORS_TMP108
-	tristate "Texas Instruments TMP108"
-	depends on I2C
-	depends on I3C || !I3C
+	depends on I3C_OR_I2C
 	select REGMAP_I2C
 	select REGMAP_I3C if I3C
 	help
drivers/i3c/Kconfig +12 -0
index 30a441506f61..626c54b386d5 100644
@@ -22,3 +22,15 @@ menuconfig I3C
 if I3C
 source "drivers/i3c/master/Kconfig"
 endif # I3C
+
+config I3C_OR_I2C
+	tristate
+	default m if I3C=m
+	default I2C
+	help
+	  Device drivers using module_i3c_i2c_driver() can use either
+	  i2c or i3c hosts, but cannot be built-in for the kernel when
+	  CONFIG_I3C=m.
+
+	  Add 'depends on I2C_OR_I3C' in Kconfig for those drivers to
+	  get the correct dependencies.
drivers/iio/magnetometer/Kconfig +1 -1
index 2b81b22c9550..448fef4e5716 100644
@@ -143,7 +143,7 @@ config MMC5633
 	tristate "MEMSIC MMC5633 3-axis magnetic sensor"
 	select REGMAP_I2C if I2C
 	select REGMAP_I3C if I3C
-	depends on I2C || I3C
+	depends on I3C_OR_I2C
 	help
 	  Say yes here to build support for the MEMSIC MMC5633 3-axis
 	  magnetic sensor.
drivers/misc/amd-sbi/Kconfig +1 -2
index be022c71a90c..30e7fad7356c 100644
@@ -1,10 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0-only
 config AMD_SBRMI_I2C
 	tristate "AMD side band RMI support"
-	depends on I2C
+	depends on I3C_OR_I2C
 	depends on ARM || ARM64 || COMPILE_TEST
 	select REGMAP_I2C
-	depends on I3C || !I3C
 	select REGMAP_I3C if I3C
 	help
 	  Side band RMI over I2C/I3C support for AMD out of band management.
Signature · 1 line
2.39.5
maintainer
#1 lore raw
Quoted 42 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

All combined i2c/i3c drivers appear to suffer from the same link time problem when CONFIG_I3C is set to 'm':

arm-linux-gnueabi-ld: drivers/iio/magnetometer/mmc5633.o: in function `mmc5633_i3c_driver_init':
mmc5633.c:(.init.text+0x30): undefined reference to `i3c_driver_register_with_owner'

This was previously fixed several times by marking individual drivers as 'depends on I2C; depends on I3C || !I3C', but this gets tedious and is somewhat confusing.

Add a Kconfig symbol 'I3C_OR_I2C' to help replace those dependencies, and use this in all the existing drivers that had already fixed it as well as the new mmc5633 driver.

Fixes 6e5f6bf2e3f0 ("iio: magnetometer: Add mmc5633 sensor")
---
  drivers/hwmon/Kconfig            | 17 ++---------------
  drivers/i3c/Kconfig              | 12 ++++++++++++
  drivers/iio/magnetometer/Kconfig |  2 +-
  drivers/misc/amd-sbi/Kconfig     |  3 +--
  4 files changed, 16 insertions(+), 18 deletions(-)
drivers/hwmon/Kconfig +1 -2
index 41c381764c2b..1ddb3f73fdc0 100644
@@ -1493,8 +1493,7 @@ config SENSORS_LM73
 
  config SENSORS_LM75
  	tristate "National Semiconductor LM75 and compatibles"
-	depends on I2C
-	depends on I3C || !I3C
+	depends on I3C_OR_I2C
  	select REGMAP_I2C
  	select REGMAP_I3C if I3C
  	help
@@ -2381,19 +2380,7 @@ config SENSORS_TMP102
 
  config SENSORS_TMP103

drivers/hwmon/Kconfig config SENSORS_TMP102 · line 2383

Quoted 10 lines
drivers/hwmon/Kconfig +0 -8
  	tristate "Texas Instruments TMP103"
-	depends on I2C
-	select REGMAP_I2C
-	help
-	  If you say yes here you get support for Texas Instruments TMP103
-	  sensor chips.
-
-	  This driver can also be built as a module. If so, the module
-	  will be called tmp103.
 

Why ? That doesn't make sense to me, and if it does, it seems unrelated to what this patch claims to do.

Quoted 57 lines
drivers/hwmon/Kconfig +1 -4
-config SENSORS_TMP108
-	tristate "Texas Instruments TMP108"
-	depends on I2C
-	depends on I3C || !I3C
+	depends on I3C_OR_I2C
  	select REGMAP_I2C
  	select REGMAP_I3C if I3C
  	help
drivers/i3c/Kconfig +12 -0
index 30a441506f61..626c54b386d5 100644
@@ -22,3 +22,15 @@ menuconfig I3C
  if I3C
  source "drivers/i3c/master/Kconfig"
  endif # I3C
+
+config I3C_OR_I2C
+	tristate
+	default m if I3C=m
+	default I2C
+	help
+	  Device drivers using module_i3c_i2c_driver() can use either
+	  i2c or i3c hosts, but cannot be built-in for the kernel when
+	  CONFIG_I3C=m.
+
+	  Add 'depends on I2C_OR_I3C' in Kconfig for those drivers to
+	  get the correct dependencies.
drivers/iio/magnetometer/Kconfig +1 -1
index 2b81b22c9550..448fef4e5716 100644
@@ -143,7 +143,7 @@ config MMC5633
  	tristate "MEMSIC MMC5633 3-axis magnetic sensor"
  	select REGMAP_I2C if I2C
  	select REGMAP_I3C if I3C
-	depends on I2C || I3C
+	depends on I3C_OR_I2C
  	help
  	  Say yes here to build support for the MEMSIC MMC5633 3-axis
  	  magnetic sensor.
drivers/misc/amd-sbi/Kconfig +1 -2
index be022c71a90c..30e7fad7356c 100644
@@ -1,10 +1,9 @@
  # SPDX-License-Identifier: GPL-2.0-only
  config AMD_SBRMI_I2C
  	tristate "AMD side band RMI support"
-	depends on I2C
+	depends on I3C_OR_I2C
  	depends on ARM || ARM64 || COMPILE_TEST
  	select REGMAP_I2C
-	depends on I3C || !I3C
  	select REGMAP_I3C if I3C
  	help
  	  Side band RMI over I2C/I3C support for AMD out of band management.
maintainer
#2 lore raw
Quoted 4 lines · Guenter Roeck
Quoted 2 lines · Arnd Bergmann
(quoted diff) +0 -0
@@ -2381,19 +2380,7 @@ config SENSORS_TMP102
 
Quoted 14 lines

drivers/hwmon/Kconfig config SENSORS_TMP102

Quoted 11 lines
drivers/hwmon/Kconfig +0 -8
  config SENSORS_TMP103
  	tristate "Texas Instruments TMP103"
-	depends on I2C
-	select REGMAP_I2C
-	help
-	  If you say yes here you get support for Texas Instruments TMP103
-	  sensor chips.
-
-	  This driver can also be built as a module. If so, the module
-	  will be called tmp103.
 

Why ? That doesn't make sense to me, and if it does, it seems unrelated to what this patch claims to do.

Indeed, that was not intended here. Sending a fixed version now.

I have no idea how that change got in there.

Arnd