Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp571442rwd; Wed, 7 Jun 2023 04:13:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7iijpHtVAmDuKvxysLuCJv2DyZJQmFS6DYTJUgLI+V5BfBy1dAskt5wutn+bynblV7kH6Z X-Received: by 2002:a05:6a20:958c:b0:117:b923:5106 with SMTP id iu12-20020a056a20958c00b00117b9235106mr761728pzb.43.1686136387878; Wed, 07 Jun 2023 04:13:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686136387; cv=none; d=google.com; s=arc-20160816; b=pWOeQ+pKvuGH3q558DpLvkEkMkUwCq4tfzL9hf9OdLlFlWimOdhJK/cMm4HzvPH+lf hIb+boQvJtYJ+JIrhkz6CGrcBElinPLuSsG7fArvDKKLz5qTEzPQWVEO8gdhOBX1MLLR 2dz/FoswNp1N2ZzUNWNKcalI6sUO8vGvrcGKgAI9sa5LzggVY/J/OsJSjyuNFzqeq/yg UlHXMfyM6xY6879YZkxd3ccx6Zu744xB0BFvF35ZWQbRyErLc0xIcG08JMHf3YhICkzl ziEsLqWR1UXlZeANjw0sVHrXrWMmAmb07Ruqr9wf7Bt9zUmD5DlP0muf4F/tPA+VYuBu 71Cw== 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=gu+G2RgbBkLbR88sRNXzxRmjiuWLF2/Tmpx3T3EINKI=; b=ax185L0YKL8LOXCHm/CZaa0MyefLujmguVW2Wh2Hl/Efn/lcl99F9c63k3Ri072B1r 1ZGiBX4L2g9Xryp0SZ+nWxp3fTxPlKixTJLhEgv18nLEu80ZQYHca0f8H1ekeepHU6ip wX85+osoCloM4TJt3AFpqNmNv7y9dFPZbJyLe5B0YDE8uvf7WfmaNZtYWQk0FHQ5TgJp Jee3nGkR58CM9S0kPLDVZqCIrUrhzhQrOU013M1DMBrCR7CFIO6h3Qw5BC9W9VCzoZk1 EPGeBuv0+nUTxUmfOLxAJf2XBuoZQ7cLcW2/i0JtxSZhTrUiK5DznRAs5f3N/pENqaig eLkg== 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 c15-20020a170902d48f00b001b231cb6f2bsi2828953plg.313.2023.06.07.04.12.51; Wed, 07 Jun 2023 04:13:07 -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 S239970AbjFGK4s (ORCPT + 99 others); Wed, 7 Jun 2023 06:56:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239885AbjFGK4Q (ORCPT ); Wed, 7 Jun 2023 06:56:16 -0400 Received: from 189.cn (ptr.189.cn [183.61.185.102]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1581D192 for ; Wed, 7 Jun 2023 03:56:15 -0700 (PDT) HMM_SOURCE_IP: 10.64.8.31:55208.1520123491 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-114.242.206.180 (unknown [10.64.8.31]) by 189.cn (HERMES) with SMTP id BBE501002CE; Wed, 7 Jun 2023 18:56:13 +0800 (CST) Received: from ([114.242.206.180]) by gateway-151646-dep-75648544bd-xp9j7 with ESMTP id 2d6665bc324c466abda1ee67f04d8d7e for l.stach@pengutronix.de; Wed, 07 Jun 2023 18:56:14 CST X-Transaction-ID: 2d6665bc324c466abda1ee67f04d8d7e 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 , Li Yi Cc: linux-kernel@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Sui Jingfeng , Philipp Zabel , Bjorn Helgaas Subject: [PATCH v8 8/8] drm/etnaviv: add a dedicated function to create the virtual master Date: Wed, 7 Jun 2023 18:55:51 +0800 Message-Id: <20230607105551.568639-9-15330273260@189.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230607105551.568639-1-15330273260@189.cn> References: <20230607105551.568639-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,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 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 d7e7498826f5..6f2260a76433 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -769,10 +769,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(); @@ -790,22 +812,9 @@ static int __init etnaviv_init(void) goto unregister_platform_driver; #endif - /* - * 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