]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: v4l2-fwnode: Return -EPROBE_DEFER on parsing NULL endpoints
authorSakari Ailus <sakari.ailus@linux.intel.com>
Wed, 4 Mar 2026 22:16:10 +0000 (00:16 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Tue, 24 Mar 2026 10:58:02 +0000 (11:58 +0100)
In general drivers get their firmware graph endpoints from system
firmware, but on some systems this information is conveyed to drivers via
software nodes. The software nodes may be instantiated only after the
drivers are first probed, requiring drivers to explicitly issue
-EPROBE_DEFER when endpoints aren't found.

Instead of doing this in all (or at least most) drivers, make v4l2-fwnode
endpoint parsing functions v4l2_fwnode_endpoint_parse() and
v4l2_fwnode_endpoint_alloc_parse() return -EPROBE_DEFER when an endpoint
is NULL.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/v4l2-core/v4l2-fwnode.c
include/media/v4l2-fwnode.h

index 03daa8c4ff7a81850724363350089607e08d5e1d..77f3298821b5c6a3e1843b6dbfb0f26f63f3386a 100644 (file)
@@ -465,8 +465,15 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
        enum v4l2_mbus_type mbus_type;
        int rval;
 
+       /*
+        * Return -EPROBE_DEFER if there's no endpoint -- in case the endpoint's
+        * origin is a software node, it may be that the endpoint has not been
+        * instantiated yet, but will be with probing of another driver. This is
+        * the case with the IPU bridge; once we have no such cases left, return
+        * another error such as -EINVAL.
+        */
        if (!fwnode)
-               return -EINVAL;
+               return -EPROBE_DEFER;
 
        pr_debug("===== begin parsing endpoint %pfw\n", fwnode);
 
index cd82e70ccbaa96312df9b02c9d4308b5d530a097..d7abbd76a421fcba3faec6b63a2029fbf3360826 100644 (file)
@@ -218,8 +218,9 @@ enum v4l2_fwnode_bus_type {
  *
  * Return: %0 on success or a negative error code on failure:
  *        %-ENOMEM on memory allocation failure
- *        %-EINVAL on parsing failure, including @fwnode == NULL
+ *        %-EINVAL on parsing failure
  *        %-ENXIO on mismatching bus types
+ *        %-EPROBE_DEFER on NULL @fwnode
  */
 int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
                               struct v4l2_fwnode_endpoint *vep);
@@ -276,8 +277,9 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep);
  *
  * Return: %0 on success or a negative error code on failure:
  *        %-ENOMEM on memory allocation failure
- *        %-EINVAL on parsing failure, including @fwnode == NULL
+ *        %-EINVAL on parsing failure
  *        %-ENXIO on mismatching bus types
+ *        %-EPROBE_DEFER on NULL @fwnode
  */
 int v4l2_fwnode_endpoint_alloc_parse(struct fwnode_handle *fwnode,
                                     struct v4l2_fwnode_endpoint *vep);