From: Mehdi Djait mehdi.djait@linux.intel.com
[ Upstream commit 2d240b124cc9df62ccccee6054bc3d1d19018758 ]
Both ACPI and DT-based systems are required to obtain the external camera sensor clock using the new devm_v4l2_sensor_clk_get() helper function.
Ensure a dependency on HAVE_CLK when config VIDEO_CAMERA_SENSOR is enabled.
Signed-off-by: Mehdi Djait mehdi.djait@linux.intel.com Reviewed-by: Arnd Bergmann arnd@arndb.de Signed-off-by: Sakari Ailus sakari.ailus@linux.intel.com Signed-off-by: Hans Verkuil hverkuil+cisco@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
YES
- What changed: The patch adds a single dependency to gate the entire camera sensor menu on the clock framework by changing the line in drivers/media/i2c/Kconfig:30 from “depends on MEDIA_CAMERA_SUPPORT && I2C” to “depends on MEDIA_CAMERA_SUPPORT && I2C && HAVE_CLK”. This confines all options under “if VIDEO_CAMERA_SENSOR” to builds where the clk API is available.
- Why it’s needed: The commit message states camera sensors now must obtain their external sensor clock via the new devm_v4l2_sensor_clk_get() helper. That implies the clk consumer API must be present. In the kernel, devm_clk_get() and friends are only built when HAVE_CLK=y (drivers/clk/Makefile:1 “obj-$(CONFIG_HAVE_CLK) += clk-devres.o”), and while include/linux/clk.h provides stubs when !CONFIG_HAVE_CLK, those stubs return NULL/0 and no-op, which can mask build issues but lead to misconfiguration or malfunction at runtime when sensors require an actual MCLK. Many i2c camera sensors already rely on clk APIs: - drivers/media/i2c/imx219.c:1158 (devm_clk_get(dev, NULL)) - drivers/media/i2c/ov5640.c:3901 (devm_clk_get(dev, "xclk")) - drivers/media/i2c/ov7670.c:1868 (devm_clk_get_optional(&client->dev, "xclk")) This shows the practical requirement for clk support across the group. Additionally, some media i2c drivers already enforce clk dependencies individually (e.g., drivers/media/i2c/ccs/Kconfig:2 “depends on HAVE_CLK”), and this change lifts that correctness to the menu-level.
- Bug fixed: Prevents invalid configurations where VIDEO_CAMERA_SENSOR can be enabled on platforms without clock support, which either: - fail at runtime when an external sensor clock is required, or - depend on stubs returning NULL/0 (include/linux/clk.h:1040+) that “appear to work” but do not actually provide a sensor clock, causing probe failures or subtle malfunctions.
- Scope and risk: The change is one-line, Kconfig-only, subsystem-local, and introduces no runtime code changes. It reduces misconfigurations and does not add features or architectural shifts. On platforms that legitimately use these drivers, HAVE_CLK is already set; on platforms without clocks, these drivers are not meaningful. This is minimal risk and aligns with stable tree policy.
- Stable backport considerations: While the commit lacks an explicit “Cc: stable” tag, it is a classic dependency fix that: - is small and contained, - prevents user-visible failures on misconfigured builds, - aligns the menu with the new clock helper’s requirements, - matches existing per-driver patterns. If earlier stable series do not yet include the devm_v4l2_sensor_clk_get() conversions, the change is still harmless (it only hides options on platforms without clk support), and improves configuration correctness.
drivers/media/i2c/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index 6237fe804a5c8..1f5a3082ead9c 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -27,7 +27,7 @@ config VIDEO_IR_I2C
menuconfig VIDEO_CAMERA_SENSOR bool "Camera sensor devices" - depends on MEDIA_CAMERA_SUPPORT && I2C + depends on MEDIA_CAMERA_SUPPORT && I2C && HAVE_CLK select MEDIA_CONTROLLER select V4L2_FWNODE select VIDEO_V4L2_SUBDEV_API