drm/amdgpu: Use pci_get_base_class() to reduce duplicated code
authorSui Jingfeng <suijingfeng@loongson.cn>
Fri, 25 Aug 2023 06:27:13 +0000 (14:27 +0800)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 28 Sep 2023 21:54:54 +0000 (16:54 -0500)
Use pci_get_base_class() to reduce duplicated code.  No functional change
intended.

Link: https://lore.kernel.org/r/20230825062714.6325-5-sui.jingfeng@linux.dev
Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c

index 2bca37044ad0fb762a59dc8dfcbda540e2f50168..327e2fd2401fe1967ab117dee9f609072716766c 100644 (file)
@@ -1389,14 +1389,11 @@ void amdgpu_acpi_detect(void)
        struct pci_dev *pdev = NULL;
        int ret;
 
-       while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
-               if (!atif->handle)
-                       amdgpu_atif_pci_probe_handle(pdev);
-               if (!atcs->handle)
-                       amdgpu_atcs_pci_probe_handle(pdev);
-       }
+       while ((pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) {
+               if ((pdev->class != PCI_CLASS_DISPLAY_VGA << 8) &&
+                   (pdev->class != PCI_CLASS_DISPLAY_OTHER << 8))
+                       continue;
 
-       while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
                if (!atif->handle)
                        amdgpu_atif_pci_probe_handle(pdev);
                if (!atcs->handle)
index 38ccec913f0097772c6facd1a73b5cbeeca8287e..5bbb23e102ba0fec448ad73c382965e788ed8cbd 100644 (file)
@@ -287,7 +287,11 @@ static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev)
        if (adev->flags & AMD_IS_APU)
                return false;
 
-       while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
+       while ((pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) {
+               if ((pdev->class != PCI_CLASS_DISPLAY_VGA << 8) &&
+                   (pdev->class != PCI_CLASS_DISPLAY_OTHER << 8))
+                       continue;
+
                dhandle = ACPI_HANDLE(&pdev->dev);
                if (!dhandle)
                        continue;
@@ -299,20 +303,6 @@ static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev)
                }
        }
 
-       if (!found) {
-               while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
-                       dhandle = ACPI_HANDLE(&pdev->dev);
-                       if (!dhandle)
-                               continue;
-
-                       status = acpi_get_handle(dhandle, "ATRM", &atrm_handle);
-                       if (ACPI_SUCCESS(status)) {
-                               found = true;
-                               break;
-                       }
-               }
-       }
-
        if (!found)
                return false;
        pci_dev_put(pdev);