From 6baa1e610eb67c6f5c185bb5e8cd189dff3a3d17 Mon Sep 17 00:00:00 2001 From: Aaron Lu Date: Wed, 21 Nov 2012 23:33:40 +0100 Subject: [PATCH] --- yaml --- r: 336611 b: refs/heads/master c: 1399dfcdfe89898ccd791216f9679ba734aea910 h: refs/heads/master i: 336609: 29444e65e41649dfd70eb99cc230b17c4f47fd4d 336607: d24d8b2b2f2540b1104320e639e590af5c762e6c v: v3 --- [refs] | 2 +- trunk/drivers/acpi/scan.c | 9 ++++++++- trunk/include/acpi/acpi_bus.h | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 1b453e1507ac..993e1c6cc3eb 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: ddc150f7a33ae0c9cb16eaac3641abc00f56316f +refs/heads/master: 1399dfcdfe89898ccd791216f9679ba734aea910 diff --git a/trunk/drivers/acpi/scan.c b/trunk/drivers/acpi/scan.c index 1fcb8678665c..da1416af0c8b 100644 --- a/trunk/drivers/acpi/scan.c +++ b/trunk/drivers/acpi/scan.c @@ -965,8 +965,10 @@ static int acpi_bus_get_power_flags(struct acpi_device *device) * D3hot is only valid if _PR3 present. */ if (ps->resources.count || - (ps->flags.explicit_set && i < ACPI_STATE_D3_HOT)) + (ps->flags.explicit_set && i < ACPI_STATE_D3_HOT)) { ps->flags.valid = 1; + ps->flags.os_accessible = 1; + } ps->power = -1; /* Unknown - driver assigned */ ps->latency = -1; /* Unknown - driver assigned */ @@ -982,6 +984,11 @@ static int acpi_bus_get_power_flags(struct acpi_device *device) if (device->power.states[ACPI_STATE_D3_HOT].flags.explicit_set) device->power.states[ACPI_STATE_D3_COLD].flags.explicit_set = 1; + /* Presence of _PS3 or _PRx means we can put the device into D3 cold */ + if (device->power.states[ACPI_STATE_D3_HOT].flags.explicit_set || + device->power.flags.power_resources) + device->power.states[ACPI_STATE_D3_COLD].flags.os_accessible = 1; + acpi_bus_init_power(device); return 0; diff --git a/trunk/include/acpi/acpi_bus.h b/trunk/include/acpi/acpi_bus.h index 80155fda517f..c3bc4511e0c0 100644 --- a/trunk/include/acpi/acpi_bus.h +++ b/trunk/include/acpi/acpi_bus.h @@ -201,6 +201,7 @@ struct acpi_device_power_flags { struct acpi_device_power_state { struct { u8 valid:1; + u8 os_accessible:1; u8 explicit_set:1; /* _PSx present? */ u8 reserved:6; } flags; @@ -500,6 +501,11 @@ static inline bool acpi_device_can_wakeup(struct acpi_device *adev) return adev->wakeup.flags.valid; } +static inline bool acpi_device_can_poweroff(struct acpi_device *adev) +{ + return adev->power.states[ACPI_STATE_D3_COLD].flags.os_accessible; +} + #else /* CONFIG_ACPI */ static inline int register_acpi_bus_type(void *bus) { return 0; }