On Tue Jul 7 23:24:25 2026 +0800, Hao-Qun Huang wrote:
> tegra_vi_channels_alloc() iterates over port nodes and skips those
> whose reg property cannot be read or whose remote endpoint fails
> v4l2_fwnode_endpoint_parse(), leaving the negative result of the
> failed call in ret. If that happens on the last port node, the loop
> ends with ret still negative and tegra_vi_init() fails the whole VI
> probe.
>
> The same defective port earlier in the ports node is skipped silently,
> so probing succeeds or fails depending on the order of the port nodes.
> The CSI equivalent, tegra_csi_channels_alloc(), returns 0
> unconditionally after its loop and does not have this problem.
>
> Use a separate variable for the per-port checks so that only fatal
> errors end up in ret.
>
> Fixes: 1ebaeb09830f ("media: tegra-video: Add support for external sensor
> capture")
> Fixes: 2ac4035a78c9 ("media: tegra-video: Add support for x8 captures with
> gang ports")
> Cc: [email protected]
> Assisted-by: Claude:claude-fable-5
> Signed-off-by: Hao-Qun Huang <[email protected]>
> Signed-off-by: Hans Verkuil <[email protected]>
Patch committed.
Thanks,
Hans Verkuil
drivers/staging/media/tegra-video/vi.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/drivers/staging/media/tegra-video/vi.c
b/drivers/staging/media/tegra-video/vi.c
index ce09949178f6..01622013c109 100644
--- a/drivers/staging/media/tegra-video/vi.c
+++ b/drivers/staging/media/tegra-video/vi.c
@@ -1257,6 +1257,7 @@ static int tegra_vi_channels_alloc(struct tegra_vi *vi)
struct device_node *parent;
struct v4l2_fwnode_endpoint v4l2_ep = { .bus_type = 0 };
unsigned int lanes;
+ int err;
int ret = 0;
ports = of_get_child_by_name(node, "ports");
@@ -1267,8 +1268,8 @@ static int tegra_vi_channels_alloc(struct tegra_vi *vi)
if (!of_node_name_eq(port, "port"))
continue;
- ret = of_property_read_u32(port, "reg", &port_num);
- if (ret < 0)
+ err = of_property_read_u32(port, "reg", &port_num);
+ if (err < 0)
continue;
if (port_num > vi->soc->vi_max_channels) {
@@ -1289,10 +1290,10 @@ static int tegra_vi_channels_alloc(struct tegra_vi *vi)
ep = of_graph_get_endpoint_by_regs(parent, 0, 0);
of_node_put(parent);
- ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep),
+ err = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep),
&v4l2_ep);
of_node_put(ep);
- if (ret)
+ if (err)
continue;
lanes = v4l2_ep.bus.mipi_csi2.num_data_lanes;
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]