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

media: i2c: ov2680: Use the v4l2 helper for obtaining the clock

Use the new v4l2 helper devm_v4l2_sensor_clk_get() that works on both
DT- and ACPI-based platforms to retrieve a reference to the clock
producer from firmware.

Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>

authored by

Mehdi Djait and committed by
Hans Verkuil
380e6896 51d79d12

+2 -27
+2 -27
drivers/media/i2c/ov2680.c
··· 1079 1079 struct device *dev = sensor->dev; 1080 1080 struct fwnode_handle *ep_fwnode; 1081 1081 struct gpio_desc *gpio; 1082 - unsigned int rate = 0; 1083 1082 int i, ret; 1084 1083 1085 1084 /* ··· 1113 1114 1114 1115 sensor->pwdn_gpio = gpio; 1115 1116 1116 - sensor->xvclk = devm_clk_get_optional(dev, "xvclk"); 1117 + sensor->xvclk = devm_v4l2_sensor_clk_get(dev, "xvclk"); 1117 1118 if (IS_ERR(sensor->xvclk)) { 1118 1119 ret = dev_err_probe(dev, PTR_ERR(sensor->xvclk), 1119 1120 "xvclk clock missing or invalid\n"); 1120 1121 goto out_free_bus_cfg; 1121 1122 } 1122 1123 1123 - /* 1124 - * We could have either a 24MHz or 19.2MHz clock rate from either DT or 1125 - * ACPI... but we also need to support the weird IPU3 case which will 1126 - * have an external clock AND a clock-frequency property. Check for the 1127 - * clock-frequency property and if found, set that rate if we managed 1128 - * to acquire a clock. This should cover the ACPI case. If the system 1129 - * uses devicetree then the configured rate should already be set, so 1130 - * we can just read it. 1131 - */ 1132 - ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", 1133 - &rate); 1134 - if (ret && !sensor->xvclk) { 1135 - dev_err_probe(dev, ret, "invalid clock config\n"); 1136 - goto out_free_bus_cfg; 1137 - } 1138 - 1139 - if (!ret && sensor->xvclk) { 1140 - ret = clk_set_rate(sensor->xvclk, rate); 1141 - if (ret) { 1142 - dev_err_probe(dev, ret, "failed to set clock rate\n"); 1143 - goto out_free_bus_cfg; 1144 - } 1145 - } 1146 - 1147 - sensor->xvclk_freq = rate ?: clk_get_rate(sensor->xvclk); 1124 + sensor->xvclk_freq = clk_get_rate(sensor->xvclk); 1148 1125 1149 1126 for (i = 0; i < ARRAY_SIZE(ov2680_xvclk_freqs); i++) { 1150 1127 if (sensor->xvclk_freq == ov2680_xvclk_freqs[i])