From: Laurent Pinchart Date: Tue, 12 Aug 2025 21:45:56 +0000 (+0300) Subject: media: i2c: gc05a2: Use V4L2 legacy sensor clock helper X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=30dbc5316736bb17aa59729e417db45bfface060;p=thirdparty%2Fkernel%2Fstable.git media: i2c: gc05a2: Use V4L2 legacy sensor clock helper Several camera sensor drivers access the "clock-frequency" property directly to retrieve the external clock rate, or modify the clock rate of the external clock programmatically. Both behaviours are valid on a subset of ACPI platforms, but are considered deprecated on OF platforms, and do not support ACPI platforms that implement MIPI DisCo for Imaging. Implementing them manually in drivers is deprecated, as that can encourage copying deprecated behaviour for OF platforms in new drivers, and lead to differences in behaviour between drivers. Instead, drivers that need to preserve the deprecated OF behaviour should use the devm_v4l2_sensor_clk_get_legacy() helper. This driver supports OF platforms only. The "clocks" and "clock-frequency" properties were initially mandatory in the DT bindings and were both set in the upstream DT sources. The driver retrieves the clock, retrieves and ignores the clock rate from the clock-frequency property, and sets the clock rate to a fixed value. This is deprecated behaviour for OF. Switch to using the devm_v4l2_sensor_clk_get_legacy() helper. This preserves setting the clock rate on OF platforms. Should support for OF platforms that set the clock rate through clock-frequency be considered unneeded in the future, the driver will only need to switch to devm_v4l2_sensor_clk_get() without any other change. Signed-off-by: Laurent Pinchart Signed-off-by: Sakari Ailus Reviewed-by: Mehdi Djait Signed-off-by: Hans Verkuil --- diff --git a/drivers/media/i2c/gc05a2.c b/drivers/media/i2c/gc05a2.c index 4dadd25e6c908..8ba17f80fffe7 100644 --- a/drivers/media/i2c/gc05a2.c +++ b/drivers/media/i2c/gc05a2.c @@ -1235,16 +1235,12 @@ static int gc05a2_probe(struct i2c_client *client) return dev_err_probe(dev, PTR_ERR(gc05a2->regmap), "failed to init CCI\n"); - gc05a2->xclk = devm_v4l2_sensor_clk_get(dev, NULL); + gc05a2->xclk = devm_v4l2_sensor_clk_get_legacy(dev, NULL, true, + GC05A2_DEFAULT_CLK_FREQ); if (IS_ERR(gc05a2->xclk)) return dev_err_probe(dev, PTR_ERR(gc05a2->xclk), "failed to get xclk\n"); - ret = clk_set_rate(gc05a2->xclk, GC05A2_DEFAULT_CLK_FREQ); - if (ret) - return dev_err_probe(dev, ret, - "failed to set xclk frequency\n"); - ret = gc05a2_get_regulators(dev, gc05a2); if (ret < 0) return dev_err_probe(dev, ret,