If the bridge has not yet setup the fwnode-graph then the fwnode_property_read_u32("clock-frequency") call will fail. Move the fwnode_property_read_u32("clock-frequency") call below the fwnode_graph_get_next_endpoint() call and return -EPROBE_DEFER if the latter fails. While moving the fwnode_property_read_u32("clock-frequency") call also switch to dev_err_probe() for logging when it fails so that the error code gets logged. Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx> --- drivers/media/i2c/ov08x40.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index 7ead3c720e0e..c0dc918edc3c 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -2060,31 +2060,32 @@ static int ov08x40_check_hwcfg(struct device *dev) int ret; u32 ext_clk; - if (!fwnode) - return -ENXIO; - - ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", - &ext_clk); - if (ret) { - dev_err(dev, "can't get clock frequency"); - return ret; - } - - if (ext_clk != OV08X40_EXT_CLK) { - dev_err(dev, "external clock %d is not supported", - ext_clk); - return -EINVAL; - } - + /* + * Sometimes the fwnode graph is initialized by the bridge driver. + * Bridge drivers doing this also add sensor properties, wait for this. + */ ep = fwnode_graph_get_next_endpoint(fwnode, NULL); if (!ep) - return -ENXIO; + return dev_err_probe(dev, -EPROBE_DEFER, + "waiting for fwnode graph endpoint\n"); ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg); fwnode_handle_put(ep); if (ret) return ret; + ret = fwnode_property_read_u32(fwnode, "clock-frequency", &ext_clk); + if (ret) { + dev_err_probe(dev, ret, "reading clock-frequency\n"); + goto out_err; + } + + if (ext_clk != OV08X40_EXT_CLK) { + dev_err(dev, "external clock %u is not supported\n", ext_clk); + ret = -EINVAL; + goto out_err; + } + if (bus_cfg.bus.mipi_csi2.num_data_lanes != OV08X40_DATA_LANES) { dev_err(dev, "number of CSI2 data lanes %d is not supported", bus_cfg.bus.mipi_csi2.num_data_lanes); -- 2.47.0