[v2,3/9] media: ov2740: Move fwnode_graph_get_next_endpoint() call up
Commit Message
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>
---
drivers/media/i2c/ov2740.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
Comments
Hi Hans,
On Sun, Nov 26, 2023 at 03:15:11PM +0100, Hans de Goede wrote:
> 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>
> ---
> drivers/media/i2c/ov2740.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c
> index 0396e40419ca..832f24721dca 100644
> --- a/drivers/media/i2c/ov2740.c
> +++ b/drivers/media/i2c/ov2740.c
> @@ -926,6 +926,14 @@ 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;
> +
You'll need
fwnode_handle_put(ep);
in error cases below, too.
> ret = fwnode_property_read_u32(fwnode, "clock-frequency", &mclk);
> if (ret)
> return ret;
> @@ -935,10 +943,6 @@ static int ov2740_check_hwcfg(struct device *dev)
> "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);
> if (ret)
@@ -926,6 +926,14 @@ 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)
return ret;
@@ -935,10 +943,6 @@ static int ov2740_check_hwcfg(struct device *dev)
"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);
if (ret)