===================================================================
@@ -52,7 +52,6 @@ struct acpi_power_resource {
u32 system_level;
u32 order;
unsigned int ref_count;
- unsigned int users;
u8 state;
bool wakeup_enabled;
struct mutex resource_lock;
@@ -174,8 +173,6 @@ int acpi_extract_power_resources(union a
err = acpi_power_resources_list_add(rhandle, list);
if (err)
break;
-
- to_power_resource(rdev)->users++;
}
if (err)
acpi_power_resources_list_free(list);
@@ -1018,39 +1015,10 @@ void acpi_resume_power_resources(void)
}
#endif
-static void acpi_power_turn_off_if_unused(struct acpi_power_resource *resource,
- bool init)
-{
- if (resource->ref_count > 0)
- return;
-
- if (init) {
- if (resource->users > 0)
- return;
- } else {
- int result;
- u8 state;
-
- result = acpi_power_get_state(resource->device.handle, &state);
- if (result || state == ACPI_POWER_RESOURCE_STATE_OFF)
- return;
- }
-
- dev_info(&resource->device.dev, "Turning OFF\n");
- __acpi_power_off(resource);
-}
-
/**
* acpi_turn_off_unused_power_resources - Turn off power resources not in use.
- * @init: Control switch.
- *
- * If @ainit is set, unconditionally turn off all of the ACPI power resources
- * without any users.
- *
- * Otherwise, turn off all ACPI power resources without active references (that
- * is, the ones that should be "off" at the moment) that are "on".
*/
-void acpi_turn_off_unused_power_resources(bool init)
+void acpi_turn_off_unused_power_resources(void)
{
struct acpi_power_resource *resource;
@@ -1059,7 +1027,16 @@ void acpi_turn_off_unused_power_resource
list_for_each_entry_reverse(resource, &acpi_power_resource_list, list_node) {
mutex_lock(&resource->resource_lock);
- acpi_power_turn_off_if_unused(resource, init);
+ /*
+ * Turn off power resources in an unknown state too, because the
+ * platform firmware on some system expects the OS to turn off
+ * power resources without any users unconditionally.
+ */
+ if (!resource->ref_count &&
+ resource->state != ACPI_POWER_RESOURCE_STATE_OFF) {
+ dev_info(&resource->device.dev, "Turning OFF\n");
+ __acpi_power_off(resource);
+ }
mutex_unlock(&resource->resource_lock);
}
===================================================================
@@ -142,7 +142,7 @@ int acpi_device_sleep_wake(struct acpi_d
int acpi_power_get_inferred_state(struct acpi_device *device, int *state);
int acpi_power_on_resources(struct acpi_device *device, int state);
int acpi_power_transition(struct acpi_device *device, int state);
-void acpi_turn_off_unused_power_resources(bool init);
+void acpi_turn_off_unused_power_resources(void);
/* --------------------------------------------------------------------------
Device Power Management
===================================================================
@@ -2356,7 +2356,7 @@ int __init acpi_scan_init(void)
}
}
- acpi_turn_off_unused_power_resources(true);
+ acpi_turn_off_unused_power_resources();
acpi_scan_initialized = true;
===================================================================
@@ -504,7 +504,7 @@ static void acpi_pm_start(u32 acpi_state
*/
static void acpi_pm_end(void)
{
- acpi_turn_off_unused_power_resources(false);
+ acpi_turn_off_unused_power_resources();
acpi_scan_lock_release();
/*
* This is necessary in case acpi_pm_finish() is not called during a