Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752280AbbDSK4w (ORCPT ); Sun, 19 Apr 2015 06:56:52 -0400 Received: from mout.gmx.net ([212.227.15.19]:52100 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751413AbbDSK4u (ORCPT ); Sun, 19 Apr 2015 06:56:50 -0400 Message-ID: <553389EB.7070109@gmx.de> Date: Sun, 19 Apr 2015 12:56:43 +0200 From: Hartmut Knaack User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0 SeaMonkey/2.33.1 MIME-Version: 1.0 To: NeilBrown , Jonathan Cameron CC: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, GTA04 owners , Doug Anderson , Thorsten Nowak , Manuel Stahl , Christian Strobel Subject: Re: [PATCH v2] iio: gyro: itg3200: add suspend/resume support. References: <20150224132441.2cb8ae6d@notabene.brown> In-Reply-To: <20150224132441.2cb8ae6d@notabene.brown> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:U7YHoCWMVJtE21IUU3BXNal3B4kThZB6RH2Q6fq2ip4sF8Rtf8H pqqXrqNctrThjmOzYbpsNTy34ETlWan6OBQhzqR7WmbfF6JayAHXXaz3kh0X1aWcIg9s7Lm V+a3tDnWld112OGcWhytQQlEMGcWwgrqpKsZ8obn0zFePnjylCeG3GA7Qe7eLogTQ6gCJas VviUjLoaLZEu6T4Y/YA+A== X-UI-Out-Filterresults: notjunk:1; Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2720 Lines: 93 NeilBrown schrieb am 24.02.2015 um 03:24: > > 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 > Acked-by: Hartmut Knaack I don't recall acking on this. Anyway, no objection on the patch content. Hartmut > Signed-off-by: NeilBrown > > --- > v1 of this was sent in November. I got some useful feedback, but then got distracted > by something. Sorry for the long gap. > NeilBrown > > > 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, > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/