From: Hermes Wu via B4 Relay <devnull+Hermes.wu.ite.com.tw@kernel.org>
To: Hermes Wu <Hermes.Wu@ite.com.tw>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Hans Verkuil <hverkuil+cisco@kernel.org>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, Hermes Wu <Hermes.wu@ite.com.tw>
Subject: [PATCH v2 17/21] media: i2c: it6625: require a DT endpoint and simplify endpoint parsing
Date: Wed, 30 Sep 2026 14:41:35 +0800 [thread overview]
Message-ID: <20260930-upstream-it6625-follow-up-patch-v2-17-e353f887e7fa@ite.com.tw> (raw)
In-Reply-To: <20260930-upstream-it6625-follow-up-patch-v2-0-e353f887e7fa@ite.com.tw>
From: Hermes Wu <Hermes.wu@ite.com.tw>
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 <Hermes.wu@ite.com.tw>
---
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 7637418c5a214d32f75d197a1e0ba1bffe7235f9..01200acb6bda5cdd759caf70642fcd910284a8b8 100644
--- a/drivers/media/i2c/it6625.c
+++ b/drivers/media/i2c/it6625.c
@@ -2074,9 +2074,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;
@@ -2122,33 +2119,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;
@@ -2158,15 +2146,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)
--
2.34.1
next prev parent reply other threads:[~2026-09-30 6:42 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 6:41 [PATCH v2 00/21] media: i2c: it6625: address review feedback and adopt subdev state Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 01/21] dt-bindings: media: ite,it6625: document the default CSI-2 bus type Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 02/21] media: i2c: it6625: propagate initial-setup and control-update errors Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 03/21] media: i2c: it6625: default the debug module parameter to 0 Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 04/21] media: i2c: it6625: drop unused bus field from struct it6625 Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 05/21] media: i2c: it6625: drop stale GCC < 4.4.6 workaround Hermes Wu via B4 Relay
2026-09-30 15:31 ` Hans Verkuil
2026-09-30 6:41 ` [PATCH v2 06/21] media: i2c: it6625: use unsigned int loop indices in table lookups Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 07/21] media: i2c: it6625: drop redundant parentheses in status helpers Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 08/21] media: i2c: it6625: make the audio sampling-rate table static const Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 09/21] media: i2c: it6625: tidy CEC buffer init and a continuation line Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 10/21] media: i2c: it6625: clean up it6625_wait_for_status() Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 11/21] media: i2c: it6625: use unsigned int indices in EDID read/write Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 12/21] media: i2c: it6625: use unaligned/units helpers to decode pixel clock Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 13/21] media: i2c: it6625: decode detected timings via typed register structs Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 14/21] media: i2c: it6625: fix link-frequency reporting for one-/two-trio C-PHY Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 15/21] media: i2c: it6625: use early returns in it6625_update_timings_if_changed() Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 16/21] media: i2c: it6625: drop the private CSI-format name table Hermes Wu via B4 Relay
2026-09-30 6:41 ` Hermes Wu via B4 Relay [this message]
2026-09-30 6:41 ` [PATCH v2 18/21] media: i2c: it6625: finish reverse fir-tree declaration order Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 19/21] media: i2c: it6625: fold subdev initialization into probe Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 20/21] media: i2c: it6625: use centrally managed active state Hermes Wu via B4 Relay
2026-09-30 6:41 ` [PATCH v2 21/21] media: i2c: it6625: use enable_streams and disable_streams Hermes Wu via B4 Relay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260930-upstream-it6625-follow-up-patch-v2-17-e353f887e7fa@ite.com.tw \
--to=devnull+hermes.wu.ite.com.tw@kernel.org \
--cc=Hermes.Wu@ite.com.tw \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hverkuil+cisco@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=robh@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®