Skip to content

Commit 553b84b

Browse files
committed
Merge branch 'pci/enumeration'
- Add and use pci_get_base_class() to search for all PCI_BASE_CLASS_DISPLAY devices (Sui Jingfeng) - Fix a vmd check for multi-function devices (Ilpo Järvinen) - Add PCI_HEADER_TYPE_MFD and use it to replace literals (Ilpo Järvinen) - Use acpi_evaluate_dsm_typed() instead of open-coding it (Andy Shevchenko) - Keep .remove() and .probe() callbacks (previously marked __init) in case they're used via sysfs (Uwe Kleine-König) * pci/enumeration: PCI: keystone: Don't discard .probe() callback PCI: keystone: Don't discard .remove() callback PCI: kirin: Don't discard .remove() callback PCI: exynos: Don't discard .remove() callback PCI/ACPI: Use acpi_evaluate_dsm_typed() PCI: Use PCI_HEADER_TYPE_* instead of literals PCI: Add PCI_HEADER_TYPE_MFD definition PCI: vmd: Correct PCI Header Type Register's multi-function check drm/radeon: Use pci_get_base_class() to reduce duplicated code drm/amdgpu: Use pci_get_base_class() to reduce duplicated code drm/nouveau: Use pci_get_base_class() to reduce duplicated code ALSA: hda: Use pci_get_base_class() to reduce duplicated code PCI: Add pci_get_base_class() helper
2 parents 4eccbed + 7994db9 commit 553b84b

File tree

24 files changed

+104
-98
lines changed

24 files changed

+104
-98
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,14 +1389,11 @@ void amdgpu_acpi_detect(void)
13891389
struct pci_dev *pdev = NULL;
13901390
int ret;
13911391

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;
13981396

1399-
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
14001397
if (!atif->handle)
14011398
amdgpu_atif_pci_probe_handle(pdev);
14021399
if (!atcs->handle)

drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,11 @@ static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev)
287287
if (adev->flags & AMD_IS_APU)
288288
return false;
289289

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+
291295
dhandle = ACPI_HANDLE(&pdev->dev);
292296
if (!dhandle)
293297
continue;
@@ -299,20 +303,6 @@ static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev)
299303
}
300304
}
301305

302-
if (!found) {
303-
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
304-
dhandle = ACPI_HANDLE(&pdev->dev);
305-
if (!dhandle)
306-
continue;
307-
308-
status = acpi_get_handle(dhandle, "ATRM", &atrm_handle);
309-
if (ACPI_SUCCESS(status)) {
310-
found = true;
311-
break;
312-
}
313-
}
314-
}
315-
316306
if (!found)
317307
return false;
318308
pci_dev_put(pdev);

drivers/gpu/drm/nouveau/nouveau_acpi.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,11 @@ static bool nouveau_dsm_detect(void)
284284
printk("MXM: GUID detected in BIOS\n");
285285

286286
/* now do DSM detection */
287-
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
288-
vga_count++;
289-
290-
nouveau_dsm_pci_probe(pdev, &dhandle, &has_mux, &has_optimus,
291-
&has_optimus_flags, &has_power_resources);
292-
}
287+
while ((pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) {
288+
if ((pdev->class != PCI_CLASS_DISPLAY_VGA << 8) &&
289+
(pdev->class != PCI_CLASS_DISPLAY_3D << 8))
290+
continue;
293291

294-
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_3D << 8, pdev)) != NULL) {
295292
vga_count++;
296293

297294
nouveau_dsm_pci_probe(pdev, &dhandle, &has_mux, &has_optimus,

drivers/gpu/drm/radeon/radeon_bios.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,11 @@ static bool radeon_atrm_get_bios(struct radeon_device *rdev)
199199
if (rdev->flags & RADEON_IS_IGP)
200200
return false;
201201

202-
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
202+
while ((pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) {
203+
if ((pdev->class != PCI_CLASS_DISPLAY_VGA << 8) &&
204+
(pdev->class != PCI_CLASS_DISPLAY_OTHER << 8))
205+
continue;
206+
203207
dhandle = ACPI_HANDLE(&pdev->dev);
204208
if (!dhandle)
205209
continue;
@@ -211,20 +215,6 @@ static bool radeon_atrm_get_bios(struct radeon_device *rdev)
211215
}
212216
}
213217

214-
if (!found) {
215-
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
216-
dhandle = ACPI_HANDLE(&pdev->dev);
217-
if (!dhandle)
218-
continue;
219-
220-
status = acpi_get_handle(dhandle, "ATRM", &atrm_handle);
221-
if (ACPI_SUCCESS(status)) {
222-
found = true;
223-
break;
224-
}
225-
}
226-
}
227-
228218
if (!found)
229219
return false;
230220
pci_dev_put(pdev);

drivers/pci/controller/dwc/pci-exynos.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ static int exynos_pcie_probe(struct platform_device *pdev)
375375
return ret;
376376
}
377377

378-
static int __exit exynos_pcie_remove(struct platform_device *pdev)
378+
static int exynos_pcie_remove(struct platform_device *pdev)
379379
{
380380
struct exynos_pcie *ep = platform_get_drvdata(pdev);
381381

@@ -431,7 +431,7 @@ static const struct of_device_id exynos_pcie_of_match[] = {
431431

432432
static struct platform_driver exynos_pcie_driver = {
433433
.probe = exynos_pcie_probe,
434-
.remove = __exit_p(exynos_pcie_remove),
434+
.remove = exynos_pcie_remove,
435435
.driver = {
436436
.name = "exynos-pcie",
437437
.of_match_table = exynos_pcie_of_match,

drivers/pci/controller/dwc/pci-keystone.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ static const struct of_device_id ks_pcie_of_match[] = {
11001100
{ },
11011101
};
11021102

1103-
static int __init ks_pcie_probe(struct platform_device *pdev)
1103+
static int ks_pcie_probe(struct platform_device *pdev)
11041104
{
11051105
const struct dw_pcie_host_ops *host_ops;
11061106
const struct dw_pcie_ep_ops *ep_ops;
@@ -1302,7 +1302,7 @@ static int __init ks_pcie_probe(struct platform_device *pdev)
13021302
return ret;
13031303
}
13041304

1305-
static int __exit ks_pcie_remove(struct platform_device *pdev)
1305+
static int ks_pcie_remove(struct platform_device *pdev)
13061306
{
13071307
struct keystone_pcie *ks_pcie = platform_get_drvdata(pdev);
13081308
struct device_link **link = ks_pcie->link;
@@ -1318,9 +1318,9 @@ static int __exit ks_pcie_remove(struct platform_device *pdev)
13181318
return 0;
13191319
}
13201320

1321-
static struct platform_driver ks_pcie_driver __refdata = {
1321+
static struct platform_driver ks_pcie_driver = {
13221322
.probe = ks_pcie_probe,
1323-
.remove = __exit_p(ks_pcie_remove),
1323+
.remove = ks_pcie_remove,
13241324
.driver = {
13251325
.name = "keystone-pcie",
13261326
.of_match_table = ks_pcie_of_match,

drivers/pci/controller/dwc/pci-layerscape.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static bool ls_pcie_is_bridge(struct ls_pcie *pcie)
5858
u32 header_type;
5959

6060
header_type = ioread8(pci->dbi_base + PCI_HEADER_TYPE);
61-
header_type &= 0x7f;
61+
header_type &= PCI_HEADER_TYPE_MASK;
6262

6363
return header_type == PCI_HEADER_TYPE_BRIDGE;
6464
}

drivers/pci/controller/dwc/pcie-kirin.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ static int kirin_pcie_power_on(struct platform_device *pdev,
741741
return ret;
742742
}
743743

744-
static int __exit kirin_pcie_remove(struct platform_device *pdev)
744+
static int kirin_pcie_remove(struct platform_device *pdev)
745745
{
746746
struct kirin_pcie *kirin_pcie = platform_get_drvdata(pdev);
747747

@@ -818,7 +818,7 @@ static int kirin_pcie_probe(struct platform_device *pdev)
818818

819819
static struct platform_driver kirin_pcie_driver = {
820820
.probe = kirin_pcie_probe,
821-
.remove = __exit_p(kirin_pcie_remove),
821+
.remove = kirin_pcie_remove,
822822
.driver = {
823823
.name = "kirin-pcie",
824824
.of_match_table = kirin_pcie_match,

drivers/pci/controller/mobiveil/pcie-mobiveil-host.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ static bool mobiveil_pcie_is_bridge(struct mobiveil_pcie *pcie)
539539
u32 header_type;
540540

541541
header_type = mobiveil_csr_readb(pcie, PCI_HEADER_TYPE);
542-
header_type &= 0x7f;
542+
header_type &= PCI_HEADER_TYPE_MASK;
543543

544544
return header_type == PCI_HEADER_TYPE_BRIDGE;
545545
}

drivers/pci/controller/pcie-iproc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie)
783783

784784
/* make sure we are not in EP mode */
785785
iproc_pci_raw_config_read32(pcie, 0, PCI_HEADER_TYPE, 1, &hdr_type);
786-
if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE) {
786+
if ((hdr_type & PCI_HEADER_TYPE_MASK) != PCI_HEADER_TYPE_BRIDGE) {
787787
dev_err(dev, "in EP mode, hdr=%#02x\n", hdr_type);
788788
return -EFAULT;
789789
}

0 commit comments

Comments
 (0)