From patchwork Wed Sep 12 21:29:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 10598391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2690E14DB for ; Wed, 12 Sep 2018 21:30:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16FAD2ACA2 for ; Wed, 12 Sep 2018 21:30:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B7B32ACAB; Wed, 12 Sep 2018 21:30:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B5EF92ACA2 for ; Wed, 12 Sep 2018 21:30:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9AB636E4F3; Wed, 12 Sep 2018 21:30:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from hillosipuli.retiisi.org.uk (hillosipuli.retiisi.org.uk [IPv6:2001:1bc8:1a6:d3d5::81:2]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6DC7C6E4FE for ; Wed, 12 Sep 2018 21:29:49 +0000 (UTC) Received: from lanttu.localdomain (lanttu-e.localdomain [192.168.1.64]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id 8AC4A634C92; Thu, 13 Sep 2018 00:29:43 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Subject: [PATCH v3 11/23] v4l: fwnode: Only assign configuration if there is no error Date: Thu, 13 Sep 2018 00:29:30 +0300 Message-Id: <20180912212942.19641-12-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180912212942.19641-1-sakari.ailus@linux.intel.com> References: <20180912212942.19641-1-sakari.ailus@linux.intel.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, jacopo@jmondi.org, dri-devel@lists.freedesktop.org, slongerbeam@gmail.com, niklas.soderlund@ragnatech.se MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Only assign endpoint configuration if the endpoint is parsed successfully. Signed-off-by: Sakari Ailus Tested-by: Steve Longerbeam --- drivers/media/v4l2-core/v4l2-fwnode.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c index cb0b12eefe7f..1ec7590b18bd 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c @@ -47,7 +47,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, enum v4l2_fwnode_bus_type bus_type) { struct v4l2_fwnode_bus_mipi_csi2 *bus = &vep->bus.mipi_csi2; - bool have_clk_lane = false; + bool have_clk_lane = false, have_lane_polarities = false; unsigned int flags = 0, lanes_used = 0; u32 array[1 + V4L2_FWNODE_CSI2_MAX_DATA_LANES]; unsigned int num_data_lanes = 0; @@ -73,7 +73,6 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, array[i]); lanes_used |= BIT(array[i]); - bus->data_lanes[i] = array[i]; pr_debug("lane %u position %u\n", i, array[i]); } } @@ -87,16 +86,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, return -EINVAL; } - fwnode_property_read_u32_array(fwnode, "lane-polarities", array, - 1 + num_data_lanes); - - for (i = 0; i < 1 + num_data_lanes; i++) { - bus->lane_polarities[i] = array[i]; - pr_debug("lane %u polarity %sinverted", - i, array[i] ? "" : "not "); - } - } else { - pr_debug("no lane polarities defined, assuming not inverted\n"); + have_lane_polarities = true; } if (!fwnode_property_read_u32(fwnode, "clock-lanes", &v)) { @@ -121,6 +111,22 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, bus->flags = flags; vep->bus_type = V4L2_MBUS_CSI2_DPHY; bus->num_data_lanes = num_data_lanes; + for (i = 0; i < num_data_lanes; i++) + bus->data_lanes[i] = array[i]; + + if (have_lane_polarities) { + fwnode_property_read_u32_array(fwnode, + "lane-polarities", array, + 1 + num_data_lanes); + + for (i = 0; i < 1 + num_data_lanes; i++) { + bus->lane_polarities[i] = array[i]; + pr_debug("lane %u polarity %sinverted", + i, array[i] ? "" : "not "); + } + } else { + pr_debug("no lane polarities defined, assuming not inverted\n"); + } } return 0;