From nobody Tue Feb 10 16:18:30 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7189C7EE23 for ; Wed, 7 Jun 2023 10:56:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239982AbjFGK4t (ORCPT ); Wed, 7 Jun 2023 06:56:49 -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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/etnavi= v/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 pl= atform_device **ppdev) *ppdev =3D NULL; } =20 +static int etnaviv_create_virtual_master(void) +{ + struct platform_device **master =3D &etnaviv_platform_device; + struct device_node *np; + + /* + * If the DT contains at least one available GPU device, instantiate + * the DRM platform device. + */ + np =3D etnaviv_of_first_available_node(); + if (np) { + int ret; + + of_node_put(np); + + ret =3D etnaviv_create_platform_device("etnaviv", master); + if (ret) + return ret; + } + + return 0; +} + static int __init etnaviv_init(void) { int ret; - struct device_node *np; =20 etnaviv_validate_init(); =20 @@ -790,22 +812,9 @@ static int __init etnaviv_init(void) goto unregister_platform_driver; #endif =20 - /* - * 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 =3D etnaviv_create_platform_device("etnaviv", - &etnaviv_platform_device); - if (ret) - goto unregister_platform_driver; - - break; - } + ret =3D etnaviv_create_virtual_master(); + if (ret) + goto unregister_platform_driver; =20 return ret; =20 --=20 2.25.1