From patchwork Thu Apr 9 21:25:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 6190871 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0DD59BF4A6 for ; Thu, 9 Apr 2015 21:26:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2B1C620395 for ; Thu, 9 Apr 2015 21:26:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B88BE2034F for ; Thu, 9 Apr 2015 21:26:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753470AbbDIV0G (ORCPT ); Thu, 9 Apr 2015 17:26:06 -0400 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:40199 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753396AbbDIV0E (ORCPT ); Thu, 9 Apr 2015 17:26:04 -0400 Received: from lanttu.localdomain (lanttu.localdomain [192.168.5.64]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id 4F3F7600A0; Fri, 10 Apr 2015 00:25:58 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: g.liakhovetski@gmx.de, laurent.pinchart@ideasonboard.com, s.nawrocki@samsung.com Subject: [PATCH v4 2/4] v4l: of: Instead of zeroing bus_type and bus field separately, unify this Date: Fri, 10 Apr 2015 00:25:04 +0300 Message-Id: <1428614706-8367-3-git-send-email-sakari.ailus@iki.fi> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1428614706-8367-1-git-send-email-sakari.ailus@iki.fi> References: <1428614706-8367-1-git-send-email-sakari.ailus@iki.fi> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Laurent Pinchart Acked-by: Sylwester Nawrocki Acked-by: Lad, Prabhakar --- 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;