From: Hans de Goede <hdegoede@redhat.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>,
Jason Chen <jason.z.chen@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-media@vger.kernel.org
Subject: [PATCH 1/2] media: ov08x40: Move fwnode_property_read_u32("clock-frequency") call down
Date: Sat, 12 Oct 2024 13:52:35 +0200 [thread overview]
Message-ID: <20241012115236.53998-1-hdegoede@redhat.com> (raw)
If the bridge has not yet setup the fwnode-graph then
the fwnode_property_read_u32("clock-frequency") call will fail.
Move the fwnode_property_read_u32("clock-frequency") call below
the fwnode_graph_get_next_endpoint() call and return -EPROBE_DEFER
if the latter fails.
While moving the fwnode_property_read_u32("clock-frequency") call also
switch to dev_err_probe() for logging when it fails so that the error
code gets logged.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/media/i2c/ov08x40.c | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c
index 7ead3c720e0e..c0dc918edc3c 100644
--- a/drivers/media/i2c/ov08x40.c
+++ b/drivers/media/i2c/ov08x40.c
@@ -2060,31 +2060,32 @@ static int ov08x40_check_hwcfg(struct device *dev)
int ret;
u32 ext_clk;
- if (!fwnode)
- return -ENXIO;
-
- ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency",
- &ext_clk);
- if (ret) {
- dev_err(dev, "can't get clock frequency");
- return ret;
- }
-
- if (ext_clk != OV08X40_EXT_CLK) {
- dev_err(dev, "external clock %d is not supported",
- ext_clk);
- return -EINVAL;
- }
-
+ /*
+ * Sometimes the fwnode graph is initialized by the bridge driver.
+ * Bridge drivers doing this also add sensor properties, wait for this.
+ */
ep = fwnode_graph_get_next_endpoint(fwnode, NULL);
if (!ep)
- return -ENXIO;
+ return dev_err_probe(dev, -EPROBE_DEFER,
+ "waiting for fwnode graph endpoint\n");
ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg);
fwnode_handle_put(ep);
if (ret)
return ret;
+ ret = fwnode_property_read_u32(fwnode, "clock-frequency", &ext_clk);
+ if (ret) {
+ dev_err_probe(dev, ret, "reading clock-frequency\n");
+ goto out_err;
+ }
+
+ if (ext_clk != OV08X40_EXT_CLK) {
+ dev_err(dev, "external clock %u is not supported\n", ext_clk);
+ ret = -EINVAL;
+ goto out_err;
+ }
+
if (bus_cfg.bus.mipi_csi2.num_data_lanes != OV08X40_DATA_LANES) {
dev_err(dev, "number of CSI2 data lanes %d is not supported",
bus_cfg.bus.mipi_csi2.num_data_lanes);
--
2.47.0
next reply other threads:[~2024-10-12 11:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-12 11:52 Hans de Goede [this message]
2024-10-12 11:52 ` [PATCH 2/2] media: ov08x40: Add missing '\n' to ov08x40_check_hwcfg() error messages Hans de Goede
2024-10-12 14:40 ` Bryan O'Donoghue
2024-10-12 15:10 ` [PATCH 1/2] media: ov08x40: Move fwnode_property_read_u32("clock-frequency") call down Bryan O'Donoghue
2024-11-01 11:20 ` Sakari Ailus
2024-11-06 21:57 ` 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=20241012115236.53998-1-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=jason.z.chen@intel.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@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