From: Jonathan Cameron <jic23@kernel.org>
To: NeilBrown <neilb@suse.de>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
GTA04 owners <gta04-owner@goldelico.com>,
Doug Anderson <dianders@chromium.org>,
Thorsten Nowak <thorsten.nowak@iis.fraunhofer.de>,
Manuel Stahl <manuel.stahl@iis.fraunhofer.de>,
Christian Strobel <christian.strobel@iis.fraunhofer.de>,
Hartmut Knaack <knaack.h@gmx.de>
Subject: Re: [PATCH v2] iio: gyro: itg3200: add suspend/resume support.
Date: Mon, 09 Mar 2015 14:55:31 +0000 [thread overview]
Message-ID: <54FDB463.1070409@kernel.org> (raw)
In-Reply-To: <20150224132441.2cb8ae6d@notabene.brown>
On 24/02/15 02:24, NeilBrown wrote:
>
> Unless we put the device to sleep when not it use, it wastes
> 6mA.
>
> If the device is asleep on probe, the 'id' register
> sometimes mis-reads - so reset first. If the device responds
> at all a command sent to the address, it is almost certainly
> the correct device already.
>
> Acked-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
> Acked-by: Hartmut Knaack <knaack.h@gmx.de>
> Signed-off-by: NeilBrown <neil@brown.name>
Applied to the togreg branch of iio.git. Initially pushed out
as testing for the autobuilders to play with it.
Thanks,
Jonathan
>
> ---
> v1 of this was sent in November. I got some useful feedback, but then got distracted
> by something. Sorry for the long gap.
> NeilBrown
Not to worry, I've got lots of stuff in that category ;(
>
>
> diff --git a/drivers/iio/gyro/itg3200_core.c b/drivers/iio/gyro/itg3200_core.c
> index 6a8020d48140..f0fd94055d88 100644
> --- a/drivers/iio/gyro/itg3200_core.c
> +++ b/drivers/iio/gyro/itg3200_core.c
> @@ -223,6 +223,10 @@ static int itg3200_initial_setup(struct iio_dev *indio_dev)
> int ret;
> u8 val;
>
> + ret = itg3200_reset(indio_dev);
> + if (ret)
> + goto err_ret;
> +
> ret = itg3200_read_reg_8(indio_dev, ITG3200_REG_ADDRESS, &val);
> if (ret)
> goto err_ret;
> @@ -233,10 +237,6 @@ static int itg3200_initial_setup(struct iio_dev *indio_dev)
> goto err_ret;
> }
>
> - ret = itg3200_reset(indio_dev);
> - if (ret)
> - goto err_ret;
> -
> ret = itg3200_enable_full_scale(indio_dev);
> err_ret:
> return ret;
> @@ -351,6 +351,26 @@ static int itg3200_remove(struct i2c_client *client)
> return 0;
> }
>
> +static int __maybe_unused itg3200_suspend(struct device *dev)
> +{
> + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> + struct itg3200 *st = iio_priv(indio_dev);
> +
> + dev_dbg(&st->i2c->dev, "suspend device");
> +
> + return itg3200_write_reg_8(indio_dev, ITG3200_REG_POWER_MANAGEMENT,
> + ITG3200_SLEEP);
> +}
> +
> +static int __maybe_unused itg3200_resume(struct device *dev)
> +{
> + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> +
> + return itg3200_initial_setup(indio_dev);
> +}
> +
> +static SIMPLE_DEV_PM_OPS(itg3200_pm_ops, itg3200_suspend, itg3200_resume);
> +
> static const struct i2c_device_id itg3200_id[] = {
> { "itg3200", 0 },
> { }
> @@ -361,6 +381,7 @@ static struct i2c_driver itg3200_driver = {
> .driver = {
> .owner = THIS_MODULE,
> .name = "itg3200",
> + .pm = &itg3200_pm_ops,
> },
> .id_table = itg3200_id,
> .probe = itg3200_probe,
>
next prev parent reply other threads:[~2015-03-09 14:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-24 2:24 [PATCH v2] iio: gyro: itg3200: add suspend/resume support NeilBrown
2015-03-09 14:55 ` Jonathan Cameron [this message]
2015-04-19 10:56 ` Hartmut Knaack
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=54FDB463.1070409@kernel.org \
--to=jic23@kernel.org \
--cc=christian.strobel@iis.fraunhofer.de \
--cc=dianders@chromium.org \
--cc=gta04-owner@goldelico.com \
--cc=knaack.h@gmx.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manuel.stahl@iis.fraunhofer.de \
--cc=neilb@suse.de \
--cc=thorsten.nowak@iis.fraunhofer.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.