From: Laurent Pinchart Date: Tue, 12 Aug 2025 21:46:10 +0000 (+0300) Subject: media: i2c: s5k6a3: Use V4L2 legacy sensor clock helper X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c0baf70955e7f865036463fdfc562ffa092f4250;p=users%2Fhch%2Fmisc.git media: i2c: s5k6a3: 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" property has always been specified as mandatory in the DT bindings and the "clock-frequency" property has initially been optional. Both properties were initially set in the upstream DT sources. The driver retrieves the clock, retrieves the clock rate from the "clock-frequency" property if available or uses a fixed default otherwise, and sets the clock rate. 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/s5k6a3.c b/drivers/media/i2c/s5k6a3.c index 4bf5f122b113..ba6477e88da3 100644 --- a/drivers/media/i2c/s5k6a3.c +++ b/drivers/media/i2c/s5k6a3.c @@ -51,7 +51,6 @@ enum { * @lock: mutex protecting the structure's members below * @format: media bus format at the sensor's source pad * @clock: pointer to &struct clk. - * @clock_frequency: clock frequency * @power_count: stores state if device is powered */ struct s5k6a3 { @@ -63,7 +62,6 @@ struct s5k6a3 { struct mutex lock; struct v4l2_mbus_framefmt format; struct clk *clock; - u32 clock_frequency; int power_count; }; @@ -192,10 +190,6 @@ static int __s5k6a3_power_on(struct s5k6a3 *sensor) int i = S5K6A3_SUPP_VDDA; int ret; - ret = clk_set_rate(sensor->clock, sensor->clock_frequency); - if (ret < 0) - return ret; - ret = pm_runtime_get(sensor->dev); if (ret < 0) goto error_rpm_put; @@ -292,7 +286,9 @@ static int s5k6a3_probe(struct i2c_client *client) mutex_init(&sensor->lock); sensor->dev = dev; - sensor->clock = devm_v4l2_sensor_clk_get(sensor->dev, S5K6A3_CLK_NAME); + sensor->clock = devm_v4l2_sensor_clk_get_legacy(sensor->dev, + S5K6A3_CLK_NAME, false, + S5K6A3_DEFAULT_CLK_FREQ); if (IS_ERR(sensor->clock)) return dev_err_probe(sensor->dev, PTR_ERR(sensor->clock), "failed to get extclk\n"); @@ -302,13 +298,6 @@ static int s5k6a3_probe(struct i2c_client *client) if (ret) return ret; - if (of_property_read_u32(dev->of_node, "clock-frequency", - &sensor->clock_frequency)) { - sensor->clock_frequency = S5K6A3_DEFAULT_CLK_FREQ; - dev_info(dev, "using default %u Hz clock frequency\n", - sensor->clock_frequency); - } - for (i = 0; i < S5K6A3_NUM_SUPPLIES; i++) sensor->supplies[i].supply = s5k6a3_supply_names[i];