Skip to content

Commit b7dd629

Browse files
committed
ACPI: PM: Introduce acpi_dev_power_up_children_with_adr()
Introduce a function powering up all of the children of a given ACPI device object that are power-manageable and hold valid _ADR ACPI objects so as to make it possible to prepare the corresponding "physical" devices for enumeration carried out by a bus type driver, like PCI. This function will be used in a subsequent change set. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
1 parent cf6ba07 commit b7dd629

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

drivers/acpi/device_pm.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,36 @@ bool acpi_bus_power_manageable(acpi_handle handle)
425425
}
426426
EXPORT_SYMBOL(acpi_bus_power_manageable);
427427

428+
static int acpi_power_up_if_adr_present(struct device *dev, void *not_used)
429+
{
430+
struct acpi_device *adev;
431+
432+
adev = to_acpi_device(dev);
433+
if (!(adev->flags.power_manageable && adev->pnp.type.bus_address))
434+
return 0;
435+
436+
acpi_handle_debug(adev->handle, "Power state: %s\n",
437+
acpi_power_state_string(adev->power.state));
438+
439+
if (adev->power.state == ACPI_STATE_D3_COLD)
440+
return acpi_device_set_power(adev, ACPI_STATE_D0);
441+
442+
return 0;
443+
}
444+
445+
/**
446+
* acpi_dev_power_up_children_with_adr - Power up childres with valid _ADR
447+
* @adev: Parent ACPI device object.
448+
*
449+
* Change the power states of the direct children of @adev that are in D3cold
450+
* and hold valid _ADR objects to D0 in order to allow bus (e.g. PCI)
451+
* enumeration code to access them.
452+
*/
453+
void acpi_dev_power_up_children_with_adr(struct acpi_device *adev)
454+
{
455+
acpi_dev_for_each_child(adev, acpi_power_up_if_adr_present, NULL);
456+
}
457+
428458
#ifdef CONFIG_PM
429459
static DEFINE_MUTEX(acpi_pm_notifier_lock);
430460
static DEFINE_MUTEX(acpi_pm_notifier_install_lock);

include/acpi/acpi_bus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ int acpi_device_fix_up_power(struct acpi_device *device);
524524
int acpi_bus_update_power(acpi_handle handle, int *state_p);
525525
int acpi_device_update_power(struct acpi_device *device, int *state_p);
526526
bool acpi_bus_power_manageable(acpi_handle handle);
527+
void acpi_dev_power_up_children_with_adr(struct acpi_device *adev);
527528
int acpi_device_power_add_dependent(struct acpi_device *adev,
528529
struct device *dev);
529530
void acpi_device_power_remove_dependent(struct acpi_device *adev,

0 commit comments

Comments
 (0)