Skip to contentSkip to conversation

media: ov2680: Clear the 'ret' variable on success

PATCH Superseded Fabio Estevam 2 participants 2 messages Mar 28, 2024

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 media: ov2680: Clear the 'ret' variable on success

From: Fabio Estevam <[email protected]>

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>;
	};
};
Fixes 63b0cd30b78e ("media: ov2680: Add bus-cfg / endpoint property verification")

---
Changes since v1:
- Use Hans' suggestion to clear 'ret'.

 drivers/media/i2c/ov2680.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/i2c/ov2680.c +1 -0
index 39d321e2b7f9..3e3b7c2b492c 100644
@@ -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;
Signature · 1 line
2.34.1
Reviewed-by on v2 1/1
#1 lore raw

Hi,

Quoted 27 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

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>;
	};
};
Quoted 4 lines
Fixes 63b0cd30b78e ("media: ov2680: Add bus-cfg / endpoint property verification")

Thanks, patch looks good to me:

Regards,

Hans

Quoted 19 lines

---
Changes since v1:
- Use Hans' suggestion to clear 'ret'.

 drivers/media/i2c/ov2680.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/i2c/ov2680.c +1 -0
index 39d321e2b7f9..3e3b7c2b492c 100644
@@ -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;