linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Ming Lei <ming.lei@canonical.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	Borislav Petkov <borislav.petkov@amd.com>,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH v1 2/3] PM / Sleep: introduce dpm_for_each_dev
Date: Sat, 18 Aug 2012 00:02:26 +0200	[thread overview]
Message-ID: <201208180002.26563.rjw@sisk.pl> (raw)
In-Reply-To: <1345212420-1707-3-git-send-email-ming.lei@canonical.com>

On Friday, August 17, 2012, Ming Lei wrote:
> dpm_list and its pm lock provide a good way to iterate all
> devices in system. Except this way, there is no other easy
> way to iterate devices in system.
> 
> firmware loader need to cache firmware images for devices
> before system sleep, so introduce the function to meet its
> demand.
> 
> Reported-by: Fengguang Wu <fengguang.wu@intel.com>
> Signed-off-by: Ming Lei <ming.lei@canonical.com>

Well.

> ---
>  drivers/base/power/main.c |   22 ++++++++++++++++++++++
>  include/linux/pm.h        |    5 +++++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
> index 57f5814..23b417f 100644
> --- a/drivers/base/power/main.c
> +++ b/drivers/base/power/main.c
> @@ -1349,3 +1349,25 @@ int device_pm_wait_for_dev(struct device *subordinate, struct device *dev)
>  	return async_error;
>  }
>  EXPORT_SYMBOL_GPL(device_pm_wait_for_dev);
> +
> +/**
> + * dpm_for_each_dev - device iterator.
> + * @data: data for the callback.
> + * @fn: function to be called for each device.
> + *
> + * Iterate over devices in dpm_list, and call @fn for each device,
> + * passing it @data.
> + */
> +void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *))

Is this function actually used more than once?

> +{
> +	struct device *dev;
> +
> +	if (!fn)
> +		return;
> +
> +	device_pm_lock();
> +	list_for_each_entry(dev, &dpm_list, power.entry)
> +		fn(dev, data);
> +	device_pm_unlock();
> +}
> +EXPORT_SYMBOL_GPL(dpm_for_each_dev);
> diff --git a/include/linux/pm.h b/include/linux/pm.h
> index 44d1f23..007e687 100644
> --- a/include/linux/pm.h
> +++ b/include/linux/pm.h
> @@ -640,6 +640,7 @@ extern void __suspend_report_result(const char *function, void *fn, int ret);
>  	} while (0)
>  
>  extern int device_pm_wait_for_dev(struct device *sub, struct device *dev);
> +extern void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *));
>  
>  extern int pm_generic_prepare(struct device *dev);
>  extern int pm_generic_suspend_late(struct device *dev);
> @@ -679,6 +680,10 @@ static inline int device_pm_wait_for_dev(struct device *a, struct device *b)
>  	return 0;
>  }
>  
> +static inline void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *))
> +{
> +}
> +
>  #define pm_generic_prepare	NULL
>  #define pm_generic_suspend	NULL
>  #define pm_generic_resume	NULL

Rafael

  reply	other threads:[~2012-08-17 21:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-17 14:06 [PATCH v1 0/3] firmware loader: fix build failure Ming Lei
2012-08-17 14:06 ` [PATCH v1 1/3] firmware loader: fix compile failure if !PM Ming Lei
2012-08-17 14:06 ` [PATCH v1 2/3] PM / Sleep: introduce dpm_for_each_dev Ming Lei
2012-08-17 22:02   ` Rafael J. Wysocki [this message]
2012-08-18  0:43     ` Ming Lei
2012-08-18 13:38       ` Rafael J. Wysocki
2012-08-18 14:52         ` Ming Lei
2012-08-18 20:33           ` Rafael J. Wysocki
2012-08-18 20:49             ` Rafael J. Wysocki
2012-08-19  6:20               ` Greg Kroah-Hartman
2012-08-19 20:10                 ` Rafael J. Wysocki
2012-08-17 14:07 ` [PATCH v1 3/3] firmware loader: fix build failure if FW_LOADER is m Ming Lei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201208180002.26563.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=borislav.petkov@amd.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=ming.lei@canonical.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).