media: ov08x40: Move fwnode_property_read_u32("clock-frequency") call down
PATCH 1/2 media: ov08x40: Move fwnode_property_read_u32("clock-frequency") call down
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.
--- drivers/media/i2c/ov08x40.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)
drivers/media/i2c/ov08x40.c +18 -17
@@ -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);
Signature · 1 line
2.47.0
PATCH 2/2 media: ov08x40: Add missing '\n' to ov08x40_check_hwcfg() error messages
Add '\n' to the dev_err() error messages printed on ov08x40_check_hwcfg() errors.
--- drivers/media/i2c/ov08x40.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/i2c/ov08x40.c +4 -4
@@ -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; }
Signature · 1 line
2.47.0
Re: [PATCH 2/2] media: ov08x40: Add missing '\n' to ov08x40_check_hwcfg() error messages
Quoted 39 lines · Hans de Goede
Add '\n' to the
dev_err()error messages printed onov08x40_check_hwcfg()errors.Signed-off-by Hans de Goede <[email protected]>--- drivers/media/i2c/ov08x40.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/media/i2c/ov08x40.c +3
-3@@ -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;
drivers/media/i2c/ov08x40.c static int ov08x40_probe(struct i2c_client *client) · line 2135
Quoted 8 lines
drivers/media/i2c/ov08x40.c +1
-1@@ -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; }
Quoted 60 lines · Hans de Goede
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 thefwnode_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 todev_err_probe()for logging when it fails so that the error code gets logged.Signed-off-by Hans de Goede <[email protected]>--- drivers/media/i2c/ov08x40.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)drivers/media/i2c/ov08x40.c +11
-17@@ -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; + }
drivers/media/i2c/ov08x40.c static int ov08x40_check_hwcfg(struct device *dev) · line 2091
Quoted 10 lines
drivers/media/i2c/ov08x40.c +7
-0+ +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);
One of us will have to rebase for this change.
---
bod
Sakari Ailus
maintainerQuoted 1 line · Bryan O'Donoghue
Hans: could you rebase this, please? Bryan's set has been out for quite some time (and now in my tree, devel branch).
Signature · 1 line
Sakari Ailus
Hi,
Quoted 5 lines · Sakari Ailus
Quoted 1 line · Bryan O'Donoghue
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