]> git.itanic.dy.fi Git - linux-stable/commitdiff
media: ov2740: Move fwnode_graph_get_next_endpoint() call up
authorHans de Goede <hdegoede@redhat.com>
Mon, 4 Dec 2023 12:39:40 +0000 (13:39 +0100)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 13 Dec 2023 12:21:20 +0000 (13:21 +0100)
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>
drivers/media/i2c/ov2740.c

index 653cd96bb1563481280d3229c4da910a21eab4fc..06427e886d15102cb3e99e555140754e93b48eb2 100644 (file)
@@ -929,18 +929,26 @@ static int ov2740_check_hwcfg(struct device *dev)
        int ret;
        unsigned int i, j;
 
+       /*
+        * 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)
+       if (ret) {
+               fwnode_handle_put(ep);
                return ret;
+       }
 
-       if (mclk != OV2740_MCLK)
+       if (mclk != OV2740_MCLK) {
+               fwnode_handle_put(ep);
                return dev_err_probe(dev, -EINVAL,
                                     "external clock %d is not supported\n",
                                     mclk);
-
-       ep = fwnode_graph_get_next_endpoint(fwnode, NULL);
-       if (!ep)
-               return -EPROBE_DEFER;
+       }
 
        ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg);
        fwnode_handle_put(ep);