From nobody Sat Feb 7 21:08:20 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 09D81EB64D7 for ; Fri, 23 Jun 2023 10:17:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231866AbjFWKRi (ORCPT ); Fri, 23 Jun 2023 06:17:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231290AbjFWKRR (ORCPT ); Fri, 23 Jun 2023 06:17:17 -0400 Received: from out-46.mta0.migadu.com (out-46.mta0.migadu.com [IPv6:2001:41d0:1004:224b::2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFC99172C for ; Fri, 23 Jun 2023 03:17:05 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1687514927; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1mYSHA82Ggr/qk8LcxRbWw+jtvr8ZShkQNBHi2vnZ+s=; b=Lzg3YyZjlP7eRGip2Pkq+Mlkn9hRfaUhzylAQ7XKNRcqwCBYLb1w4P73Ire/0LVeXvDLIz MfyjpGmYhjQcQC4Hb+QFcuzk44dUFpduWHPWYF3n1tUjfYU02Rg7J0nHbNxqVTl/9EN6km 1KkGyTaVOUxJgeE5C2JJqu6xcW0bLVg= From: Sui Jingfeng To: Lucas Stach , Russell King , Christian Gmeiner , David Airlie , Daniel Vetter Cc: etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn, Sui Jingfeng Subject: [PATCH v1 8/8] drm/etnaviv: Add a helper to get a pointer to the first available node Date: Fri, 23 Jun 2023 18:08:22 +0800 Message-Id: <20230623100822.274706-9-sui.jingfeng@linux.dev> In-Reply-To: <20230623100822.274706-1-sui.jingfeng@linux.dev> References: <20230623100822.274706-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sui Jingfeng This make the code in etnaviv_pdev_probe() less twisted, drop the reference to device node after finished. Also kill a double blank line. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 32 ++++++++++++++++++--------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnavi= v/etnaviv_drv.c index 7d0eeab3e8b7..3446f8eabf59 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -27,6 +27,19 @@ * DRM operations: */ =20 +/* If the DT contains at least one available GPU, return a pointer to it */ + +static struct device_node *etnaviv_of_first_node(void) +{ + struct device_node *np; + + for_each_compatible_node(np, NULL, "vivante,gc") { + if (of_device_is_available(np)) + return np; + } + + return NULL; +} =20 static void load_gpu(struct drm_device *dev) { @@ -587,7 +600,7 @@ static const struct component_master_ops etnaviv_master= _ops =3D { static int etnaviv_pdev_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; - struct device_node *first_node =3D NULL; + struct device_node *first_node; struct component_match *match =3D NULL; =20 if (!dev->platform_data) { @@ -597,11 +610,10 @@ static int etnaviv_pdev_probe(struct platform_device = *pdev) if (!of_device_is_available(core_node)) continue; =20 - if (!first_node) - first_node =3D core_node; - drm_of_component_match_add(&pdev->dev, &match, component_compare_of, core_node); + + of_node_put(core_node); } } else { char **names =3D dev->platform_data; @@ -634,8 +646,11 @@ static int etnaviv_pdev_probe(struct platform_device *= pdev) * device as the GPU we found. This assumes that all Vivante * GPUs in the system share the same DMA constraints. */ - if (first_node) + first_node =3D etnaviv_of_first_node(); + if (first_node) { of_dma_configure(&pdev->dev, first_node, true); + of_node_put(first_node); + } =20 return component_master_add_with_match(dev, &etnaviv_master_ops, match); } @@ -709,17 +724,14 @@ static int __init etnaviv_init(void) * 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; + np =3D etnaviv_of_first_node(); + if (np) { of_node_put(np); =20 ret =3D etnaviv_create_platform_device("etnaviv", &etnaviv_platform_device); if (ret) goto unregister_platform_driver; - - break; } =20 return 0; --=20 2.25.1