Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1202971imj; Thu, 14 Feb 2019 02:56:43 -0800 (PST) X-Google-Smtp-Source: AHgI3IbbtsaDjbWcp1DrrTIHU5+j3s43c80DNkYG9/sacwT/s/G25qgz/2ko+3MJM1VUxffQ/Ibe X-Received: by 2002:a62:445a:: with SMTP id r87mr3331787pfa.13.1550141803172; Thu, 14 Feb 2019 02:56:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550141803; cv=none; d=google.com; s=arc-20160816; b=g5q6y9AgjZd11YGMLz87aN7XfNdA/tLrtTOJYL5MwXOfZVkKjGF2b5RNWg/1QTdbQC Q+tNodWCdF0wYrRu3Cnq6+xZM1oWUAEXAMXwUPl+TIvguAmlTb2iYZwVQui1bdy5qqQi hIrv1LFn7zZAHDvLb621qO+WzmZ2AQfLMPdrTRdvd7kH+j+SsrTZ94Mbz7GyiJGtS/Wi L4heN7panJbkV0sb01kWNy+YsemKh1liAKu2yVD30ygC7gMnljBUeBPnaRNVV92Lw5jf Qhb6W7nmCvEn1fwglObhfpbxMW6PJkLyzoJaZIWU5APF+LUoDmWA5omqJK2i7/CwwFI+ nj+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=EWx02DadoMsiyWPAHAQYOZkP1agrMtSncQoZHRXtZOc=; b=AEzbJnwGBQwsyGbinP9e3kLhTwYz3XpxN223ziOOKl5UaD2Hj/U9U1FVNxYWcKB9Ay S68Vuk/8rROgsEAVHxXbe6WbxT4gVWaeFOjJBdwwvklSYADVGSGaV5k/bwDHh9f0Jt/e KagJF+SqDnhBvxNdej5QcA2XIJUAG/yarzpLRqhyQxxV90RK0vVdQEBSCkKbLftNuVwa dYuGsXzruY/oQbTiPruxJOVFflVMaKkMoIResVed3MvZak8oicRpLIbe00+yn2xU7vr1 4VY7eKGuO4NZHIEqixJoQArulWY75jv29W3IYN/aMn8Fu3daMIsJ268oTVCDcSGw0QMr aABw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n5si2202388pgc.563.2019.02.14.02.56.27; Thu, 14 Feb 2019 02:56:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394341AbfBNEm5 (ORCPT + 99 others); Wed, 13 Feb 2019 23:42:57 -0500 Received: from Mailgw01.mediatek.com ([1.203.163.78]:51229 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727763AbfBNEm5 (ORCPT ); Wed, 13 Feb 2019 23:42:57 -0500 X-UUID: ad40ba9941264bd1bdd90f0a73efd555-20190214 X-UUID: ad40ba9941264bd1bdd90f0a73efd555-20190214 Received: from mtkcas36.mediatek.inc [(172.27.4.250)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 759461771; Thu, 14 Feb 2019 12:42:48 +0800 Received: from MTKCAS32.mediatek.inc (172.27.4.184) by MTKMBS33DR.mediatek.inc (172.27.6.106) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 14 Feb 2019 12:42:46 +0800 Received: from mszsdclx1018.gcn.mediatek.inc (10.16.6.18) by MTKCAS32.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Thu, 14 Feb 2019 12:42:45 +0800 From: Jitao Shi To: Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , , David Airlie , Matthias Brugger , CC: Jitao Shi , Thierry Reding , Ajay Kumar , Inki Dae , Rahul Sharma , Sean Paul , Vincent Palatin , Andy Yan , Philipp Zabel , Russell King , , , , , , , Sascha Hauer , , , , , , Subject: [PATCH 1/3] drm/mediatek: move mipi_dsi_host_register to probe Date: Thu, 14 Feb 2019 12:42:41 +0800 Message-ID: <20190214044243.129920-1-jitao.shi@mediatek.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org DSI panel driver need attach function which is inculde in mipi_dsi_host_ops. If mipi_dsi_host_register is not in probe, dsi panel will probe fail or more delay. So move the mipi_dsi_host_register to probe from bind. Signed-off-by: Jitao Shi --- drivers/gpu/drm/mediatek/mtk_dsi.c | 49 ++++++++++++++++++------------ 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index 27b507eb4a99..93fa255b4aad 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -1045,12 +1045,6 @@ static int mtk_dsi_bind(struct device *dev, struct device *master, void *data) return ret; } - ret = mipi_dsi_host_register(&dsi->host); - if (ret < 0) { - dev_err(dev, "failed to register DSI host: %d\n", ret); - goto err_ddp_comp_unregister; - } - ret = mtk_dsi_create_conn_enc(drm, dsi); if (ret) { DRM_ERROR("Encoder create failed with %d\n", ret); @@ -1060,8 +1054,6 @@ static int mtk_dsi_bind(struct device *dev, struct device *master, void *data) return 0; err_unregister: - mipi_dsi_host_unregister(&dsi->host); -err_ddp_comp_unregister: mtk_ddp_comp_unregister(drm, &dsi->ddp_comp); return ret; } @@ -1097,31 +1089,37 @@ static int mtk_dsi_probe(struct platform_device *pdev) dsi->host.ops = &mtk_dsi_ops; dsi->host.dev = dev; + dsi->dev = dev; + ret = mipi_dsi_host_register(&dsi->host); + if (ret < 0) { + dev_err(dev, "failed to register DSI host: %d\n", ret); + return -EPROBE_DEFER; + } ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0, &dsi->panel, &dsi->bridge); if (ret) - return ret; + goto err_unregister_host; dsi->engine_clk = devm_clk_get(dev, "engine"); if (IS_ERR(dsi->engine_clk)) { ret = PTR_ERR(dsi->engine_clk); dev_err(dev, "Failed to get engine clock: %d\n", ret); - return ret; + goto err_unregister_host; } dsi->digital_clk = devm_clk_get(dev, "digital"); if (IS_ERR(dsi->digital_clk)) { ret = PTR_ERR(dsi->digital_clk); dev_err(dev, "Failed to get digital clock: %d\n", ret); - return ret; + goto err_unregister_host; } dsi->hs_clk = devm_clk_get(dev, "hs"); if (IS_ERR(dsi->hs_clk)) { ret = PTR_ERR(dsi->hs_clk); dev_err(dev, "Failed to get hs clock: %d\n", ret); - return ret; + goto err_unregister_host; } regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -1129,33 +1127,35 @@ static int mtk_dsi_probe(struct platform_device *pdev) if (IS_ERR(dsi->regs)) { ret = PTR_ERR(dsi->regs); dev_err(dev, "Failed to ioremap memory: %d\n", ret); - return ret; + goto err_unregister_host; } dsi->phy = devm_phy_get(dev, "dphy"); if (IS_ERR(dsi->phy)) { ret = PTR_ERR(dsi->phy); dev_err(dev, "Failed to get MIPI-DPHY: %d\n", ret); - return ret; + goto err_unregister_host; } comp_id = mtk_ddp_comp_get_id(dev->of_node, MTK_DSI); if (comp_id < 0) { dev_err(dev, "Failed to identify by alias: %d\n", comp_id); - return comp_id; + ret = comp_id; + goto err_unregister_host; } ret = mtk_ddp_comp_init(dev, dev->of_node, &dsi->ddp_comp, comp_id, &mtk_dsi_funcs); if (ret) { dev_err(dev, "Failed to initialize component: %d\n", ret); - return ret; + goto err_unregister_host; } irq_num = platform_get_irq(pdev, 0); if (irq_num < 0) { dev_err(&pdev->dev, "failed to request dsi irq resource\n"); - return -EPROBE_DEFER; + ret = -EPROBE_DEFER; + goto err_unregister_host; } irq_set_status_flags(irq_num, IRQ_TYPE_LEVEL_LOW); @@ -1163,14 +1163,25 @@ static int mtk_dsi_probe(struct platform_device *pdev) IRQF_TRIGGER_LOW, dev_name(&pdev->dev), dsi); if (ret) { dev_err(&pdev->dev, "failed to request mediatek dsi irq\n"); - return -EPROBE_DEFER; + ret = -EPROBE_DEFER; + goto err_unregister_host; } init_waitqueue_head(&dsi->irq_wait_queue); platform_set_drvdata(pdev, dsi); - return component_add(&pdev->dev, &mtk_dsi_component_ops); + ret = component_add(&pdev->dev, &mtk_dsi_component_ops); + if (ret) { + ret = -EPROBE_DEFER; + goto err_unregister_host; + } + + return 0; + +err_unregister_host: + mipi_dsi_host_unregister(&dsi->host); + return ret; } static int mtk_dsi_remove(struct platform_device *pdev) -- 2.20.1