Skip to content

Commit

Permalink
media: v4l2-fwnode: Return -EINVAL for invalid bus-type
Browse files Browse the repository at this point in the history
Return -EINVAL if invalid bus-type is detected while parsing endpoints.

Fixes: 26c1126 ("media: v4l: fwnode: Use media bus type for bus parser selection")
Signed-off-by: Lad Prabhakar <[email protected]>
Signed-off-by: Sakari Ailus <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
prabhakarlad authored and mchehab committed Nov 16, 2020
1 parent 57a9755 commit 69baf33
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/media/v4l2-core/v4l2-fwnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ v4l2_fwnode_bus_type_to_mbus(enum v4l2_fwnode_bus_type type)
const struct v4l2_fwnode_bus_conv *conv =
get_v4l2_fwnode_bus_conv_by_fwnode_bus(type);

return conv ? conv->mbus_type : V4L2_MBUS_UNKNOWN;
return conv ? conv->mbus_type : V4L2_MBUS_INVALID;
}

static const char *
Expand Down Expand Up @@ -436,6 +436,10 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
v4l2_fwnode_mbus_type_to_string(vep->bus_type),
vep->bus_type);
mbus_type = v4l2_fwnode_bus_type_to_mbus(bus_type);
if (mbus_type == V4L2_MBUS_INVALID) {
pr_debug("unsupported bus type %u\n", bus_type);
return -EINVAL;
}

if (vep->bus_type != V4L2_MBUS_UNKNOWN) {
if (mbus_type != V4L2_MBUS_UNKNOWN &&
Expand Down
2 changes: 2 additions & 0 deletions include/media/v4l2-mediabus.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
* @V4L2_MBUS_CCP2: CCP2 (Compact Camera Port 2)
* @V4L2_MBUS_CSI2_DPHY: MIPI CSI-2 serial interface, with D-PHY
* @V4L2_MBUS_CSI2_CPHY: MIPI CSI-2 serial interface, with C-PHY
* @V4L2_MBUS_INVALID: invalid bus type (keep as last)
*/
enum v4l2_mbus_type {
V4L2_MBUS_UNKNOWN,
Expand All @@ -112,6 +113,7 @@ enum v4l2_mbus_type {
V4L2_MBUS_CCP2,
V4L2_MBUS_CSI2_DPHY,
V4L2_MBUS_CSI2_CPHY,
V4L2_MBUS_INVALID,
};

/**
Expand Down

0 comments on commit 69baf33

Please sign in to comment.