Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: i2c: gc08a3: 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 <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>

authored by

Laurent Pinchart and committed by
Mauro Carvalho Chehab
d2d7488b 30dbc531

+2 -6
+2 -6
drivers/media/i2c/gc08a3.c
··· 1199 1199 return dev_err_probe(dev, PTR_ERR(gc08a3->regmap), 1200 1200 "failed to init CCI\n"); 1201 1201 1202 - gc08a3->xclk = devm_v4l2_sensor_clk_get(dev, NULL); 1202 + gc08a3->xclk = devm_v4l2_sensor_clk_get_legacy(dev, NULL, true, 1203 + GC08A3_DEFAULT_CLK_FREQ); 1203 1204 if (IS_ERR(gc08a3->xclk)) 1204 1205 return dev_err_probe(dev, PTR_ERR(gc08a3->xclk), 1205 1206 "failed to get xclk\n"); 1206 - 1207 - ret = clk_set_rate(gc08a3->xclk, GC08A3_DEFAULT_CLK_FREQ); 1208 - if (ret) 1209 - return dev_err_probe(dev, ret, 1210 - "failed to set xclk frequency\n"); 1211 1207 1212 1208 ret = gc08a3_get_regulators(dev, gc08a3); 1213 1209 if (ret < 0)