media: v4l2-fwnode: Allow passing NULL fwnode to endpoint parsers
Subsystems (2)
Sakari Ailus
maintainerPATCH v2 1/1 media: v4l2-fwnode: Allow passing NULL fwnode to endpoint parsers
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.
---
since v1:
- Explicitly mention @fwnode == NULL case for -EINVAL
drivers/media/v4l2-core/v4l2-fwnode.c | 3 +++ include/media/v4l2-fwnode.h | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/media/v4l2-core/v4l2-fwnode.c +3 -0
@@ -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);
include/media/v4l2-fwnode.h +4 -4
@@ -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,
Signature · 1 line
2.47.3
Hi Sakari,
Thanks for the patch and for addressing my comment!
Quoted 6 lines · Sakari Ailus
v4l2_fwnode_endpoint_parse()andv4l2_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 <[email protected]>
Best regards,
Michael
Quoted 63 lines
---
since v1:- Explicitly mention @fwnode == NULL case for
-EINVALdrivers/media/v4l2-core/v4l2-fwnode.c | 3 +++ include/media/v4l2-fwnode.h | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-)drivers/media/v4l2-core/v4l2-fwnode.c +3
-0@@ -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);include/media/v4l2-fwnode.h +4
-4@@ -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,