]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: v4l2-fwnode: Allow passing NULL fwnode to endpoint parsers
authorSakari Ailus <sakari.ailus@linux.intel.com>
Wed, 12 Nov 2025 07:57:57 +0000 (09:57 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 14 Jan 2026 22:33:02 +0000 (23:33 +0100)
v4l2_fwnode_endpoint_parse() and v4l2_fwnode_endpoint_alloc_parse() take
a fwnode as the first argument and leave it up to the caller to check a
valid fwnode has been obtained through various means. Instead, add a check
here so the callers won't need to do that anymore.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Michael Riesch <michael.riesch@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/v4l2-core/v4l2-fwnode.c
include/media/v4l2-fwnode.h

index cb153ce42c45d69600a3ec4e59a5584d7e791a2a..22ec702a456742934957ae7748fee46f5598dfb3 100644 (file)
@@ -465,6 +465,9 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
        enum v4l2_mbus_type mbus_type;
        int rval;
 
+       if (!fwnode)
+               return -EINVAL;
+
        pr_debug("===== begin parsing endpoint %pfw\n", fwnode);
 
        fwnode_property_read_u32(fwnode, "bus-type", &bus_type);
index f7c57c7765898da635ac1893577d5edd2e3bf69a..cd82e70ccbaa96312df9b02c9d4308b5d530a097 100644 (file)
@@ -182,7 +182,7 @@ enum v4l2_fwnode_bus_type {
 
 /**
  * v4l2_fwnode_endpoint_parse() - parse all fwnode node properties
- * @fwnode: pointer to the endpoint's fwnode handle
+ * @fwnode: pointer to the endpoint's fwnode handle (may be NULL)
  * @vep: pointer to the V4L2 fwnode data structure
  *
  * This function parses the V4L2 fwnode endpoint specific parameters from the
@@ -218,7 +218,7 @@ 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
+ *        %-EINVAL on parsing failure, including @fwnode == NULL
  *        %-ENXIO on mismatching bus types
  */
 int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
@@ -236,7 +236,7 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep);
 
 /**
  * v4l2_fwnode_endpoint_alloc_parse() - parse all fwnode node properties
- * @fwnode: pointer to the endpoint's fwnode handle
+ * @fwnode: pointer to the endpoint's fwnode handle (may be NULL)
  * @vep: pointer to the V4L2 fwnode data structure
  *
  * This function parses the V4L2 fwnode endpoint specific parameters from the
@@ -276,7 +276,7 @@ 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
+ *        %-EINVAL on parsing failure, including @fwnode == NULL
  *        %-ENXIO on mismatching bus types
  */
 int v4l2_fwnode_endpoint_alloc_parse(struct fwnode_handle *fwnode,