From patchwork Mon Apr 6 22:57:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 6166251 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 931B79F399 for ; Mon, 6 Apr 2015 22:59:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BAA7B202F8 for ; Mon, 6 Apr 2015 22:59:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C605820364 for ; Mon, 6 Apr 2015 22:59:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752751AbbDFW7K (ORCPT ); Mon, 6 Apr 2015 18:59:10 -0400 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:37698 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752784AbbDFW7B (ORCPT ); Mon, 6 Apr 2015 18:59:01 -0400 Received: from lanttu.localdomain (lanttu.localdomain [192.168.5.64]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id 485636009C; Tue, 7 Apr 2015 01:58: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 v3 2/4] v4l: of: Instead of zeroing bus_type and bus field separately, unify this Date: Tue, 7 Apr 2015 01:57:30 +0300 Message-Id: <1428361053-20411-3-git-send-email-sakari.ailus@iki.fi> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1428361053-20411-1-git-send-email-sakari.ailus@iki.fi> References: <1428361053-20411-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=unavailable 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 Clean 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 --- 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..5bbdfbf 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 cleaned by v4l2_of_parse_endpoint() */ enum v4l2_mbus_type bus_type; union { struct v4l2_of_bus_parallel parallel;