• R
    ACPI / PM: Rework and clean up acpi_dev_pm_get_state() · fa1675b5
    Rafael J. Wysocki 提交于
    The acpi_dev_pm_get_state() function defined in device_pm.c is quite
    convoluted, which isn't really necessary, and it doesn't validate the
    values returned by the ACPI methods executed by it appropriately.
    
    To address these shortcomings modify it in the following way.
    
     (1) Make its return value only mean whether or not it succeeded and
         pass the device power states determined by it through pointers.
    
     (2) Drop the d_max_in argument, used by only one of its callers,
         from it, and move the code related to d_max_in into that caller,
         acpi_pm_device_sleep_state().
    
     (3) Make it always check the return value of acpi_evaluate_integer()
         and handle failures as appropriate.  Moreover, make it check if
         the values returned by the executed ACPI methods are not out of
         range.
    
     (4) Make it check if the values returned by the executed ACPI
         methods represent valid power states of the given device and
         handle situations in which that's not the case gracefully.
    
    Also update the kerneldoc comments of acpi_dev_pm_get_state() and
    acpi_pm_device_sleep_state() to reflect the code changes.
    Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
    fa1675b5
device_pm.c 29.6 KB