]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: i2c: ov2685: Use V4L2 legacy sensor clock helper
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tue, 12 Aug 2025 21:46:03 +0000 (00:46 +0300)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 9 Sep 2025 13:59:19 +0000 (15:59 +0200)
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" property has always
been specified as mandatory in the DT bindings and the "clock-frequency"
property has never been allowed. The "clocks" property has always been
set in the upstream DT sources, and the "clock-frequency" never. The
driver retrieves the clock, and sets its 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 <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Mehdi Djait <mehdi.djait@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/i2c/ov2685.c

index c435799514b95824a3fcf8b7e70877b669852add..4911a4eea126a8fe3ab2050fb0c928b0c78aad48 100644 (file)
@@ -783,16 +783,12 @@ static int ov2685_probe(struct i2c_client *client)
        ov2685->client = client;
        ov2685->cur_mode = &supported_modes[0];
 
-       ov2685->xvclk = devm_v4l2_sensor_clk_get(dev, "xvclk");
+       ov2685->xvclk = devm_v4l2_sensor_clk_get_legacy(dev, "xvclk", true,
+                                                       OV2685_XVCLK_FREQ);
        if (IS_ERR(ov2685->xvclk))
                return dev_err_probe(dev, PTR_ERR(ov2685->xvclk),
                                     "Failed to get xvclk\n");
 
-       ret = clk_set_rate(ov2685->xvclk, OV2685_XVCLK_FREQ);
-       if (ret < 0) {
-               dev_err(dev, "Failed to set xvclk rate (24MHz)\n");
-               return ret;
-       }
        if (clk_get_rate(ov2685->xvclk) != OV2685_XVCLK_FREQ)
                dev_warn(dev, "xvclk mismatched, modes are based on 24MHz\n");