* [PATCH 1/2] media: ov08x40: Move fwnode_property_read_u32("clock-frequency") call down
@ 2024-10-12 11:52 Hans de Goede
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 15:10 ` [PATCH 1/2] media: ov08x40: Move fwnode_property_read_u32("clock-frequency") call down Bryan O'Donoghue
0 siblings, 2 replies; 6+ messages in thread
From: Hans de Goede @ 2024-10-12 11:52 UTC (permalink / raw)
To: Sakari Ailus, Jason Chen
Cc: Hans de Goede, Mauro Carvalho Chehab, linux-media
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] media: ov08x40: Add missing '\n' to ov08x40_check_hwcfg() error messages
2024-10-12 11:52 [PATCH 1/2] media: ov08x40: Move fwnode_property_read_u32("clock-frequency") call down Hans de Goede
@ 2024-10-12 11:52 ` 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
1 sibling, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2024-10-12 11:52 UTC (permalink / raw)
To: Sakari Ailus, Jason Chen
Cc: Hans de Goede, Mauro Carvalho Chehab, linux-media
Add '\n' to the dev_err() error messages printed on ov08x40_check_hwcfg()
errors.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/media/i2c/ov08x40.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c
index c0dc918edc3c..610fb3ef46c4 100644
--- a/drivers/media/i2c/ov08x40.c
+++ b/drivers/media/i2c/ov08x40.c
@@ -2087,14 +2087,14 @@ static int ov08x40_check_hwcfg(struct device *dev)
}
if (bus_cfg.bus.mipi_csi2.num_data_lanes != OV08X40_DATA_LANES) {
- dev_err(dev, "number of CSI2 data lanes %d is not supported",
+ dev_err(dev, "number of CSI2 data lanes %d is not supported\n",
bus_cfg.bus.mipi_csi2.num_data_lanes);
ret = -EINVAL;
goto out_err;
}
if (!bus_cfg.nr_of_link_frequencies) {
- dev_err(dev, "no link frequencies defined");
+ dev_err(dev, "no link frequencies defined\n");
ret = -EINVAL;
goto out_err;
}
@@ -2107,7 +2107,7 @@ static int ov08x40_check_hwcfg(struct device *dev)
}
if (j == bus_cfg.nr_of_link_frequencies) {
- dev_err(dev, "no link frequency %lld supported",
+ dev_err(dev, "no link frequency %lld supported\n",
link_freq_menu_items[i]);
ret = -EINVAL;
goto out_err;
@@ -2129,7 +2129,7 @@ static int ov08x40_probe(struct i2c_client *client)
/* Check HW config */
ret = ov08x40_check_hwcfg(&client->dev);
if (ret) {
- dev_err(&client->dev, "failed to check hwcfg: %d", ret);
+ dev_err(&client->dev, "failed to check hwcfg: %d\n", ret);
return ret;
}
--
2.47.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] media: ov08x40: Add missing '\n' to ov08x40_check_hwcfg() error messages
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
0 siblings, 0 replies; 6+ messages in thread
From: Bryan O'Donoghue @ 2024-10-12 14:40 UTC (permalink / raw)
To: Hans de Goede, Sakari Ailus, Jason Chen
Cc: Mauro Carvalho Chehab, linux-media
On 12/10/2024 12:52, Hans de Goede wrote:
> Add '\n' to the dev_err() error messages printed on ov08x40_check_hwcfg()
> errors.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/media/i2c/ov08x40.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c
> index c0dc918edc3c..610fb3ef46c4 100644
> --- a/drivers/media/i2c/ov08x40.c
> +++ b/drivers/media/i2c/ov08x40.c
> @@ -2087,14 +2087,14 @@ static int ov08x40_check_hwcfg(struct device *dev)
> }
>
> if (bus_cfg.bus.mipi_csi2.num_data_lanes != OV08X40_DATA_LANES) {
> - dev_err(dev, "number of CSI2 data lanes %d is not supported",
> + dev_err(dev, "number of CSI2 data lanes %d is not supported\n",
> bus_cfg.bus.mipi_csi2.num_data_lanes);
> ret = -EINVAL;
> goto out_err;
> }
>
> if (!bus_cfg.nr_of_link_frequencies) {
> - dev_err(dev, "no link frequencies defined");
> + dev_err(dev, "no link frequencies defined\n");
> ret = -EINVAL;
> goto out_err;
> }
> @@ -2107,7 +2107,7 @@ static int ov08x40_check_hwcfg(struct device *dev)
> }
>
> if (j == bus_cfg.nr_of_link_frequencies) {
> - dev_err(dev, "no link frequency %lld supported",
> + dev_err(dev, "no link frequency %lld supported\n",
> link_freq_menu_items[i]);
> ret = -EINVAL;
> goto out_err;
> @@ -2129,7 +2129,7 @@ static int ov08x40_probe(struct i2c_client *client)
> /* Check HW config */
> ret = ov08x40_check_hwcfg(&client->dev);
> if (ret) {
> - dev_err(&client->dev, "failed to check hwcfg: %d", ret);
> + dev_err(&client->dev, "failed to check hwcfg: %d\n", ret);
> return ret;
> }
>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] media: ov08x40: Move fwnode_property_read_u32("clock-frequency") call down
2024-10-12 11:52 [PATCH 1/2] media: ov08x40: Move fwnode_property_read_u32("clock-frequency") call down Hans de Goede
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 15:10 ` Bryan O'Donoghue
2024-11-01 11:20 ` Sakari Ailus
1 sibling, 1 reply; 6+ messages in thread
From: Bryan O'Donoghue @ 2024-10-12 15:10 UTC (permalink / raw)
To: Hans de Goede, Sakari Ailus, Jason Chen
Cc: Mauro Carvalho Chehab, linux-media
On 12/10/2024 12:52, Hans de Goede wrote:
> 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);
20241010-b4-master-24-11-25-ov08x40-v6-4-cf966e34e685@linaro.org
One of us will have to rebase for this change.
---
bod
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] media: ov08x40: Move fwnode_property_read_u32("clock-frequency") call down
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
0 siblings, 1 reply; 6+ messages in thread
From: Sakari Ailus @ 2024-11-01 11:20 UTC (permalink / raw)
To: Bryan O'Donoghue, Hans de Goede
Cc: Jason Chen, Mauro Carvalho Chehab, linux-media
On Sat, Oct 12, 2024 at 04:10:14PM +0100, Bryan O'Donoghue wrote:
> 20241010-b4-master-24-11-25-ov08x40-v6-4-cf966e34e685@linaro.org
Hans: could you rebase this, please? Bryan's set has been out for quite
some time (and now in my tree, devel branch).
--
Sakari Ailus
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] media: ov08x40: Move fwnode_property_read_u32("clock-frequency") call down
2024-11-01 11:20 ` Sakari Ailus
@ 2024-11-06 21:57 ` Hans de Goede
0 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2024-11-06 21:57 UTC (permalink / raw)
To: Sakari Ailus, Bryan O'Donoghue
Cc: Jason Chen, Mauro Carvalho Chehab, linux-media
Hi,
On 1-Nov-24 12:20 PM, Sakari Ailus wrote:
> On Sat, Oct 12, 2024 at 04:10:14PM +0100, Bryan O'Donoghue wrote:
>> 20241010-b4-master-24-11-25-ov08x40-v6-4-cf966e34e685@linaro.org
>
> Hans: could you rebase this, please? Bryan's set has been out for quite
> some time (and now in my tree, devel branch).
Ack will do. I'm still waiting for testing feedback anyways
since I don't have a laptop with this sensor myself.
Regards,
Hans
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-06 21:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-12 11:52 [PATCH 1/2] media: ov08x40: Move fwnode_property_read_u32("clock-frequency") call down Hans de Goede
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox