forked from mirrors/linux
		
	ACPI / PM: Clean up device wakeup enable/disable code
The wakeup.flags.enabled flag in struct acpi_device is not used consistently, as there is no reason why it should only apply to the enabling/disabling of the wakeup GPE, so put the invocation of acpi_enable_wakeup_device_power() under it too. Moreover, it is not necessary to call acpi_enable_wakeup_devices() and acpi_disable_wakeup_devices() for suspend-to-idle, so don't do that. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
		
							parent
							
								
									190cab8471
								
							
						
					
					
						commit
						235d81a630
					
				
					 2 changed files with 10 additions and 13 deletions
				
			
		|  | @ -688,26 +688,23 @@ static int acpi_device_wakeup(struct acpi_device *adev, u32 target_state, | ||||||
| 		acpi_status res; | 		acpi_status res; | ||||||
| 		int error; | 		int error; | ||||||
| 
 | 
 | ||||||
|  | 		if (adev->wakeup.flags.enabled) | ||||||
|  | 			return 0; | ||||||
|  | 
 | ||||||
| 		error = acpi_enable_wakeup_device_power(adev, target_state); | 		error = acpi_enable_wakeup_device_power(adev, target_state); | ||||||
| 		if (error) | 		if (error) | ||||||
| 			return error; | 			return error; | ||||||
| 
 | 
 | ||||||
| 		if (adev->wakeup.flags.enabled) |  | ||||||
| 			return 0; |  | ||||||
| 
 |  | ||||||
| 		res = acpi_enable_gpe(wakeup->gpe_device, wakeup->gpe_number); | 		res = acpi_enable_gpe(wakeup->gpe_device, wakeup->gpe_number); | ||||||
| 		if (ACPI_SUCCESS(res)) { | 		if (ACPI_FAILURE(res)) { | ||||||
| 			adev->wakeup.flags.enabled = 1; |  | ||||||
| 		} else { |  | ||||||
| 			acpi_disable_wakeup_device_power(adev); | 			acpi_disable_wakeup_device_power(adev); | ||||||
| 			return -EIO; | 			return -EIO; | ||||||
| 		} | 		} | ||||||
| 	} else { | 		adev->wakeup.flags.enabled = 1; | ||||||
| 		if (adev->wakeup.flags.enabled) { | 	} else if (adev->wakeup.flags.enabled) { | ||||||
| 			acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number); | 		acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number); | ||||||
| 			adev->wakeup.flags.enabled = 0; |  | ||||||
| 		} |  | ||||||
| 		acpi_disable_wakeup_device_power(adev); | 		acpi_disable_wakeup_device_power(adev); | ||||||
|  | 		adev->wakeup.flags.enabled = 0; | ||||||
| 	} | 	} | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -658,19 +658,19 @@ static int acpi_freeze_begin(void) | ||||||
| 
 | 
 | ||||||
| static int acpi_freeze_prepare(void) | static int acpi_freeze_prepare(void) | ||||||
| { | { | ||||||
| 	acpi_enable_wakeup_devices(ACPI_STATE_S0); |  | ||||||
| 	acpi_enable_all_wakeup_gpes(); | 	acpi_enable_all_wakeup_gpes(); | ||||||
| 	acpi_os_wait_events_complete(); | 	acpi_os_wait_events_complete(); | ||||||
| 	if (acpi_sci_irq_valid()) | 	if (acpi_sci_irq_valid()) | ||||||
| 		enable_irq_wake(acpi_sci_irq); | 		enable_irq_wake(acpi_sci_irq); | ||||||
|  | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void acpi_freeze_restore(void) | static void acpi_freeze_restore(void) | ||||||
| { | { | ||||||
| 	acpi_disable_wakeup_devices(ACPI_STATE_S0); |  | ||||||
| 	if (acpi_sci_irq_valid()) | 	if (acpi_sci_irq_valid()) | ||||||
| 		disable_irq_wake(acpi_sci_irq); | 		disable_irq_wake(acpi_sci_irq); | ||||||
|  | 
 | ||||||
| 	acpi_enable_all_runtime_gpes(); | 	acpi_enable_all_runtime_gpes(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Rafael J. Wysocki
						Rafael J. Wysocki