diff mbox

[v4,2/4] v4l: of: Instead of zeroing bus_type and bus field separately, unify this

Message ID 1428614706-8367-3-git-send-email-sakari.ailus@iki.fi (mailing list archive)
State New, archived
Headers show

Commit Message

Sakari Ailus April 9, 2015, 9:25 p.m. UTC
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>
---
 drivers/media/v4l2-core/v4l2-of.c |    5 +++--
 include/media/v4l2-of.h           |    1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

Comments

On 09/04/15 23:25, Sakari Ailus wrote:
> 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>

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lad, Prabhakar April 10, 2015, 10:16 p.m. UTC | #2
Hi Sakari,

Thanks for the patch.

On Thu, Apr 9, 2015 at 10:25 PM, Sakari Ailus <sakari.ailus@iki.fi> wrote:
> 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: Lad, Prabhakar <prabhakar.csengg@gmail.com>

Cheers,
--Prabhakar Lad

> ---
>  drivers/media/v4l2-core/v4l2-of.c |    5 +++--
>  include/media/v4l2-of.h           |    1 +
>  2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c
> index 83143d3..3ac6348 100644
> --- a/drivers/media/v4l2-core/v4l2-of.c
> +++ b/drivers/media/v4l2-core/v4l2-of.c
> @@ -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)
> diff --git a/include/media/v4l2-of.h b/include/media/v4l2-of.h
> index f66b92c..6c85c07 100644
> --- a/include/media/v4l2-of.h
> +++ b/include/media/v4l2-of.h
> @@ -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;
> --
> 1.7.10.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c
index 83143d3..3ac6348 100644
--- a/drivers/media/v4l2-core/v4l2-of.c
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -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)
diff --git a/include/media/v4l2-of.h b/include/media/v4l2-of.h
index f66b92c..6c85c07 100644
--- a/include/media/v4l2-of.h
+++ b/include/media/v4l2-of.h
@@ -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;