summaryrefslogtreecommitdiff
path: root/drivers/media/v4l2-core/v4l2-fwnode.c
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2018-07-31 05:21:53 -0400
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-10-04 16:21:02 -0400
commit9a5b4b76f3be34980571d11dce509a564c938318 (patch)
tree48d14c57aa832c1b2a341b1c7c01c97e62a008fe /drivers/media/v4l2-core/v4l2-fwnode.c
parent60359a28d59278e2a9e7558c15dc7be518d9beb8 (diff)
media: v4l: fwnode: Only zero the struct if bus type is set to V4L2_MBUS_UNKNOWN
In order to prepare for allowing drivers to set the defaults for a given bus, make zeroing the struct conditional based on detecting the bus. All callers now set the bus type to zero which allows only zeroing the remaining bus union. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Tested-by: Steve Longerbeam <steve_longerbeam@mentor.com> Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/v4l2-core/v4l2-fwnode.c')
-rw-r--r--drivers/media/v4l2-core/v4l2-fwnode.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
index 5f3bb3d1191c..f224b6c42c10 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -301,6 +301,12 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
u32 bus_type = 0;
int rval;
+ if (vep->bus_type == V4L2_MBUS_UNKNOWN) {
+ /* Zero fields from bus union to until the end */
+ memset(&vep->bus, 0,
+ sizeof(*vep) - offsetof(typeof(*vep), bus));
+ }
+
pr_debug("===== begin V4L2 endpoint properties\n");
/*
@@ -309,10 +315,6 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
*/
memset(&vep->base, 0, sizeof(vep->base));
- /* Zero fields from bus_type to until the end */
- memset(&vep->bus_type, 0, sizeof(*vep) -
- offsetof(typeof(*vep), bus_type));
-
fwnode_property_read_u32(fwnode, "bus-type", &bus_type);
switch (bus_type) {