[media] v4l: of: Instead of zeroing bus_type and bus field separately, unify this
authorSakari Ailus <sakari.ailus@iki.fi>
Sun, 22 Mar 2015 20:42:31 +0000 (17:42 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 27 Apr 2015 18:43:52 +0000 (15:43 -0300)
Zero the entire struct starting from bus_type. As more fields are added, no
changes will be needed in the function to reset their value explicitly.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/v4l2-core/v4l2-of.c
include/media/v4l2-of.h

index 83143d39dea760d1120f6bf7d2fa309a147a2189..3ac634891f756933cf7aee4c2ce3388d6eb3415a 100644 (file)
@@ -149,8 +149,9 @@ int v4l2_of_parse_endpoint(const struct device_node *node,
        int rval;
 
        of_graph_parse_endpoint(node, &endpoint->base);
-       endpoint->bus_type = 0;
-       memset(&endpoint->bus, 0, sizeof(endpoint->bus));
+       /* Zero fields from bus_type to until the end */
+       memset(&endpoint->bus_type, 0, sizeof(*endpoint) -
+              offsetof(typeof(*endpoint), bus_type));
 
        rval = v4l2_of_parse_csi_bus(node, endpoint);
        if (rval)
index f66b92cc866909cb6632ac4bbe2dc3be6e70b725..6c85c079544f4f8dff366d63386caa13ce8034ef 100644 (file)
@@ -60,6 +60,7 @@ struct v4l2_of_bus_parallel {
  */
 struct v4l2_of_endpoint {
        struct of_endpoint base;
+       /* Fields below this line will be zeroed by v4l2_of_parse_endpoint() */
        enum v4l2_mbus_type bus_type;
        union {
                struct v4l2_of_bus_parallel parallel;