From: "Rafael J. Wysocki" <rjw-KKrjLPT3xs0@public.gmane.org>
To: Mark Brown
<broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
pm list
<linux-pm-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
Alan Stern
<stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>,
Matthew Garrett <mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org>
Subject: Re: [PATCH] i2c: Hook up runtime PM support
Date: Thu, 4 Feb 2010 22:57:27 +0100 [thread overview]
Message-ID: <201002042257.27145.rjw@sisk.pl> (raw)
In-Reply-To: <1265203367-21344-1-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
On Wednesday 03 February 2010, Mark Brown wrote:
> Allow I2C drivers to make use of the runtime PM framework by adding
> bus implementations of the runtime PM operations. These simply
> immediately suspend when the device is idle.
Perhaps it would be a good idea to give the driver a chance to veto
the suspend by calling its _idle callback? We do that for PCI and turns out to
be quite useful.
> The runtime PM framework provides drivers with off the shelf refcounts for
> enables and sysfs control for managing runtime suspend from userspace so is
> useful even without meaningful input from the bus.
>
> Signed-off-by: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
> ---
> drivers/i2c/i2c-core.c | 41 +++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 41 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 10be7b5..985eaac 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -34,6 +34,7 @@
> #include <linux/hardirq.h>
> #include <linux/irqflags.h>
> #include <linux/rwsem.h>
> +#include <linux/pm_runtime.h>
> #include <asm/uaccess.h>
>
> #include "i2c-core.h"
> @@ -184,6 +185,43 @@ static int i2c_device_pm_resume(struct device *dev)
> #define i2c_device_pm_resume NULL
> #endif
>
> +#ifdef CONFIG_PM_RUNTIME
> +static int i2c_device_runtime_suspend(struct device *dev)
> +{
> + const struct dev_pm_ops *pm;
> +
> + if (!dev->driver)
> + return 0;
> + pm = dev->driver->pm;
> + if (!pm || !pm->runtime_suspend)
> + return 0;
> + return pm->runtime_suspend(dev);
> +}
> +
> +static int i2c_device_runtime_resume(struct device *dev)
> +{
> + const struct dev_pm_ops *pm;
> +
> + if (!dev->driver)
> + return 0;
> + pm = dev->driver->pm;
> + if (!pm || !pm->runtime_resume)
> + return 0;
> + return pm->runtime_resume(dev);
> +}
> +
> +static int i2c_device_runtime_idle(struct device *dev)
> +{
> + /* I2C devices are very independent of each other so we
> + * suspend them immediately. */
> + return pm_runtime_suspend(dev);
> +}
> +#else
> +#define i2c_device_runtime_suspend NULL
> +#define i2c_device_runtime_resume NULL
> +#define i2c_device_runtime_idle NULL
> +#endif
> +
> static int i2c_device_suspend(struct device *dev, pm_message_t mesg)
> {
> struct i2c_client *client = i2c_verify_client(dev);
> @@ -251,6 +289,9 @@ static const struct attribute_group *i2c_dev_attr_groups[] = {
> static const struct dev_pm_ops i2c_device_pm_ops = {
> .suspend = i2c_device_pm_suspend,
> .resume = i2c_device_pm_resume,
> + .runtime_suspend = i2c_device_runtime_suspend,
> + .runtime_resume = i2c_device_runtime_resume,
> + .runtime_idle = i2c_device_runtime_idle,
> };
>
> struct bus_type i2c_bus_type = {
>
Rafael
next prev parent reply other threads:[~2010-02-04 21:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-03 13:22 [PATCH] i2c: Hook up runtime PM support Mark Brown
[not found] ` <1265203367-21344-1-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2010-02-04 21:57 ` Rafael J. Wysocki [this message]
[not found] ` <201002042257.27145.rjw-KKrjLPT3xs0@public.gmane.org>
2010-02-05 10:39 ` [linux-pm] " Mark Brown
[not found] ` <20100205103915.GA2600-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2010-02-05 22:09 ` Rafael J. Wysocki
[not found] ` <201002052309.13966.rjw-KKrjLPT3xs0@public.gmane.org>
2010-02-05 23:17 ` Mark Brown
-- strict thread matches above, loose matches on Subject: below --
2010-02-05 12:30 Mark Brown
[not found] ` <1265373011-12874-1-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2010-02-07 11:45 ` Rafael J. Wysocki
2010-02-15 18:14 ` Jean Delvare
[not found] ` <20100215191409.14d87257-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-02-15 18:30 ` Mark Brown
[not found] ` <20100215183058.GA24590-HF5t3jzXg/6ND3a5+9QAFujbO/Zr0HzV@public.gmane.org>
2010-02-15 19:08 ` Rafael J. Wysocki
[not found] ` <201002152008.24142.rjw-KKrjLPT3xs0@public.gmane.org>
2010-02-15 19:14 ` Jean Delvare
2010-02-15 19:15 ` Mark Brown
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=201002042257.27145.rjw@sisk.pl \
--to=rjw-kkrjlpt3xs0@public.gmane.org \
--cc=broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
--cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-pm-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org \
--cc=stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.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).