Skip to content

Commit 87440d7

Browse files
committed
Merge back ACPI PCI material for v5.16.
2 parents 3fb937f + 2ef5236 commit 87440d7

File tree

4 files changed

+33
-41
lines changed

4 files changed

+33
-41
lines changed

drivers/acpi/glue.c

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <linux/rwsem.h>
1818
#include <linux/acpi.h>
1919
#include <linux/dma-mapping.h>
20+
#include <linux/pci.h>
21+
#include <linux/pci-acpi.h>
2022
#include <linux/platform_device.h>
2123

2224
#include "internal.h"
@@ -287,12 +289,13 @@ EXPORT_SYMBOL_GPL(acpi_unbind_one);
287289

288290
void acpi_device_notify(struct device *dev)
289291
{
290-
struct acpi_bus_type *type = acpi_get_bus_type(dev);
291292
struct acpi_device *adev;
292293
int ret;
293294

294295
ret = acpi_bind_one(dev, NULL);
295296
if (ret) {
297+
struct acpi_bus_type *type = acpi_get_bus_type(dev);
298+
296299
if (!type)
297300
goto err;
298301

@@ -304,17 +307,26 @@ void acpi_device_notify(struct device *dev)
304307
ret = acpi_bind_one(dev, adev);
305308
if (ret)
306309
goto err;
307-
}
308-
adev = ACPI_COMPANION(dev);
309310

310-
if (dev_is_platform(dev))
311-
acpi_configure_pmsi_domain(dev);
311+
if (type->setup) {
312+
type->setup(dev);
313+
goto done;
314+
}
315+
} else {
316+
adev = ACPI_COMPANION(dev);
317+
318+
if (dev_is_pci(dev)) {
319+
pci_acpi_setup(dev, adev);
320+
goto done;
321+
} else if (dev_is_platform(dev)) {
322+
acpi_configure_pmsi_domain(dev);
323+
}
324+
}
312325

313-
if (type && type->setup)
314-
type->setup(dev);
315-
else if (adev->handler && adev->handler->bind)
326+
if (adev->handler && adev->handler->bind)
316327
adev->handler->bind(dev);
317328

329+
done:
318330
acpi_handle_debug(ACPI_HANDLE(dev), "Bound to device %s\n",
319331
dev_name(dev));
320332

@@ -327,14 +339,12 @@ void acpi_device_notify(struct device *dev)
327339
void acpi_device_notify_remove(struct device *dev)
328340
{
329341
struct acpi_device *adev = ACPI_COMPANION(dev);
330-
struct acpi_bus_type *type;
331342

332343
if (!adev)
333344
return;
334345

335-
type = acpi_get_bus_type(dev);
336-
if (type && type->cleanup)
337-
type->cleanup(dev);
346+
if (dev_is_pci(dev))
347+
pci_acpi_cleanup(dev, adev);
338348
else if (adev->handler && adev->handler->unbind)
339349
adev->handler->unbind(dev);
340350

drivers/pci/pci-acpi.c

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,13 +1356,9 @@ static void pci_acpi_set_external_facing(struct pci_dev *dev)
13561356
dev->external_facing = 1;
13571357
}
13581358

1359-
static void pci_acpi_setup(struct device *dev)
1359+
void pci_acpi_setup(struct device *dev, struct acpi_device *adev)
13601360
{
13611361
struct pci_dev *pci_dev = to_pci_dev(dev);
1362-
struct acpi_device *adev = ACPI_COMPANION(dev);
1363-
1364-
if (!adev)
1365-
return;
13661362

13671363
pci_acpi_optimize_delay(pci_dev, adev->handle);
13681364
pci_acpi_set_external_facing(pci_dev);
@@ -1386,14 +1382,10 @@ static void pci_acpi_setup(struct device *dev)
13861382
acpi_device_power_add_dependent(adev, dev);
13871383
}
13881384

1389-
static void pci_acpi_cleanup(struct device *dev)
1385+
void pci_acpi_cleanup(struct device *dev, struct acpi_device *adev)
13901386
{
1391-
struct acpi_device *adev = ACPI_COMPANION(dev);
13921387
struct pci_dev *pci_dev = to_pci_dev(dev);
13931388

1394-
if (!adev)
1395-
return;
1396-
13971389
pci_acpi_remove_edr_notifier(pci_dev);
13981390
pci_acpi_remove_pm_notifier(adev);
13991391
if (adev->wakeup.flags.valid) {
@@ -1405,20 +1397,6 @@ static void pci_acpi_cleanup(struct device *dev)
14051397
}
14061398
}
14071399

1408-
static bool pci_acpi_bus_match(struct device *dev)
1409-
{
1410-
return dev_is_pci(dev);
1411-
}
1412-
1413-
static struct acpi_bus_type acpi_pci_bus = {
1414-
.name = "PCI",
1415-
.match = pci_acpi_bus_match,
1416-
.find_companion = acpi_pci_find_companion,
1417-
.setup = pci_acpi_setup,
1418-
.cleanup = pci_acpi_cleanup,
1419-
};
1420-
1421-
14221400
static struct fwnode_handle *(*pci_msi_get_fwnode_cb)(struct device *dev);
14231401

14241402
/**
@@ -1460,8 +1438,6 @@ struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus)
14601438

14611439
static int __init acpi_pci_init(void)
14621440
{
1463-
int ret;
1464-
14651441
if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_MSI) {
14661442
pr_info("ACPI FADT declares the system doesn't support MSI, so disable it\n");
14671443
pci_no_msi();
@@ -1472,8 +1448,7 @@ static int __init acpi_pci_init(void)
14721448
pcie_no_aspm();
14731449
}
14741450

1475-
ret = register_acpi_bus_type(&acpi_pci_bus);
1476-
if (ret)
1451+
if (acpi_pci_disabled)
14771452
return 0;
14781453

14791454
pci_set_platform_pm(&acpi_pci_platform_pm);

include/acpi/acpi_bus.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,6 @@ struct acpi_bus_type {
570570
bool (*match)(struct device *dev);
571571
struct acpi_device * (*find_companion)(struct device *);
572572
void (*setup)(struct device *);
573-
void (*cleanup)(struct device *);
574573
};
575574
int register_acpi_bus_type(struct acpi_bus_type *);
576575
int unregister_acpi_bus_type(struct acpi_bus_type *);

include/linux/pci-acpi.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ extern struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
8484
void acpi_pci_add_bus(struct pci_bus *bus);
8585
void acpi_pci_remove_bus(struct pci_bus *bus);
8686

87+
#ifdef CONFIG_PCI
88+
void pci_acpi_setup(struct device *dev, struct acpi_device *adev);
89+
void pci_acpi_cleanup(struct device *dev, struct acpi_device *adev);
90+
#else
91+
static inline void pci_acpi_setup(struct device *dev, struct acpi_device *adev) {}
92+
static inline void pci_acpi_cleanup(struct device *dev, struct acpi_device *adev) {}
93+
#endif
94+
8795
#ifdef CONFIG_ACPI_PCI_SLOT
8896
void acpi_pci_slot_init(void);
8997
void acpi_pci_slot_enumerate(struct pci_bus *bus);

0 commit comments

Comments
 (0)