Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1678558pxb; Mon, 23 Aug 2021 01:50:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVdpuyeMiAQihPTZ4nTc94w82DyLXGC75JHpCcIl2KP6CIj3RdTc0qnMsp2fiW3cGaL3OE X-Received: by 2002:a05:6e02:78d:: with SMTP id q13mr22388056ils.262.1629708619811; Mon, 23 Aug 2021 01:50:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629708619; cv=none; d=google.com; s=arc-20160816; b=jtCP5Xq59Ww0QPSKv38mv1JjyB+akJQne9SEY4t1aNKYQh40Zp9c9ntJm7N0LdxiOy tQ5NeK9k09y29txhUTXm0/hQRzKZ6o9QzsaD8moHRaOhbKtKQ6XfYVwhbb9NcLD7FOav JpuAs2vpqPaFDscdGyT0MZiJs1z6k1mrA9c0HfVPYxdQVO8iFNykheAZmSySbHsI1W/U U5yGJTDFHkrJs1ttZ+TFtbGKdqIu3e2+MuKiiOeIu/LhvS/MHQmUo0DUpVEaErgZ8M4N l0AuFMAKgAkc6VY/pJRAeg5cvuKQWcOuiE+BHyW+qgT+QtA4skaKDKncpKxo/7nwgnFQ WslQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=QEg7Vp8gCjMDXhvK4uZ6lD3DQNesVKp5J6Tnbairaz8=; b=ImlPRhBthZUdHp/Fcf5jZ8+nM0CABmK0Z+TR0UtRMo/ai2+CYMKMmgi4iZFxQuDt5U /CuGcXOonvXzbRrQz5jO3wecH/tmqOO+nJ9xu+SWfSGNERLEAT3wi4RmGaY47KAf0Bdk FhW5rWmEKyiu6EuEC4XT37NXdz5kj+I0631ljUZvWdkAxAd/llR7gxGS3zWkawT68cFQ kkDX0uyZjRJiA7xzbFz5XvHQh8WQOpfNLkVekFINZLrjs+T1DVAOfEnRlXwjnXJFPwnH 3LepAnnq/qOwx/axlcr1UYOw6Kn4G2Gf6mATw6W041peuTqGO5Z5TPMTuWktOwzal/uK ms7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=0vzzcRaa; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=ZvLUJ0gN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p14si14701984ilo.31.2021.08.23.01.50.09; Mon, 23 Aug 2021 01:50:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=0vzzcRaa; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=ZvLUJ0gN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235785AbhHWIsn (ORCPT + 99 others); Mon, 23 Aug 2021 04:48:43 -0400 Received: from new2-smtp.messagingengine.com ([66.111.4.224]:50165 "EHLO new2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235766AbhHWIsd (ORCPT ); Mon, 23 Aug 2021 04:48:33 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 67C56580C67; Mon, 23 Aug 2021 04:47:50 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 23 Aug 2021 04:47:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=QEg7Vp8gCjMDX hvK4uZ6lD3DQNesVKp5J6Tnbairaz8=; b=0vzzcRaawN90SVLYfNwd8T+dAdW2+ NR5OWaThZchQK6iPu+4SvBwSv+6f3uVIlVUODHk+TE7s31aRxf5Kf1Q/rhS+yXRC sCjUE9Re1DbA+7K49HmgkSKflElrQBskdFiRU3HMK/+prWoTif6iozvwmamtJIu+ bVEMabWrPuSusquuf6pQ6Ag8yHY/+SawUxl8s4zN7i5TQaD4AtrsVGPV5YnMDuR7 tNbRjjxnRBU+DuA7otf92PsxthRhmzbPsC73vh2Bx5Nj2FyVwbuSMZoWxJCGKupY qOl0tErhpy9pWNCEcwB/DaofbZeQjRHR7IeV3hxglkUxFxc3c+xHLS46Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=QEg7Vp8gCjMDXhvK4uZ6lD3DQNesVKp5J6Tnbairaz8=; b=ZvLUJ0gN iz5kR7wzYQj9NKD5lfU10T+LEio36Fvk0maroQFGx3+tFSKVvvReb66/1lbIB4Dj i8Q+lK81HhgDtRTZnJDo4eVQ3ReK99kpX5eKI5kAf2yRWxL1y++XZ8YVkIGFsCkL yCcvwF1GU9/g+asunStUqnVBm2Y2ZZ691371hpUGEhDFckcKNpvFEE96qVruvdwL SWDkIp8s+y5zieqlsNjn1I4+J0O+H4USBf2DRUt8hagTe0FjyimByWsbtjkLsMfD gmlV9AW5rj6RsiWLS7emKLTCYK0zOk5TG91S+Qe5R0X4iQtHuy00880g4jK+1lCA U2Qn2SaEepbqMA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddthedgtdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmh grgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 23 Aug 2021 04:47:49 -0400 (EDT) From: Maxime Ripard To: Jonas Karlman , Sam Ravnborg , Jernej Skrabec , Thierry Reding , Daniel Vetter , David Airlie , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Neil Armstrong , Laurent Pinchart , Robert Foss , Andrzej Hajda Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH v3 8/8] drm/bridge: sn65dsi83: Register and attach our DSI device at probe Date: Mon, 23 Aug 2021 10:47:23 +0200 Message-Id: <20210823084723.1493908-9-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210823084723.1493908-1-maxime@cerno.tech> References: <20210823084723.1493908-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to avoid any probe ordering issue, the best practice is to move the secondary MIPI-DSI device registration and attachment to the MIPI-DSI host at probe time. Let's do this. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/ti-sn65dsi83.c | 76 +++++++++++++++------------ 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c index db4d39082705..3a75224b7348 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c @@ -245,40 +245,6 @@ static int sn65dsi83_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { struct sn65dsi83 *ctx = bridge_to_sn65dsi83(bridge); - struct device *dev = ctx->dev; - struct mipi_dsi_device *dsi; - struct mipi_dsi_host *host; - int ret = 0; - - const struct mipi_dsi_device_info info = { - .type = "sn65dsi83", - .channel = 0, - .node = NULL, - }; - - host = of_find_mipi_dsi_host_by_node(ctx->host_node); - if (!host) { - dev_err(dev, "failed to find dsi host\n"); - return -EPROBE_DEFER; - } - - dsi = devm_mipi_dsi_device_register_full(dev, host, &info); - if (IS_ERR(dsi)) { - return dev_err_probe(dev, PTR_ERR(dsi), - "failed to create dsi device\n"); - } - - ctx->dsi = dsi; - - dsi->lanes = ctx->dsi_lanes; - dsi->format = MIPI_DSI_FMT_RGB888; - dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST; - - ret = devm_mipi_dsi_attach(dev, dsi); - if (ret < 0) { - dev_err(dev, "failed to attach dsi to host\n"); - return ret; - } return drm_bridge_attach(bridge->encoder, ctx->panel_bridge, &ctx->bridge, flags); @@ -646,6 +612,44 @@ static int sn65dsi83_parse_dt(struct sn65dsi83 *ctx, enum sn65dsi83_model model) return 0; } +static int sn65dsi83_host_attach(struct sn65dsi83 *ctx) +{ + struct device *dev = ctx->dev; + struct mipi_dsi_device *dsi; + struct mipi_dsi_host *host; + const struct mipi_dsi_device_info info = { + .type = "sn65dsi83", + .channel = 0, + .node = NULL, + }; + int ret; + + host = of_find_mipi_dsi_host_by_node(ctx->host_node); + if (!host) { + dev_err(dev, "failed to find dsi host\n"); + return -EPROBE_DEFER; + } + + dsi = devm_mipi_dsi_device_register_full(dev, host, &info); + if (IS_ERR(dsi)) + return dev_err_probe(dev, PTR_ERR(dsi), + "failed to create dsi device\n"); + + ctx->dsi = dsi; + + dsi->lanes = ctx->dsi_lanes; + dsi->format = MIPI_DSI_FMT_RGB888; + dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST; + + ret = devm_mipi_dsi_attach(dev, dsi); + if (ret < 0) { + dev_err(dev, "failed to attach dsi to host: %d\n", ret); + return ret; + } + + return 0; +} + static int sn65dsi83_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -686,6 +690,10 @@ static int sn65dsi83_probe(struct i2c_client *client, ctx->bridge.of_node = dev->of_node; drm_bridge_add(&ctx->bridge); + ret = sn65dsi83_host_attach(ctx); + if (ret) + return ret; + return 0; } -- 2.31.1