Commit df81fef9 authored by Kumar Gala's avatar Kumar Gala Committed by Fabio Baltieri
Browse files

drivers: sensor: Convert Kconfig bus 'depends on' to 'select'



This change in pattern is meant to address a misconfiguration issue
that can occur for sensors that support being on multiple busses
like I2C & SPI.

For example, you can have a configuration in which such a sensor is
on the I2C bus in the devicetree and the sensor is enabled.  However
the application configuration enables CONFIG_SPI=y and CONFIG_I2C=n
and this will cause the sensor driver to be built by default, however
since we don't have the I2C bus enabled the driver will not compile
correctly.

Previously we had been adding to board Kconfig.defconfig something
like:

	config I2C
		default y if SENSOR

This pattern doesn't scale well and may differ from what an application
specific need/use is.

So instead move to a pattern in which we leave the default enablement
up to the devicetree "status" property for the sensor.  We then have
the Kconfig move from 'depends on <BUS>' to 'select <BUS>' and in
the case of drivers that support multiple busses we have the Kconfig
be: 'select <BUS> if $(dt_compat_on_bus,$(<DT_COMPAT>),<BUS>) for
each bus type the sensor supports.

This removes the need to add Kconfig logic to each board and enables
the bus subsystem and bus controller driver if the sensor requires
it by default in the build system.

Fixes: #48518

Signed-off-by: default avatarKumar Gala <galak@kernel.org>
parent 25ed2875
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ menuconfig ADT7420
	bool "ADT7420 Temperature Sensor"
	default y
	depends on DT_HAS_ADI_ADT7420_ENABLED
	depends on I2C
	select I2C
	help
	  Enable the driver for Analog Devices ADT7420 High-Accuracy
	  16-bit Digital I2C Temperature Sensors.
+2 −1
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ config ADXL345
	bool "ADXL345 Three Axis accelerometer"
	default y
	depends on DT_HAS_ADI_ADXL345_ENABLED
	depends on I2C || SPI
	select I2C if $(dt_compat_on_bus,$(DT_COMPAT_ADI_ADXL345),i2c)
	select SPI if $(dt_compat_on_bus,$(DT_COMPAT_ADI_ADXL345),spi)
	help
	  Enable driver for ADXL345 Three-Axis Digital Accelerometer.
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ menuconfig ADXL362
	bool "ADXL362 sensor"
	default y
	depends on DT_HAS_ADI_ADXL362_ENABLED
	depends on SPI
	select SPI
	help
	  Enable driver for ADXL362 Three-Axis Digital Accelerometers.

+2 −1
Original line number Diff line number Diff line
@@ -7,7 +7,8 @@ menuconfig ADXL372
	bool "ADXL372 Three Axis High-g I2C/SPI accelerometer"
	default y
	depends on DT_HAS_ADI_ADXL372_ENABLED
	depends on I2C || SPI
	select I2C if $(dt_compat_on_bus,$(DT_COMPAT_ADI_ADXL372),i2c)
	select SPI if $(dt_compat_on_bus,$(DT_COMPAT_ADI_ADXL372),spi)
	help
	  Enable driver for ADXL372 Three-Axis Digital Accelerometers.

+1 −1
Original line number Diff line number Diff line
@@ -7,6 +7,6 @@ config AK8975
	bool "AK8975 Magnetometer"
	default y
	depends on DT_HAS_ASAHI_KASEI_AK8975_ENABLED
	depends on I2C
	select I2C
	help
	  Enable driver for AK8975 magnetometer.
Loading