Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4912114pxu; Thu, 10 Dec 2020 08:20:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFxujdJJtFccKcl7LW9O+oRluYmM6d0VJO4uO90QKiPUlaWh4ZXr7OXurzJx13XOZbhMqj X-Received: by 2002:a05:6402:48d:: with SMTP id k13mr7469654edv.92.1607617245663; Thu, 10 Dec 2020 08:20:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607617245; cv=none; d=google.com; s=arc-20160816; b=FCgnnq2niMLmlIyDdPPGGh5YY3k4NoIsrtXufw4WflgFLjEHU1f2pBTaM9Jy1GIhwZ clxt35q7obU8zGJdQhNTUQp3zW/8uW18oMDnAXPEx7qcwn7b+SDt6uyDD41LFMJjN08U uHY02BCenTBDrlwehFT7JBSKDjXlAawBuwOxa3LI6ht+wddIizjjyCtZk6Z9fquvVZMc y3TsErhgrOGIwwJ+yGF6yzanKPyfo5kYaaCs2PkRCY9pO5tnGjN3M26WWQh+zUgNLVr1 ZL0jajIqWCjeVrvYg6J9SD9drnPgaSBo7K+AEatvfiEyl3VK43pf40BI+ilqhNCIHzHv /pzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=IJgU8F79k5rMKEdc+VG6xYSyq5NKNP6MvVmJn26Y4n4=; b=Tfpu13n7ClAkC/bGwxzqQ7pG7Mr+CtvvaBI7oDUywNWY+itaiqfL5ON2udZpzgJwBu XxDoPzpmTwve4PTCdvjIqwCTEhlZGXwTXXB/fqfz3I+i6qocaxZheN3wkgLZ66lkZNAp WBB5sn7fFhxzO0qtgjOJKfaGIPKX9TXnr1RPdt3kakwYzqnuNzBAZyuXuY/EqXq2h08V ph8VVGdFl8Ov+uj46j4l6x2BhrYoBOOn4Mxf1sOD8clmrTWD6krXGg1rCGqRxB6FoojJ 2NhuPHvQn4p1Hpqve1zp5lrDbk+fpCJpx5NmWpXN308L53PIIEirQqjxOxrGcNooRgd0 2+lw== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id no7si2800384ejb.586.2020.12.10.08.20.22; Thu, 10 Dec 2020 08:20:45 -0800 (PST) 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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392228AbgLJQMU (ORCPT + 99 others); Thu, 10 Dec 2020 11:12:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:38856 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388558AbgLJQLo (ORCPT ); Thu, 10 Dec 2020 11:11:44 -0500 From: Chun-Kuang Hu Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: Philipp Zabel , David Airlie , Daniel Vetter Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, CK Hu , Chun-Kuang Hu Subject: [PATCH v2 03/12] drm/mediatek: Separate getting larb device to a function Date: Fri, 11 Dec 2020 00:10:41 +0800 Message-Id: <20201210161050.8460-4-chunkuang.hu@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201210161050.8460-1-chunkuang.hu@kernel.org> References: <20201210161050.8460-1-chunkuang.hu@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: CK Hu To make the code cleaner, separate getting larb device to a function. Signed-off-by: CK Hu Signed-off-by: Chun-Kuang Hu --- drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 57 ++++++++++++--------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c index 1730b3ddef70..a11b4f8bf959 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c @@ -465,19 +465,41 @@ unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm, return ret; } +static int mtk_ddp_get_larb_dev(struct device_node *node, struct mtk_ddp_comp *comp, + struct device *dev) +{ + struct device_node *larb_node; + struct platform_device *larb_pdev; + + larb_node = of_parse_phandle(node, "mediatek,larb", 0); + if (!larb_node) { + dev_err(dev, "Missing mediadek,larb phandle in %pOF node\n", node); + return -EINVAL; + } + + larb_pdev = of_find_device_by_node(larb_node); + if (!larb_pdev) { + dev_warn(dev, "Waiting for larb device %pOF\n", larb_node); + of_node_put(larb_node); + return -EPROBE_DEFER; + } + of_node_put(larb_node); + comp->larb_dev = &larb_pdev->dev; + + return 0; +} + int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id comp_id, const struct mtk_ddp_comp_funcs *funcs) { struct platform_device *comp_pdev; struct device *dev; enum mtk_ddp_comp_type type; - struct device_node *larb_node; - struct platform_device *larb_pdev; #if IS_REACHABLE(CONFIG_MTK_CMDQ) struct resource res; struct cmdq_client_reg cmdq_reg; - int ret; #endif + int ret; if (comp_id < 0 || comp_id >= DDP_COMPONENT_ID_MAX) return -EINVAL; @@ -529,30 +551,15 @@ int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp, #endif /* Only DMA capable components need the LARB property */ - comp->larb_dev = NULL; - if (type != MTK_DISP_OVL && - type != MTK_DISP_OVL_2L && - type != MTK_DISP_RDMA && - type != MTK_DISP_WDMA) - return 0; - - larb_node = of_parse_phandle(node, "mediatek,larb", 0); - if (!larb_node) { - dev_err(dev, - "Missing mediadek,larb phandle in %pOF node\n", node); - return -EINVAL; + if (type == MTK_DISP_OVL || + type == MTK_DISP_OVL_2L || + type == MTK_DISP_RDMA || + type == MTK_DISP_WDMA) { + ret = mtk_ddp_get_larb_dev(node, comp, dev); + if (ret) + return ret; } - larb_pdev = of_find_device_by_node(larb_node); - if (!larb_pdev) { - dev_warn(dev, "Waiting for larb device %pOF\n", larb_node); - of_node_put(larb_node); - return -EPROBE_DEFER; - } - of_node_put(larb_node); - - comp->larb_dev = &larb_pdev->dev; - return 0; } -- 2.17.1