From nobody Sat Feb 7 20:39:21 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 C989FEE49B5 for ; Fri, 25 Aug 2023 06:28:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242190AbjHYG2D (ORCPT ); Fri, 25 Aug 2023 02:28:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242175AbjHYG1l (ORCPT ); Fri, 25 Aug 2023 02:27:41 -0400 Received: from out-61.mta1.migadu.com (out-61.mta1.migadu.com [IPv6:2001:41d0:203:375::3d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7D971FCB for ; Thu, 24 Aug 2023 23:27:39 -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=1692944857; 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=x8g1PhZtieFXqvl5KlmXpfelaKvpJdAuWlFNqp32lxU=; b=azk9oKl/yWYIN5PPkoo3zBSOa5qD4a5Ttwotj7deRwg4VxJLVd1VH9ZPjzSxR8PPOtGk7H 2eXNsnzhwSuxKFP68ub1/EATKxmpRZkXRApbQsGsMiJuZEaOOoibeOK2+BNWPK3PdLGpfw qaDtANXtL8laXrkLljPHNF5ob99FzAU= From: Sui Jingfeng To: Bjorn Helgaas Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, linux-pci@vger.kernel.org, alsa-devel@alsa-project.org, Sui Jingfeng , Alex Deucher Subject: [PATCH 4/5] drm/amdgpu: Use pci_get_base_class() to reduce duplicated code Date: Fri, 25 Aug 2023 14:27:13 +0800 Message-Id: <20230825062714.6325-5-sui.jingfeng@linux.dev> In-Reply-To: <20230825062714.6325-1-sui.jingfeng@linux.dev> References: <20230825062714.6325-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 Should be no functional change. Cc: Alex Deucher Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 11 ++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 20 +++++--------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd= /amdgpu/amdgpu_acpi.c index a5a2b06c6588..4f18af877105 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c @@ -1389,14 +1389,11 @@ void amdgpu_acpi_detect(void) struct pci_dev *pdev =3D NULL; int ret; =20 - while ((pdev =3D pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) !=3D NU= LL) { - if (!atif->handle) - amdgpu_atif_pci_probe_handle(pdev); - if (!atcs->handle) - amdgpu_atcs_pci_probe_handle(pdev); - } + while ((pdev =3D pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) { + if ((pdev->class !=3D PCI_CLASS_DISPLAY_VGA << 8) && + (pdev->class !=3D PCI_CLASS_DISPLAY_OTHER << 8)) + continue; =20 - while ((pdev =3D pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) !=3D = NULL) { if (!atif->handle) amdgpu_atif_pci_probe_handle(pdev); if (!atcs->handle) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c b/drivers/gpu/drm/amd= /amdgpu/amdgpu_bios.c index 38ccec913f00..5bbb23e102ba 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c @@ -287,7 +287,11 @@ static bool amdgpu_atrm_get_bios(struct amdgpu_device = *adev) if (adev->flags & AMD_IS_APU) return false; =20 - while ((pdev =3D pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) !=3D NU= LL) { + while ((pdev =3D pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) { + if ((pdev->class !=3D PCI_CLASS_DISPLAY_VGA << 8) && + (pdev->class !=3D PCI_CLASS_DISPLAY_OTHER << 8)) + continue; + dhandle =3D ACPI_HANDLE(&pdev->dev); if (!dhandle) continue; @@ -299,20 +303,6 @@ static bool amdgpu_atrm_get_bios(struct amdgpu_device = *adev) } } =20 - if (!found) { - while ((pdev =3D pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) !=3D= NULL) { - dhandle =3D ACPI_HANDLE(&pdev->dev); - if (!dhandle) - continue; - - status =3D acpi_get_handle(dhandle, "ATRM", &atrm_handle); - if (ACPI_SUCCESS(status)) { - found =3D true; - break; - } - } - } - if (!found) return false; pci_dev_put(pdev); --=20 2.34.1