From patchwork Mon Mar 23 09:53:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 6071321 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 3F1999F318 for ; Mon, 23 Mar 2015 09:54:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BCBBE20253 for ; Mon, 23 Mar 2015 09:54:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EA0EA2024F for ; Mon, 23 Mar 2015 09:54:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752102AbbCWJyh (ORCPT ); Mon, 23 Mar 2015 05:54:37 -0400 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:55600 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752013AbbCWJyg (ORCPT ); Mon, 23 Mar 2015 05:54:36 -0400 Received: from lanttu.localdomain (lanttu.localdomain [192.168.5.64]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id C0C8360098; Mon, 23 Mar 2015 11:54:31 +0200 (EET) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: g.liakhovetski@gmx.de, laurent.pinchart@ideasonboard.com, s.nawrocki@samsung.com Subject: [PATCH v2 RESEND 2/4] v4l: of: Instead of zeroing bus_type and bus field separately, unify this Date: Mon, 23 Mar 2015 11:53:45 +0200 Message-Id: <1427104427-19911-3-git-send-email-sakari.ailus@iki.fi> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1427104427-19911-1-git-send-email-sakari.ailus@iki.fi> References: <1427104427-19911-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 --- 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 b4ed9a9..1c3e398 100644 --- a/drivers/media/v4l2-core/v4l2-of.c +++ b/drivers/media/v4l2-core/v4l2-of.c @@ -128,8 +128,9 @@ int v4l2_of_parse_endpoint(const struct device_node *node, struct v4l2_of_endpoint *endpoint) { 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)); v4l2_of_parse_csi_bus(node, endpoint); /* diff --git a/include/media/v4l2-of.h b/include/media/v4l2-of.h index dc468de..00eec26 100644 --- a/include/media/v4l2-of.h +++ b/include/media/v4l2-of.h @@ -57,6 +57,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;