On Wed Sep 30 14:41:35 2026 +0800, Hermes Wu wrote:
> it6625_init_data() preset csi_lanes/port_num/bus_type before DT
> parsing ran, and it6625_parse_endpoint() fell back to those hardcoded
> defaults whenever no CSI-2 endpoint node was found instead of failing.
> The binding requires port@0, so a missing endpoint should surface as a
> probe error, not silently apply a hardcoded D-PHY/4-lane
> configuration.
> 
> Drop the presets from it6625_init_data() -- these values must come
> only from DT -- and delete the no-endpoint fallback entirely rather
> than reshaping it. This is safe: of_fwnode_handle(NULL) returns NULL,
> and v4l2_fwnode_endpoint_alloc_parse() -> __v4l2_fwnode_endpoint_parse()
> already returns -EPROBE_DEFER for a NULL fwnode before touching
> anything else, which is a strictly better result for the no-endpoint
> case than a driver-local -EINVAL.
> 
> While here, consolidate the three -EINVAL return sites in
> it6625_parse_endpoint() through a single error-path label instead of
> repeating v4l2_fwnode_endpoint_free() at each one.
> 
> Signed-off-by: Hermes Wu <[email protected]>
> Signed-off-by: Hans Verkuil <[email protected]>

Patch committed.

Thanks,
Hans Verkuil

 drivers/media/i2c/it6625.c | 32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)

---

diff --git a/drivers/media/i2c/it6625.c b/drivers/media/i2c/it6625.c
index 515711057b25..607e578761c4 100644
--- a/drivers/media/i2c/it6625.c
+++ b/drivers/media/i2c/it6625.c
@@ -2077,9 +2077,6 @@ static void it6625_init_data(struct it6625 *it6625)
        static struct v4l2_dv_timings default_timing =
                        V4L2_DV_BT_CEA_1920X1080P60;
 
-       it6625->csi_lanes = 4;
-       it6625->port_num = 1;
-       it6625->bus_type = V4L2_MBUS_CSI2_DPHY;
        it6625->csi_format = it6625_formats[0].csi_format;
        it6625->mbus_fmt_code = it6625_formats[0].mbus_fmt_code;
        it6625->timings = default_timing;
@@ -2125,33 +2122,24 @@ static int it6625_parse_endpoint(struct it6625 *it6625)
                        of_node_put(port_ep);
        }
 
-       if (!ep) {
-               it6625->port_num = 1;
-               dev_dbg(dev, "no CSI-2 endpoint node found, using default %u 
CSI lanes",
-                       it6625->csi_lanes);
-               return 0;
-       }
-
        ret = v4l2_fwnode_endpoint_alloc_parse(of_fwnode_handle(ep), &endpoint);
        of_node_put(ep);
-       if (ret) {
-               dev_err(dev, "failed to parse endpoint: %d", ret);
-               return ret;
-       }
+       if (ret)
+               return dev_err_probe(dev, ret, "failed to parse endpoint");
 
        if (endpoint.bus_type != V4L2_MBUS_CSI2_DPHY &&
            endpoint.bus_type != V4L2_MBUS_CSI2_CPHY) {
                dev_err(dev, "unsupported bus type %d, expected CSI-2 D-PHY or 
C-PHY",
                        endpoint.bus_type);
-               v4l2_fwnode_endpoint_free(&endpoint);
-               return -EINVAL;
+               ret = -EINVAL;
+               goto out_free_endpoint;
        }
 
        if (endpoint.bus_type == V4L2_MBUS_CSI2_CPHY &&
            it6625->chip_type != IT6626_CHIP) {
                dev_err(dev, "IT6625 does not support C-PHY, only IT6626 does");
-               v4l2_fwnode_endpoint_free(&endpoint);
-               return -EINVAL;
+               ret = -EINVAL;
+               goto out_free_endpoint;
        }
 
        max_lanes = (endpoint.bus_type == V4L2_MBUS_CSI2_CPHY) ? 3 : 4;
@@ -2161,15 +2149,17 @@ static int it6625_parse_endpoint(struct it6625 *it6625)
                dev_err(dev,
                        "invalid number of CSI data lanes: %u (max %u for this 
bus type)",
                        endpoint.bus.mipi_csi2.num_data_lanes, max_lanes);
-               v4l2_fwnode_endpoint_free(&endpoint);
-               return -EINVAL;
+               ret = -EINVAL;
+               goto out_free_endpoint;
        }
 
        it6625->csi_lanes = endpoint.bus.mipi_csi2.num_data_lanes;
        it6625->bus_type = endpoint.bus_type;
+
+out_free_endpoint:
        v4l2_fwnode_endpoint_free(&endpoint);
 
-       return 0;
+       return ret;
 }
 
 static int it6625_parse_dt(struct it6625 *it6625)
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to