Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6322389rwd; Mon, 19 Jun 2023 05:51:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6VwhVBCzy9gtpcV2VUSU/WUuzC53fitQXtq4CQpjU6sb1cRoXyaaI+ePgkkbcWNJuqrLCG X-Received: by 2002:a17:902:db0c:b0:1b3:c48d:1c9 with SMTP id m12-20020a170902db0c00b001b3c48d01c9mr5884399plx.66.1687179083702; Mon, 19 Jun 2023 05:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687179083; cv=none; d=google.com; s=arc-20160816; b=enwrjwwlXRnu7iqzhy46xQUO/UQ/EuRJj9+FmCKg87Jx2AaQ+yZfTqdLDiv/aBR3d9 A8Z2fBSflGuZv7KHe5yVPBBXc4hEBrkeoNi37a2aInFff90xTDDpNB1HrjwF5t1g0G6z x+GYPnz0EPeWdAceCdvAFKqiVKp7gyJcvrV6XaMo/Q6n35xU8mIrya0G8OtnPTDfnjyj 0VVdrdBqq7ACAstvbRfIcA34U25qwNZqOE9R/cJnAj5svNorC3G6cjp0at+FqG/u3xTi 1JTetc7qo/W7fGVGwgOn/9AFKkJWlzf4g7B/Cf770OnOiev6yxBUBR49BOvFiRsZI6gj XSfw== 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:sender :hmm_source_type:hmm_attache_num:hmm_source_ip; bh=fMpVZgPH13LrQj2/yL5QuaQCk1eUSXIciYTrYInC9Vk=; b=xpFPPfgpz+lKK3e2f61bgA1JfLRYbesXhtKcQbUJG2G4Jf4SJk19A03ySpqRZfkQit UEWe0xfebiY9Xskqd/U8a2X1xn3T8B9H4fMYl0yawedpaL8bMqNcBA6Cdpc8zIaOXJ4l xrIbro2OIGkd4uQ1an3of81FPh7/ZIwhxFrD4DcwclVnpV83tjAZEIUKsv1txJtYosK+ ZX7/Sxhn2fes2bsJDZdq6FU88bRADC2UYeV5LbxviBmKMEDr9jNqoHZuuznvO9pdk3zS c1xRnhQymbRLCAantyO1K/A28DTqGxmm1ZGxnntJXkSWt0Bky9v7yZw3NWoPNvABWARi yckw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o8-20020a170902d4c800b001b668cf7162si1423224plg.401.2023.06.19.05.51.06; Mon, 19 Jun 2023 05:51:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231145AbjFSMml (ORCPT + 99 others); Mon, 19 Jun 2023 08:42:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230253AbjFSMmW (ORCPT ); Mon, 19 Jun 2023 08:42:22 -0400 Received: from 189.cn (ptr.189.cn [183.61.185.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6D695E66 for ; Mon, 19 Jun 2023 05:42:18 -0700 (PDT) HMM_SOURCE_IP: 10.64.8.41:49634.708654646 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-114.242.206.180 (unknown [10.64.8.41]) by 189.cn (HERMES) with SMTP id 1F5C710298A; Mon, 19 Jun 2023 20:42:16 +0800 (CST) Received: from ([114.242.206.180]) by gateway-151646-dep-75648544bd-xwndj with ESMTP id 8a8114871d834566bbad2466a63a610f for l.stach@pengutronix.de; Mon, 19 Jun 2023 20:42:18 CST X-Transaction-ID: 8a8114871d834566bbad2466a63a610f X-Real-From: 15330273260@189.cn X-Receive-IP: 114.242.206.180 X-MEDUSA-Status: 0 Sender: 15330273260@189.cn From: Sui Jingfeng <15330273260@189.cn> To: Lucas Stach , Russell King , Christian Gmeiner , David Airlie , Daniel Vetter Cc: linux-kernel@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Sui Jingfeng , Philipp Zabel , Bjorn Helgaas Subject: [PATCH v10 08/11] drm/etnaviv: Add a dedicated function to create the virtual master Date: Mon, 19 Jun 2023 20:41:58 +0800 Message-Id: <20230619124201.2215558-9-15330273260@189.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230619124201.2215558-1-15330273260@189.cn> References: <20230619124201.2215558-1-15330273260@189.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=1.7 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,FROM_LOCAL_DIGITS, FROM_LOCAL_HEX,RCVD_IN_SBL_CSS,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sui Jingfeng After introducing the etnaviv_of_first_available_node() helper, the creation of the virtual master platform device can also be simplified. So, switch to etnaviv_create_virtual_master() function. Cc: Lucas Stach Cc: Christian Gmeiner Cc: Philipp Zabel Cc: Bjorn Helgaas Cc: Daniel Vetter Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 43 ++++++++++++++++----------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index d8e788aa16cb..47b2cdbb53e2 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -767,10 +767,32 @@ static void etnaviv_destroy_platform_device(struct platform_device **ppdev) *ppdev = NULL; } +static int etnaviv_create_virtual_master(void) +{ + struct platform_device **master = &etnaviv_platform_device; + struct device_node *np; + + /* + * If the DT contains at least one available GPU device, instantiate + * the DRM platform device. + */ + np = etnaviv_of_first_available_node(); + if (np) { + int ret; + + of_node_put(np); + + ret = etnaviv_create_platform_device("etnaviv", master); + if (ret) + return ret; + } + + return 0; +} + static int __init etnaviv_init(void) { int ret; - struct device_node *np; etnaviv_validate_init(); @@ -786,22 +808,9 @@ static int __init etnaviv_init(void) if (ret != 0) goto unregister_platform_driver; - /* - * If the DT contains at least one available GPU device, instantiate - * the DRM platform device. - */ - for_each_compatible_node(np, NULL, "vivante,gc") { - if (!of_device_is_available(np)) - continue; - of_node_put(np); - - ret = etnaviv_create_platform_device("etnaviv", - &etnaviv_platform_device); - if (ret) - goto unregister_platform_driver; - - break; - } + ret = etnaviv_create_virtual_master(); + if (ret) + goto unregister_platform_driver; return ret; -- 2.25.1