public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/2] media: ov2680: Clear the 'ret' variable on success
@ 2024-03-28 22:44 Fabio Estevam
  2024-03-28 22:44 ` [PATCH v3 2/2] media: ov2680: Allow probing if link-frequencies is absent Fabio Estevam
  0 siblings, 1 reply; 3+ messages in thread
From: Fabio Estevam @ 2024-03-28 22:44 UTC (permalink / raw)
  To: sakari.ailus
  Cc: hdegoede, rmfrfs, laurent.pinchart, linux-media, Fabio Estevam,
	stable

From: Fabio Estevam <festevam@denx.de>

Since commit 63b0cd30b78e ("media: ov2680: Add bus-cfg / endpoint
property verification") even when the correct 'link-frequencies'
property is passed in the devicetree, the driver fails to probe:

ov2680 1-0036: probe with driver ov2680 failed with error -22

The reason is that the variable 'ret' may contain the -EINVAL value
from a previous assignment:

ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency",
			       &rate);

Fix the problem by clearing 'ret' on the successful path.

Tested on imx7s-warp board with the following devicetree:

port {
	ov2680_to_mipi: endpoint {
		remote-endpoint = <&mipi_from_sensor>;
		clock-lanes = <0>;
		data-lanes = <1>;
		link-frequencies = /bits/ 64 <330000000>;
	};
};

Cc: stable@vger.kernel.org
Fixes: 63b0cd30b78e ("media: ov2680: Add bus-cfg / endpoint property verification")
Suggested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
Changes since v2:
- Collected Hans' Reviewed-by tag.

 drivers/media/i2c/ov2680.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c
index 39d321e2b7f9..3e3b7c2b492c 100644
--- a/drivers/media/i2c/ov2680.c
+++ b/drivers/media/i2c/ov2680.c
@@ -1135,6 +1135,7 @@ static int ov2680_parse_dt(struct ov2680_dev *sensor)
 		goto out_free_bus_cfg;
 	}
 
+	ret = 0;
 out_free_bus_cfg:
 	v4l2_fwnode_endpoint_free(&bus_cfg);
 	return ret;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v3 2/2]  media: ov2680: Allow probing if link-frequencies is absent
  2024-03-28 22:44 [PATCH v3 1/2] media: ov2680: Clear the 'ret' variable on success Fabio Estevam
@ 2024-03-28 22:44 ` Fabio Estevam
  2024-03-29 11:33   ` Hans de Goede
  0 siblings, 1 reply; 3+ messages in thread
From: Fabio Estevam @ 2024-03-28 22:44 UTC (permalink / raw)
  To: sakari.ailus
  Cc: hdegoede, rmfrfs, laurent.pinchart, linux-media, Fabio Estevam,
	stable

From: Fabio Estevam <festevam@denx.de>

Since commit 63b0cd30b78e ("media: ov2680: Add bus-cfg / endpoint
property verification") the ov2680 no longer probes on a imx7s-warp7:

ov2680 1-0036: error -EINVAL: supported link freq 330000000 not found
ov2680 1-0036: probe with driver ov2680 failed with error -22

As the 'link-frequencies' property is not mandatory, allow the probe
to succeed by skipping the link-frequency verification when the
property is absent.

Cc: stable@vger.kernel.org
Fixes: 63b0cd30b78e ("media: ov2680: Add bus-cfg / endpoint property verification")
Signed-off-by: Fabio Estevam <festevam@denx.de>
---
Changes since v2:
- Fix memory leak and print a warning if 'link-frequencies' is absent. (Laurent)

 drivers/media/i2c/ov2680.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c
index 3e3b7c2b492c..a857763c7984 100644
--- a/drivers/media/i2c/ov2680.c
+++ b/drivers/media/i2c/ov2680.c
@@ -1123,18 +1123,23 @@ static int ov2680_parse_dt(struct ov2680_dev *sensor)
 		goto out_free_bus_cfg;
 	}
 
+	if (!bus_cfg.nr_of_link_frequencies) {
+		dev_warn(dev, "Consider passing 'link-frequencies' in DT\n");
+		goto skip_link_freq_validation;
+	}
+
 	for (i = 0; i < bus_cfg.nr_of_link_frequencies; i++)
 		if (bus_cfg.link_frequencies[i] == sensor->link_freq[0])
 			break;
 
-	if (bus_cfg.nr_of_link_frequencies == 0 ||
-	    bus_cfg.nr_of_link_frequencies == i) {
+	if (bus_cfg.nr_of_link_frequencies == i) {
 		ret = dev_err_probe(dev, -EINVAL,
 				    "supported link freq %lld not found\n",
 				    sensor->link_freq[0]);
 		goto out_free_bus_cfg;
 	}
 
+skip_link_freq_validation:
 	ret = 0;
 out_free_bus_cfg:
 	v4l2_fwnode_endpoint_free(&bus_cfg);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 2/2] media: ov2680: Allow probing if link-frequencies is absent
  2024-03-28 22:44 ` [PATCH v3 2/2] media: ov2680: Allow probing if link-frequencies is absent Fabio Estevam
@ 2024-03-29 11:33   ` Hans de Goede
  0 siblings, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2024-03-29 11:33 UTC (permalink / raw)
  To: Fabio Estevam, sakari.ailus
  Cc: rmfrfs, laurent.pinchart, linux-media, Fabio Estevam, stable

Hi,

On 3/28/24 11:44 PM, Fabio Estevam wrote:
> From: Fabio Estevam <festevam@denx.de>
> 
> Since commit 63b0cd30b78e ("media: ov2680: Add bus-cfg / endpoint
> property verification") the ov2680 no longer probes on a imx7s-warp7:
> 
> ov2680 1-0036: error -EINVAL: supported link freq 330000000 not found
> ov2680 1-0036: probe with driver ov2680 failed with error -22
> 
> As the 'link-frequencies' property is not mandatory, allow the probe
> to succeed by skipping the link-frequency verification when the
> property is absent.
> 
> Cc: stable@vger.kernel.org
> Fixes: 63b0cd30b78e ("media: ov2680: Add bus-cfg / endpoint property verification")
> Signed-off-by: Fabio Estevam <festevam@denx.de>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
> Changes since v2:
> - Fix memory leak and print a warning if 'link-frequencies' is absent. (Laurent)
> 
>  drivers/media/i2c/ov2680.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c
> index 3e3b7c2b492c..a857763c7984 100644
> --- a/drivers/media/i2c/ov2680.c
> +++ b/drivers/media/i2c/ov2680.c
> @@ -1123,18 +1123,23 @@ static int ov2680_parse_dt(struct ov2680_dev *sensor)
>  		goto out_free_bus_cfg;
>  	}
>  
> +	if (!bus_cfg.nr_of_link_frequencies) {
> +		dev_warn(dev, "Consider passing 'link-frequencies' in DT\n");
> +		goto skip_link_freq_validation;
> +	}
> +
>  	for (i = 0; i < bus_cfg.nr_of_link_frequencies; i++)
>  		if (bus_cfg.link_frequencies[i] == sensor->link_freq[0])
>  			break;
>  
> -	if (bus_cfg.nr_of_link_frequencies == 0 ||
> -	    bus_cfg.nr_of_link_frequencies == i) {
> +	if (bus_cfg.nr_of_link_frequencies == i) {
>  		ret = dev_err_probe(dev, -EINVAL,
>  				    "supported link freq %lld not found\n",
>  				    sensor->link_freq[0]);
>  		goto out_free_bus_cfg;
>  	}
>  
> +skip_link_freq_validation:
>  	ret = 0;
>  out_free_bus_cfg:
>  	v4l2_fwnode_endpoint_free(&bus_cfg);


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-29 11:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-28 22:44 [PATCH v3 1/2] media: ov2680: Clear the 'ret' variable on success Fabio Estevam
2024-03-28 22:44 ` [PATCH v3 2/2] media: ov2680: Allow probing if link-frequencies is absent Fabio Estevam
2024-03-29 11:33   ` 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