Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: Use pci_get_base_class() to reduce duplicated code

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>

authored by

Sui Jingfeng and committed by
Bjorn Helgaas
18bf4005 c213ed39

+9 -22
+4 -7
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
··· 1389 1389 struct pci_dev *pdev = NULL; 1390 1390 int ret; 1391 1391 1392 - while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) { 1393 - if (!atif->handle) 1394 - amdgpu_atif_pci_probe_handle(pdev); 1395 - if (!atcs->handle) 1396 - amdgpu_atcs_pci_probe_handle(pdev); 1397 - } 1392 + while ((pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) { 1393 + if ((pdev->class != PCI_CLASS_DISPLAY_VGA << 8) && 1394 + (pdev->class != PCI_CLASS_DISPLAY_OTHER << 8)) 1395 + continue; 1398 1396 1399 - while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) { 1400 1397 if (!atif->handle) 1401 1398 amdgpu_atif_pci_probe_handle(pdev); 1402 1399 if (!atcs->handle)
+5 -15
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
··· 287 287 if (adev->flags & AMD_IS_APU) 288 288 return false; 289 289 290 - while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) { 290 + while ((pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) { 291 + if ((pdev->class != PCI_CLASS_DISPLAY_VGA << 8) && 292 + (pdev->class != PCI_CLASS_DISPLAY_OTHER << 8)) 293 + continue; 294 + 291 295 dhandle = ACPI_HANDLE(&pdev->dev); 292 296 if (!dhandle) 293 297 continue; ··· 300 296 if (ACPI_SUCCESS(status)) { 301 297 found = true; 302 298 break; 303 - } 304 - } 305 - 306 - if (!found) { 307 - while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) { 308 - dhandle = ACPI_HANDLE(&pdev->dev); 309 - if (!dhandle) 310 - continue; 311 - 312 - status = acpi_get_handle(dhandle, "ATRM", &atrm_handle); 313 - if (ACPI_SUCCESS(status)) { 314 - found = true; 315 - break; 316 - } 317 299 } 318 300 } 319 301