Skip to content

Commit 2ef5236

Browse files
committed
ACPI: glue: Look for ACPI bus type only if ACPI companion is not known
Notice that it is not necessary to look for the "ACPI bus type" of the device in acpi_device_notify() if the device's ACPI companion is set upfront, so modify the code to do that lookup only if it is necessary to find the ACPI companion. Also notice that if the device's ACPI companion is not set upfront in acpi_device_notify(), the device cannot be either a PCI one or a platform one, so check for these bus types only if the device's ACPI companion is set. Signed-off-by: Rafael J. Wysocki <[email protected]> Tested-by: Ferry Toth <[email protected]>
1 parent c4d1983 commit 2ef5236

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

drivers/acpi/glue.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,13 @@ EXPORT_SYMBOL_GPL(acpi_unbind_one);
289289

290290
void acpi_device_notify(struct device *dev)
291291
{
292-
struct acpi_bus_type *type = acpi_get_bus_type(dev);
293292
struct acpi_device *adev;
294293
int ret;
295294

296295
ret = acpi_bind_one(dev, NULL);
297296
if (ret) {
297+
struct acpi_bus_type *type = acpi_get_bus_type(dev);
298+
298299
if (!type)
299300
goto err;
300301

@@ -306,21 +307,26 @@ void acpi_device_notify(struct device *dev)
306307
ret = acpi_bind_one(dev, adev);
307308
if (ret)
308309
goto err;
309-
}
310-
adev = ACPI_COMPANION(dev);
311310

312-
if (dev_is_pci(dev)) {
313-
pci_acpi_setup(dev, adev);
311+
if (type->setup) {
312+
type->setup(dev);
313+
goto done;
314+
}
314315
} else {
315-
if (dev_is_platform(dev))
316-
acpi_configure_pmsi_domain(dev);
316+
adev = ACPI_COMPANION(dev);
317317

318-
if (type && type->setup)
319-
type->setup(dev);
320-
else if (adev->handler && adev->handler->bind)
321-
adev->handler->bind(dev);
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+
}
322324
}
323325

326+
if (adev->handler && adev->handler->bind)
327+
adev->handler->bind(dev);
328+
329+
done:
324330
acpi_handle_debug(ACPI_HANDLE(dev), "Bound to device %s\n",
325331
dev_name(dev));
326332

0 commit comments

Comments
 (0)