Skip to content

Commit a22f18b

Browse files
committed
ACPI / MMC: PM: Unify fixing up device power
Introduce acpi_device_fix_up_power_extended() for fixing up power of a device having an ACPI companion in a manner that takes the device's children into account and make the MMC code use it in two places instead of walking the list of the device ACPI companion's children directly. This will help to eliminate the children list head from struct acpi_device as it is redundant and it is used in questionable ways in some places (in particular, locking is needed for walking the list pointed to it safely, but it is often missing). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 9089d1a commit a22f18b

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

drivers/acpi/device_pm.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,28 @@ int acpi_device_fix_up_power(struct acpi_device *device)
369369
}
370370
EXPORT_SYMBOL_GPL(acpi_device_fix_up_power);
371371

372+
static int fix_up_power_if_applicable(struct acpi_device *adev, void *not_used)
373+
{
374+
if (adev->status.present && adev->status.enabled)
375+
acpi_device_fix_up_power(adev);
376+
377+
return 0;
378+
}
379+
380+
/**
381+
* acpi_device_fix_up_power_extended - Force device and its children into D0.
382+
* @adev: Parent device object whose power state is to be fixed up.
383+
*
384+
* Call acpi_device_fix_up_power() for @adev and its children so long as they
385+
* are reported as present and enabled.
386+
*/
387+
void acpi_device_fix_up_power_extended(struct acpi_device *adev)
388+
{
389+
acpi_device_fix_up_power(adev);
390+
acpi_dev_for_each_child(adev, fix_up_power_if_applicable, NULL);
391+
}
392+
EXPORT_SYMBOL_GPL(acpi_device_fix_up_power_extended);
393+
372394
int acpi_device_update_power(struct acpi_device *device, int *state_p)
373395
{
374396
int state;

drivers/mmc/host/sdhci-acpi.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -775,8 +775,8 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
775775
{
776776
struct device *dev = &pdev->dev;
777777
const struct sdhci_acpi_slot *slot;
778-
struct acpi_device *device, *child;
779778
const struct dmi_system_id *id;
779+
struct acpi_device *device;
780780
struct sdhci_acpi_host *c;
781781
struct sdhci_host *host;
782782
struct resource *iomem;
@@ -796,10 +796,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
796796
slot = sdhci_acpi_get_slot(device);
797797

798798
/* Power on the SDHCI controller and its children */
799-
acpi_device_fix_up_power(device);
800-
list_for_each_entry(child, &device->children, node)
801-
if (child->status.present && child->status.enabled)
802-
acpi_device_fix_up_power(child);
799+
acpi_device_fix_up_power_extended(device);
803800

804801
if (sdhci_acpi_byt_defer(dev))
805802
return -EPROBE_DEFER;

drivers/mmc/host/sdhci-pci-core.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,16 +1240,11 @@ static const struct sdhci_pci_fixes sdhci_intel_byt_sd = {
12401240
#ifdef CONFIG_ACPI
12411241
static void intel_mrfld_mmc_fix_up_power_slot(struct sdhci_pci_slot *slot)
12421242
{
1243-
struct acpi_device *device, *child;
1243+
struct acpi_device *device;
12441244

12451245
device = ACPI_COMPANION(&slot->chip->pdev->dev);
1246-
if (!device)
1247-
return;
1248-
1249-
acpi_device_fix_up_power(device);
1250-
list_for_each_entry(child, &device->children, node)
1251-
if (child->status.present && child->status.enabled)
1252-
acpi_device_fix_up_power(child);
1246+
if (device)
1247+
acpi_device_fix_up_power_extended(device);
12531248
}
12541249
#else
12551250
static inline void intel_mrfld_mmc_fix_up_power_slot(struct sdhci_pci_slot *slot) {}

include/acpi/acpi_bus.h

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

0 commit comments

Comments
 (0)