diff mbox series

[v1,02/12] PM: sleep: Relocate two device PM core functions

Message ID 4876491.GXAFRqVoOG@kreacher
State New
Headers show
Series None | expand

Commit Message

Rafael J. Wysocki Jan. 22, 2024, 11:24 a.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Move is_async() and dpm_async_fn() in the PM core to a more suitable
place.

No functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/base/power/main.c |   58 +++++++++++++++++++++++-----------------------
 1 file changed, 29 insertions(+), 29 deletions(-)

Comments

Stanislaw Gruszka Jan. 25, 2024, 7:40 a.m. UTC | #1
On Mon, Jan 22, 2024 at 12:24:21PM +0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Move is_async() and dpm_async_fn() in the PM core to a more suitable
> place.
> 
> No functional impact.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>

> ---
>  drivers/base/power/main.c |   58 +++++++++++++++++++++++-----------------------
>  1 file changed, 29 insertions(+), 29 deletions(-)
> 
> Index: linux-pm/drivers/base/power/main.c
> ===================================================================
> --- linux-pm.orig/drivers/base/power/main.c
> +++ linux-pm/drivers/base/power/main.c
> @@ -578,6 +578,35 @@ bool dev_pm_skip_resume(struct device *d
>  	return !dev->power.must_resume;
>  }
>  
> +static bool is_async(struct device *dev)
> +{
> +	return dev->power.async_suspend && pm_async_enabled
> +		&& !pm_trace_is_enabled();
> +}
> +
> +static bool dpm_async_fn(struct device *dev, async_func_t func)
> +{
> +	reinit_completion(&dev->power.completion);
> +
> +	if (is_async(dev)) {
> +		dev->power.async_in_progress = true;
> +
> +		get_device(dev);
> +
> +		if (async_schedule_dev_nocall(func, dev))
> +			return true;
> +
> +		put_device(dev);
> +	}
> +	/*
> +	 * Because async_schedule_dev_nocall() above has returned false or it
> +	 * has not been called at all, func() is not running and it is safe to
> +	 * update the async_in_progress flag without extra synchronization.
> +	 */
> +	dev->power.async_in_progress = false;
> +	return false;
> +}
> +
>  /**
>   * device_resume_noirq - Execute a "noirq resume" callback for given device.
>   * @dev: Device to handle.
> @@ -664,35 +693,6 @@ Out:
>  	}
>  }
>  
> -static bool is_async(struct device *dev)
> -{
> -	return dev->power.async_suspend && pm_async_enabled
> -		&& !pm_trace_is_enabled();
> -}
> -
> -static bool dpm_async_fn(struct device *dev, async_func_t func)
> -{
> -	reinit_completion(&dev->power.completion);
> -
> -	if (is_async(dev)) {
> -		dev->power.async_in_progress = true;
> -
> -		get_device(dev);
> -
> -		if (async_schedule_dev_nocall(func, dev))
> -			return true;
> -
> -		put_device(dev);
> -	}
> -	/*
> -	 * Because async_schedule_dev_nocall() above has returned false or it
> -	 * has not been called at all, func() is not running and it is safe to
> -	 * update the async_in_progress flag without extra synchronization.
> -	 */
> -	dev->power.async_in_progress = false;
> -	return false;
> -}
> -
>  static void async_resume_noirq(void *data, async_cookie_t cookie)
>  {
>  	struct device *dev = data;
> 
> 
> 
>
diff mbox series

Patch

Index: linux-pm/drivers/base/power/main.c
===================================================================
--- linux-pm.orig/drivers/base/power/main.c
+++ linux-pm/drivers/base/power/main.c
@@ -578,6 +578,35 @@  bool dev_pm_skip_resume(struct device *d
 	return !dev->power.must_resume;
 }
 
+static bool is_async(struct device *dev)
+{
+	return dev->power.async_suspend && pm_async_enabled
+		&& !pm_trace_is_enabled();
+}
+
+static bool dpm_async_fn(struct device *dev, async_func_t func)
+{
+	reinit_completion(&dev->power.completion);
+
+	if (is_async(dev)) {
+		dev->power.async_in_progress = true;
+
+		get_device(dev);
+
+		if (async_schedule_dev_nocall(func, dev))
+			return true;
+
+		put_device(dev);
+	}
+	/*
+	 * Because async_schedule_dev_nocall() above has returned false or it
+	 * has not been called at all, func() is not running and it is safe to
+	 * update the async_in_progress flag without extra synchronization.
+	 */
+	dev->power.async_in_progress = false;
+	return false;
+}
+
 /**
  * device_resume_noirq - Execute a "noirq resume" callback for given device.
  * @dev: Device to handle.
@@ -664,35 +693,6 @@  Out:
 	}
 }
 
-static bool is_async(struct device *dev)
-{
-	return dev->power.async_suspend && pm_async_enabled
-		&& !pm_trace_is_enabled();
-}
-
-static bool dpm_async_fn(struct device *dev, async_func_t func)
-{
-	reinit_completion(&dev->power.completion);
-
-	if (is_async(dev)) {
-		dev->power.async_in_progress = true;
-
-		get_device(dev);
-
-		if (async_schedule_dev_nocall(func, dev))
-			return true;
-
-		put_device(dev);
-	}
-	/*
-	 * Because async_schedule_dev_nocall() above has returned false or it
-	 * has not been called at all, func() is not running and it is safe to
-	 * update the async_in_progress flag without extra synchronization.
-	 */
-	dev->power.async_in_progress = false;
-	return false;
-}
-
 static void async_resume_noirq(void *data, async_cookie_t cookie)
 {
 	struct device *dev = data;