media: ov2740: Move fwnode_graph_get_next_endpoint() call up

If the bridge has not yet setup the fwnode-graph then
the fwnode_property_read_u32("clock-frequency") call will fail.

Move the fwnode_graph_get_next_endpoint() call to above reading
the clock-frequency.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
Hans de Goede 2023-12-04 13:39:40 +01:00 committed by Hans Verkuil
parent 846a37cf47
commit 47913c1f55

View File

@ -929,19 +929,27 @@ static int ov2740_check_hwcfg(struct device *dev)
int ret;
unsigned int i, j;
ret = fwnode_property_read_u32(fwnode, "clock-frequency", &mclk);
if (ret)
return ret;
if (mclk != OV2740_MCLK)
return dev_err_probe(dev, -EINVAL,
"external clock %d is not supported\n",
mclk);
/*
* Sometimes the fwnode graph is initialized by the bridge driver,
* wait for this.
*/
ep = fwnode_graph_get_next_endpoint(fwnode, NULL);
if (!ep)
return -EPROBE_DEFER;
ret = fwnode_property_read_u32(fwnode, "clock-frequency", &mclk);
if (ret) {
fwnode_handle_put(ep);
return ret;
}
if (mclk != OV2740_MCLK) {
fwnode_handle_put(ep);
return dev_err_probe(dev, -EINVAL,
"external clock %d is not supported\n",
mclk);
}
ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg);
fwnode_handle_put(ep);
if (ret)