]> rtime.felk.cvut.cz Git - linux-imx.git/commit
ACPI / PM: Rework and clean up acpi_dev_pm_get_state()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sat, 15 Jun 2013 22:37:59 +0000 (00:37 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 19 Jun 2013 21:37:08 +0000 (23:37 +0200)
commitfa1675b56537651270e79967b7f1ee4202c83bf6
tree0c294f009d636378d79fd8300bb5c936ffdb656f
parent4c164ae7d8a7ee1f39b773d97794535c2c193b12
ACPI / PM: Rework and clean up acpi_dev_pm_get_state()

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: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/device_pm.c