public inbox for linux-gpio@vger.kernel.org
 help / color / mirror / Atom feed
From: Antti Laakso <antti.laakso@linux.intel.com>
To: linux-media@vger.kernel.org
Cc: linux-gpio@vger.kernel.org, platform-driver-x86@vger.kernel.org,
	linusw@kernel.org, brgl@kernel.org, sakari.ailus@linux.intel.com,
	mchehab@kernel.org, dan.scally@ideasonboard.com,
	hansg@kernel.org, ilpo.jarvinen@linux.intel.com,
	hverkuil+cisco@kernel.org, sre@kernel.org, hao.yao@intel.com,
	jimmy.su@intel.com, miguel.vadillo@intel.com, kees@kernel.org,
	ribalda@chromium.org
Subject: [PATCH v2 1/5] media: i2c: ov5675: Wait for endpoint
Date: Wed, 11 Mar 2026 15:19:06 +0200	[thread overview]
Message-ID: <20260311131910.835513-2-antti.laakso@linux.intel.com> (raw)
In-Reply-To: <20260311131910.835513-1-antti.laakso@linux.intel.com>

Defer probe if endpoint is not yet available. And do it before acquiring
clock, gpio and regulators.

Signed-off-by: Antti Laakso <antti.laakso@linux.intel.com>
---
 drivers/media/i2c/ov5675.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/media/i2c/ov5675.c b/drivers/media/i2c/ov5675.c
index ea26df328189..508149485248 100644
--- a/drivers/media/i2c/ov5675.c
+++ b/drivers/media/i2c/ov5675.c
@@ -1181,17 +1181,26 @@ static int ov5675_get_hwcfg(struct ov5675 *ov5675)
 	if (!fwnode)
 		return -ENXIO;
 
+	ep = fwnode_graph_get_endpoint_by_id(fwnode, 0, 0,
+					     FWNODE_GRAPH_ENDPOINT_NEXT);
+	ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg);
+	fwnode_handle_put(ep);
+	if (ret)
+		return ret;
+
 	ov5675->xvclk = devm_v4l2_sensor_clk_get(dev, NULL);
-	if (IS_ERR(ov5675->xvclk))
-		return dev_err_probe(dev, PTR_ERR(ov5675->xvclk),
-				     "failed to get xvclk: %pe\n",
-				     ov5675->xvclk);
+	if (IS_ERR(ov5675->xvclk)) {
+		ret = dev_err_probe(dev, PTR_ERR(ov5675->xvclk),
+				    "failed to get xvclk\n");
+		goto check_hwcfg_error;
+	}
 
 	xvclk_rate = clk_get_rate(ov5675->xvclk);
 	if (xvclk_rate != OV5675_XVCLK_19_2) {
 		dev_err(dev, "external clock rate %u is unsupported",
 			xvclk_rate);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto check_hwcfg_error;
 	}
 
 	ov5675->reset_gpio = devm_gpiod_get_optional(dev, "reset",
@@ -1199,7 +1208,7 @@ static int ov5675_get_hwcfg(struct ov5675 *ov5675)
 	if (IS_ERR(ov5675->reset_gpio)) {
 		ret = PTR_ERR(ov5675->reset_gpio);
 		dev_err(dev, "failed to get reset-gpios: %d\n", ret);
-		return ret;
+		goto check_hwcfg_error;
 	}
 
 	for (i = 0; i < OV5675_NUM_SUPPLIES; i++)
@@ -1208,16 +1217,7 @@ static int ov5675_get_hwcfg(struct ov5675 *ov5675)
 	ret = devm_regulator_bulk_get(dev, OV5675_NUM_SUPPLIES,
 				      ov5675->supplies);
 	if (ret)
-		return ret;
-
-	ep = fwnode_graph_get_next_endpoint(fwnode, NULL);
-	if (!ep)
-		return -ENXIO;
-
-	ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg);
-	fwnode_handle_put(ep);
-	if (ret)
-		return ret;
+		goto check_hwcfg_error;
 
 	if (bus_cfg.bus.mipi_csi2.num_data_lanes != OV5675_DATA_LANES) {
 		dev_err(dev, "number of CSI2 data lanes %d is not supported",
-- 
2.53.0


  reply	other threads:[~2026-03-11 13:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-11 13:19 [PATCH v2 0/5] platform: int3472: Add MSI prestige 14 AI EVO data Antti Laakso
2026-03-11 13:19 ` Antti Laakso [this message]
2026-03-11 14:31   ` [PATCH v2 1/5] media: i2c: ov5675: Wait for endpoint Hans de Goede
2026-03-11 19:10   ` Dan Scally
2026-03-11 13:19 ` [PATCH v2 2/5] media: ipu-bridge: Add ov5675 sensor Antti Laakso
2026-03-17 12:52   ` Sakari Ailus
2026-03-11 13:19 ` [PATCH v2 3/5] platform: int3472: Add gpio software node Antti Laakso
2026-03-11 14:33   ` Hans de Goede
2026-03-11 14:43   ` Bartosz Golaszewski
2026-03-17 11:53   ` Ilpo Järvinen
2026-03-11 13:19 ` [PATCH v2 4/5] gpio: tps68470: Add i2c daisy chain support Antti Laakso
2026-03-11 14:33   ` Hans de Goede
2026-03-11 14:42   ` Bartosz Golaszewski
2026-03-11 13:19 ` [PATCH v2 5/5] platform: int3472: Add MSI prestige board data Antti Laakso
2026-03-11 14:35   ` Hans de Goede
2026-03-12 21:00     ` Sakari Ailus
2026-03-11 14:43   ` Bartosz Golaszewski
2026-03-11 19:27   ` Dan Scally
2026-03-17 11:52   ` Ilpo Järvinen

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=20260311131910.835513-2-antti.laakso@linux.intel.com \
    --to=antti.laakso@linux.intel.com \
    --cc=brgl@kernel.org \
    --cc=dan.scally@ideasonboard.com \
    --cc=hansg@kernel.org \
    --cc=hao.yao@intel.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jimmy.su@intel.com \
    --cc=kees@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=miguel.vadillo@intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=ribalda@chromium.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=sre@kernel.org \
    /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