diff mbox

[RFC] pm: make device_prepare() use dpm_run_callback()

Message ID 1371133239-12054-1-git-send-email-bigeasy@linutronix.de (mailing list archive)
State Rejected, archived
Headers show

Commit Message

Sebastian Andrzej Siewior June 13, 2013, 2:20 p.m. UTC
After looking at device_prepare() I was curious why the info parameter
isn't used. Then I noticed that others call dpm_run_callback() which
takes the info parameter and is actually doing something with it and it
does the same (cb) check as here.
So maybe, maybe the intention here was to use the function in the first
place.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/base/power/main.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Rafael Wysocki June 13, 2013, 6:12 p.m. UTC | #1
On Thursday, June 13, 2013 04:20:39 PM Sebastian Andrzej Siewior wrote:
> After looking at device_prepare() I was curious why the info parameter
> isn't used. Then I noticed that others call dpm_run_callback() which
> takes the info parameter and is actually doing something with it and it
> does the same (cb) check as here.
> So maybe, maybe the intention here was to use the function in the first
> place.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

No, it wasn't.

We've just discussed a similar patch on linux-pm, please look into the
archives.

Thanks,
Rafael


> ---
>  drivers/base/power/main.c |    7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
> index 5a9b656..521029e 100644
> --- a/drivers/base/power/main.c
> +++ b/drivers/base/power/main.c
> @@ -1223,7 +1223,7 @@ int dpm_suspend(pm_message_t state)
>   */
>  static int device_prepare(struct device *dev, pm_message_t state)
>  {
> -	int (*callback)(struct device *) = NULL;
> +	pm_callback_t callback = NULL;
>  	char *info = NULL;
>  	int error = 0;
>  
> @@ -1261,10 +1261,7 @@ static int device_prepare(struct device *dev, pm_message_t state)
>  		callback = dev->driver->pm->prepare;
>  	}
>  
> -	if (callback) {
> -		error = callback(dev);
> -		suspend_report_result(callback, error);
> -	}
> +	error = dpm_run_callback(callback, dev, state, info);
>  
>  	device_unlock(dev);
>  
>
diff mbox

Patch

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 5a9b656..521029e 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1223,7 +1223,7 @@  int dpm_suspend(pm_message_t state)
  */
 static int device_prepare(struct device *dev, pm_message_t state)
 {
-	int (*callback)(struct device *) = NULL;
+	pm_callback_t callback = NULL;
 	char *info = NULL;
 	int error = 0;
 
@@ -1261,10 +1261,7 @@  static int device_prepare(struct device *dev, pm_message_t state)
 		callback = dev->driver->pm->prepare;
 	}
 
-	if (callback) {
-		error = callback(dev);
-		suspend_report_result(callback, error);
-	}
+	error = dpm_run_callback(callback, dev, state, info);
 
 	device_unlock(dev);