From patchwork Wed Jun 7 10:55:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng <15330273260@189.cn> X-Patchwork-Id: 104412 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp166890vqr; Wed, 7 Jun 2023 04:00:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6HQwKPJRVDUDt97sn6lUorByQqaaYQM1vNnzJfywvwn25XrGw/vu0kyqDovo7IjiYL2Bn2 X-Received: by 2002:a05:6808:8d8:b0:38c:5a32:325b with SMTP id k24-20020a05680808d800b0038c5a32325bmr5194065oij.41.1686135601795; Wed, 07 Jun 2023 04:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686135601; cv=none; d=google.com; s=arc-20160816; b=DDFwzlg81Dn4Ja3IWDm7kh/LF15V5uTUIxYpjO2VuRZzbo/8oHj/JPGXZwn1WNYIkl jD+udKFJR3S3fjBslpARMRaOl1U57p5//mGz6h+XycunV7k661pf5QCG45ZoTJXwm+rB UVVRnCnA3C/SYD7vkSoZFgkpS8SSGbNcwFIkDyzTuK4IEJ+lOAAAOaBHi2K2pYYfDFAO 0ua9Pimm9/oqiBLzw6diE/RrhgUk6PikJqry6Bq81m2dwuiwZKcBNh5PfCOpv3V/rH6f uXoYWxWLSoNTd/5GEJnjNTURsVd4GkWj0+wtKHSvGlOJ8/1JwWArqFKFmHiUPIW0WnS0 40qg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x8-20020a170902b40800b001afb96f4b8fsi8672665plr.519.2023.06.07.03.59.49; Wed, 07 Jun 2023 04:00:01 -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 S239975AbjFGK4s (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768041325039595217?= X-GMAIL-MSGID: =?utf-8?q?1768041325039595217?= 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;