public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>,
	Tianshu Qiu <tian.shu.qiu@intel.com>,
	Bingbu Cao <bingbu.cao@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Kate Hsuan <hpa@redhat.com>,
	linux-media@vger.kernel.org
Subject: [PATCH v2 3/9] media: ov2740: Move fwnode_graph_get_next_endpoint() call up
Date: Sun, 26 Nov 2023 15:15:11 +0100	[thread overview]
Message-ID: <20231126141517.7534-4-hdegoede@redhat.com> (raw)
In-Reply-To: <20231126141517.7534-1-hdegoede@redhat.com>

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;
+
 	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)
-- 
2.41.0


  parent reply	other threads:[~2023-11-26 14:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-26 14:15 [PATCH v2 0/9] media: ov2740: reset GPIO, clk and 180 MHz link-frequency support Hans de Goede
2023-11-26 14:15 ` [PATCH v2 1/9] media: ov2740: Add support for reset GPIO Hans de Goede
2023-11-26 14:15 ` [PATCH v2 2/9] media: ov2740: Add support for external clock Hans de Goede
2023-11-26 14:15 ` Hans de Goede [this message]
2023-11-27 11:55   ` [PATCH v2 3/9] media: ov2740: Move fwnode_graph_get_next_endpoint() call up Sakari Ailus
2023-11-26 14:15 ` [PATCH v2 4/9] media: ov2740: Improve ov2740_check_hwcfg() error reporting Hans de Goede
2023-11-26 14:15 ` [PATCH v2 5/9] media: ov2740: Fix hts value Hans de Goede
2023-11-26 14:15 ` [PATCH v2 6/9] media: ov2740: Check hwcfg after allocating the ov2740 struct Hans de Goede
2023-11-26 14:15 ` [PATCH v2 7/9] media: ov2740: Add support for 180 MHz link frequency Hans de Goede
2023-11-26 14:15 ` [PATCH v2 8/9] media: ov2740: Add a sleep after resetting the sensor Hans de Goede
2023-11-27  4:15   ` Bingbu Cao
2023-11-27  6:39     ` Hao Yao
2023-11-26 14:15 ` [PATCH v2 9/9] media: ipu-bridge: Change ov2740 link-frequency to 180 MHz Hans de Goede

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=20231126141517.7534-4-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=bingbu.cao@intel.com \
    --cc=hpa@redhat.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tian.shu.qiu@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