Commit b4060db9 authored by Douglas Anderson's avatar Douglas Anderson Committed by Rafael J. Wysocki

PM: runtime: Have devm_pm_runtime_enable() handle pm_runtime_dont_use_autosuspend()

The PM Runtime docs say:

  Drivers in ->remove() callback should undo the runtime PM changes done
  in ->probe(). Usually this means calling pm_runtime_disable(),
  pm_runtime_dont_use_autosuspend() etc.

From grepping code, it's clear that many people aren't aware of the
need to call pm_runtime_dont_use_autosuspend().

When brainstorming solutions, one idea that came up was to leverage
the new-ish devm_pm_runtime_enable() function. The idea here is that:

 * When the devm action is called we know that the driver is being
   removed. It's the perfect time to undo the use_autosuspend.

 * The code of pm_runtime_dont_use_autosuspend() already handles the
   case of being called when autosuspend wasn't enabled.
Suggested-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
Reviewed-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 7e57714c
...@@ -1476,11 +1476,16 @@ EXPORT_SYMBOL_GPL(pm_runtime_enable); ...@@ -1476,11 +1476,16 @@ EXPORT_SYMBOL_GPL(pm_runtime_enable);
static void pm_runtime_disable_action(void *data) static void pm_runtime_disable_action(void *data)
{ {
pm_runtime_dont_use_autosuspend(data);
pm_runtime_disable(data); pm_runtime_disable(data);
} }
/** /**
* devm_pm_runtime_enable - devres-enabled version of pm_runtime_enable. * devm_pm_runtime_enable - devres-enabled version of pm_runtime_enable.
*
* NOTE: this will also handle calling pm_runtime_dont_use_autosuspend() for
* you at driver exit time if needed.
*
* @dev: Device to handle. * @dev: Device to handle.
*/ */
int devm_pm_runtime_enable(struct device *dev) int devm_pm_runtime_enable(struct device *dev)
......
...@@ -567,6 +567,10 @@ static inline void pm_runtime_disable(struct device *dev) ...@@ -567,6 +567,10 @@ static inline void pm_runtime_disable(struct device *dev)
* Allow the runtime PM autosuspend mechanism to be used for @dev whenever * Allow the runtime PM autosuspend mechanism to be used for @dev whenever
* requested (or "autosuspend" will be handled as direct runtime-suspend for * requested (or "autosuspend" will be handled as direct runtime-suspend for
* it). * it).
*
* NOTE: It's important to undo this with pm_runtime_dont_use_autosuspend()
* at driver exit time unless your driver initially enabled pm_runtime
* with devm_pm_runtime_enable() (which handles it for you).
*/ */
static inline void pm_runtime_use_autosuspend(struct device *dev) static inline void pm_runtime_use_autosuspend(struct device *dev)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment