aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrieder Schrempf <[email protected]>2023-02-15 18:16:38 +0100
committerHans Verkuil <[email protected]>2023-04-11 18:11:53 +0200
commita56b3e151e30da1f71fcb0b5726bb592ee4e30b6 (patch)
treebcb2f563a4708d18f9f2701e078c9267f2d396c3
parent7cfb35d3a80029d1fa697d6fe5a5e89990b5c508 (diff)
media: imx: imx7-media-csi: Fix error handling in imx7_csi_async_register()
The CSI requires a connected source subdev to operate. If fwnode_graph_get_endpoint_by_id() fails and returns NULL, there is no point in going on. Print an error message and abort instead. Also we don't need to check for an existing asd. Any failure of v4l2_async_nf_add_fwnode_remote() should abort the probe. Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Frieder Schrempf <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Laurent Pinchart <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
-rw-r--r--drivers/media/platform/nxp/imx7-media-csi.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
index 9ee46c17bd02..cc468b3daed3 100644
--- a/drivers/media/platform/nxp/imx7-media-csi.c
+++ b/drivers/media/platform/nxp/imx7-media-csi.c
@@ -2107,18 +2107,21 @@ static int imx7_csi_async_register(struct imx7_csi *csi)
ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(csi->dev), 0, 0,
FWNODE_GRAPH_ENDPOINT_NEXT);
- if (ep) {
- asd = v4l2_async_nf_add_fwnode_remote(&csi->notifier, ep,
- struct v4l2_async_subdev);
+ if (!ep) {
+ ret = dev_err_probe(csi->dev, -ENOTCONN,
+ "Failed to get remote endpoint\n");
+ goto error;
+ }
- fwnode_handle_put(ep);
+ asd = v4l2_async_nf_add_fwnode_remote(&csi->notifier, ep,
+ struct v4l2_async_subdev);
- if (IS_ERR(asd)) {
- ret = PTR_ERR(asd);
- /* OK if asd already exists */
- if (ret != -EEXIST)
- goto error;
- }
+ fwnode_handle_put(ep);
+
+ if (IS_ERR(asd)) {
+ ret = dev_err_probe(csi->dev, PTR_ERR(asd),
+ "Failed to add remote subdev to notifier\n");
+ goto error;
}
csi->notifier.ops = &imx7_csi_notify_ops;