From patchwork Mon Feb 12 09:44:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 127963 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3040564ljc; Mon, 12 Feb 2018 01:46:15 -0800 (PST) X-Google-Smtp-Source: AH8x226DXofmAjCf3SSnJs6AI+fYpQD7XxHAP9NsuOEWtwhDpwezoKco4B6OolUe4nATakbwo0K1 X-Received: by 10.99.96.137 with SMTP id u131mr9124566pgb.103.1518428775108; Mon, 12 Feb 2018 01:46:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518428775; cv=none; d=google.com; s=arc-20160816; b=iW+3b2/pU/AQjoe6VtgJLy84QWVjZxuX5cZpEbyq7jVKYhlcoPHodZ2kzDm7cKLWfX gE+CTG6Vbb0aBEWeNS/XurwCYrzh7yxTByK6LoGquN4QwMWMVO6LoHG6zB69GrvpbdVW qEfSkupYGaN27VaYnWOUvTLkHMizanjTn86TkF/gopeL9N1IlircgC0mRkk2Lifpsm0X I/W2oXs1F7ofkt8BIs7A0IrpTdrrqTFfJvportFMkjMvhDnl92WpajPqRNP1y5Hy22/o +Bj58JheezNsY6dxrGczETLd5dSJiXnO0dVvN51Jo6ZtTCgSq+BqnM/5gCLlycJJp9ij EXaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to :arc-authentication-results; bh=iJZDKRrqLCwZUSrK5cuI09gW5LR76uz4+Sy12Ze3jIo=; b=L3BBXIPsPKQri4e/e3sfbXVzkOU9vr76ifftlRAWgzx/BItcswXVEAdKY79yvZADz4 PFjxCSiphO70Ly+l7Ppxjfi7rBa9x7c75fwxEgCDf85tfbaje8NGeyk0W/5R+1rY4aoz IbS9Z9ybHuftzNPJVwIyon3Ud8o1QmbK8304+A1jDJRUKEMBu7gC6/2jNTlgR9EKgh7e /IYVXgKwmv7QHzoBWCZv5BnJndwV1F560ypmsbGRoDg3ywMzb17/h1DdzevPcAYjWvNX dqG+2FyXaKsftn8WwqWphuPvESn/1ytTDGzSAQmYCsguw0T5W+aKk57Z9qefJU9a8dRl pXFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=jUHow3wv; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id w74si5453249pfj.89.2018.02.12.01.46.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 01:46:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=jUHow3wv; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A5E586E17C; Mon, 12 Feb 2018 09:45:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelnx194.ext.ti.com (lelnx194.ext.ti.com [198.47.27.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id E8D6F6E164 for ; Mon, 12 Feb 2018 09:45:19 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id w1C9jHM9007801; Mon, 12 Feb 2018 03:45:17 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1518428717; bh=kVmT8/MWH6dewBrnN25F39d2MtzqI3WKIb5UVpD6pr0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=jUHow3wvDX3NWO98ub81SNcYYVGJ+OS4qdsWzdZDVvqq2obGxa/IAswQUwASWtBd6 MEOJT9eZkV4ZNF7qzkp7Hcppd/tYX5DfGse+KCSlKJRmbJo+zAYBzUDrTpUhBW2aJI qQ/HbUJft9E3bqFtM2exdJ7hOMOW9dTmckrdKBHM= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1C9jHWD019658; Mon, 12 Feb 2018 03:45:17 -0600 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Mon, 12 Feb 2018 03:45:17 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Mon, 12 Feb 2018 03:45:17 -0600 Received: from deskari.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1C9j0N5003439; Mon, 12 Feb 2018 03:45:15 -0600 From: Tomi Valkeinen To: , Laurent Pinchart , Peter Ujfalusi , Jyri Sarha , Benoit Parrot Subject: [PATCH 08/24] drm/omap: Separate the dssdevs array setup from the connect function Date: Mon, 12 Feb 2018 11:44:38 +0200 Message-ID: <1518428694-18018-9-git-send-email-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518428694-18018-1-git-send-email-tomi.valkeinen@ti.com> References: <1518428694-18018-1-git-send-email-tomi.valkeinen@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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: Tomi Valkeinen Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Peter Ujfalusi In order to ease up on the logic, break the current code to gather the dssdevs: first get all available dssdevs, then call connect on each dssdev. As the last step remove the dssdevs which failed to connect from the available dssdev list. Signed-off-by: Peter Ujfalusi Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/omap_drv.c | 54 ++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 869a8ab6aa4e..b5061fc7241a 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -165,34 +165,60 @@ static void omap_disconnect_dssdevs(struct drm_device *ddev) priv->num_dssdevs = 0; } -static int omap_connect_dssdevs(struct drm_device *ddev) +static void omap_collect_dssdevs(struct drm_device *ddev) { struct omap_drm_private *priv = ddev->dev_private; struct omap_dss_device *dssdev = NULL; - int r; + + for_each_dss_dev(dssdev) { + omap_dss_get_device(dssdev); + priv->dssdevs[priv->num_dssdevs++] = dssdev; + if (priv->num_dssdevs == ARRAY_SIZE(priv->dssdevs)) { + /* To balance the 'for_each_dss_dev' loop */ + omap_dss_put_device(dssdev); + break; + } + } +} + +static int omap_connect_dssdevs(struct drm_device *ddev) +{ + struct omap_drm_private *priv = ddev->dev_private; + u32 working = 0; + int r, i, j; if (!omapdss_stack_is_ready()) return -EPROBE_DEFER; - for_each_dss_dev(dssdev) { + omap_collect_dssdevs(ddev); + + for (i = 0; i < priv->num_dssdevs; i++) { + struct omap_dss_device *dssdev = priv->dssdevs[i]; + r = dssdev->driver->connect(dssdev); - if (r == -EPROBE_DEFER) { - omap_dss_put_device(dssdev); + if (r == -EPROBE_DEFER) goto cleanup; - } else if (r) { + else if (r) dev_warn(dssdev->dev, "could not connect display: %s\n", - dssdev->name); + dssdev->name); + else + working |= BIT(i); + } + + /* Remove the dssdevs if their connect failed */ + j = 0; + for (i = 0; i < priv->num_dssdevs; i++) { + if (working & BIT(i)) { + if (j != i) + priv->dssdevs[j] = priv->dssdevs[i]; + j++; } else { - omap_dss_get_device(dssdev); - priv->dssdevs[priv->num_dssdevs++] = dssdev; - if (priv->num_dssdevs == ARRAY_SIZE(priv->dssdevs)) { - /* To balance the 'for_each_dss_dev' loop */ - omap_dss_put_device(dssdev); - break; - } + omap_dss_put_device(priv->dssdevs[i]); } } + priv->num_dssdevs = j; + return 0; cleanup: