From patchwork Mon Jun 19 12:41:58 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: 109996 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2993383vqr; Mon, 19 Jun 2023 06:05:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ58pA2v/JSjsS5OGzDs0HI7rGu677r21h2WN27pthlAvRoZoPSdDQMOra38JztN2ErjoC8M X-Received: by 2002:a05:6871:a694:b0:1a3:63ac:1e25 with SMTP id wh20-20020a056871a69400b001a363ac1e25mr8163925oab.42.1687179930219; Mon, 19 Jun 2023 06:05:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687179930; cv=none; d=google.com; s=arc-20160816; b=N5ar7I0AvTxvjLmZyA1z+eoG8GIFGsBECf2gJq4AJazEjuDrZlNLq+xOXRFbPNvTMt 0rrxODBPR1J9Qf3hT3CC4oA7cuzeF9x21GwHjWkBuKRh/S35ga2qq24FmkWx+4SuWSCU cIaW4JBvGCpmwyjySTZu6Gth+YSXepuW9KKOQL0ER1aYEoK07F4Il77fYFALt5QCDLZV +ukzrqD5hu+ldm2F7MVAmr4Oo/bCESyTJ3NMZTzSzTZ7P0i0fCkuAddm64qHGNnXXvwo PAXBhb7zQOzMI32zU/ouPhvL8vyfkULShz6FttdPNr5b/ZLiDs2DlOjSK5JIJwhbvz0u wvog== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d5-20020a17090a7bc500b00256551043fdsi7352221pjl.72.2023.06.19.06.05.07; Mon, 19 Jun 2023 06:05:30 -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 S231149AbjFSMml (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769136382547470563?= X-GMAIL-MSGID: =?utf-8?q?1769136382547470563?= 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;