All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Vlad Dogaru <vlad.dogaru@intel.com>, linux-iio@vger.kernel.org
Subject: Re: [PATCH 1/6] iio: sx9500: add power management
Date: Thu, 09 Apr 2015 17:13:24 +0100	[thread overview]
Message-ID: <5526A524.9080908@kernel.org> (raw)
In-Reply-To: <1428065254-6444-2-git-send-email-vlad.dogaru@intel.com>

On 03/04/15 13:47, Vlad Dogaru wrote:
> Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
Applied to the togreg branch of iio.git - initially pushed out as testing for the autobuilders to play.

J
> ---
>  drivers/iio/proximity/sx9500.c | 47 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 47 insertions(+)
> 
> diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
> index 74dff4e..f62d0b6 100644
> --- a/drivers/iio/proximity/sx9500.c
> +++ b/drivers/iio/proximity/sx9500.c
> @@ -18,6 +18,7 @@
>  #include <linux/acpi.h>
>  #include <linux/gpio/consumer.h>
>  #include <linux/regmap.h>
> +#include <linux/pm.h>
>  
>  #include <linux/iio/iio.h>
>  #include <linux/iio/buffer.h>
> @@ -89,6 +90,8 @@ struct sx9500_data {
>  	bool event_enabled[SX9500_NUM_CHANNELS];
>  	bool trigger_enabled;
>  	u16 *buffer;
> +	/* Remember enabled channels and sample rate during suspend. */
> +	unsigned int suspend_ctrl0;
>  };
>  
>  static const struct iio_event_spec sx9500_events[] = {
> @@ -724,6 +727,49 @@ static int sx9500_remove(struct i2c_client *client)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_PM_SLEEP
> +static int sx9500_suspend(struct device *dev)
> +{
> +	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> +	struct sx9500_data *data = iio_priv(indio_dev);
> +	int ret;
> +
> +	mutex_lock(&data->mutex);
> +	ret = regmap_read(data->regmap, SX9500_REG_PROX_CTRL0,
> +			  &data->suspend_ctrl0);
> +	if (ret < 0)
> +		goto out;
> +
> +	/*
> +	 * Scan period doesn't matter because when all the sensors are
> +	 * deactivated the device is in sleep mode.
> +	 */
> +	ret = regmap_write(data->regmap, SX9500_REG_PROX_CTRL0, 0);
> +
> +out:
> +	mutex_unlock(&data->mutex);
> +	return ret;
> +}
> +
> +static int sx9500_resume(struct device *dev)
> +{
> +	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> +	struct sx9500_data *data = iio_priv(indio_dev);
> +	int ret;
> +
> +	mutex_lock(&data->mutex);
> +	ret = regmap_write(data->regmap, SX9500_REG_PROX_CTRL0,
> +			   data->suspend_ctrl0);
> +	mutex_unlock(&data->mutex);
> +
> +	return ret;
> +}
> +#endif /* CONFIG_PM_SLEEP */
> +
> +static const struct dev_pm_ops sx9500_pm_ops = {
> +	SET_SYSTEM_SLEEP_PM_OPS(sx9500_suspend, sx9500_resume)
> +};
> +
>  static const struct acpi_device_id sx9500_acpi_match[] = {
>  	{"SSX9500", 0},
>  	{ },
> @@ -740,6 +786,7 @@ static struct i2c_driver sx9500_driver = {
>  	.driver = {
>  		.name	= SX9500_DRIVER_NAME,
>  		.acpi_match_table = ACPI_PTR(sx9500_acpi_match),
> +		.pm = &sx9500_pm_ops,
>  	},
>  	.probe		= sx9500_probe,
>  	.remove		= sx9500_remove,
> 


  reply	other threads:[~2015-04-09 16:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-03 12:47 [PATCH 0/6] iio: sx9500: power and GPIO fixes Vlad Dogaru
2015-04-03 12:47 ` [PATCH 1/6] iio: sx9500: add power management Vlad Dogaru
2015-04-09 16:13   ` Jonathan Cameron [this message]
2015-04-03 12:47 ` [PATCH 2/6] iio: sx9500: optimize power usage Vlad Dogaru
2015-04-09 16:27   ` Jonathan Cameron
2015-04-10 10:36     ` Vlad Dogaru
2015-04-12 16:08       ` Jonathan Cameron
2015-04-03 12:47 ` [PATCH 3/6] iio: sx9500: rename GPIO interrupt pin Vlad Dogaru
2015-04-09 16:28   ` Jonathan Cameron
2015-04-18 18:59   ` Jonathan Cameron
2015-04-03 12:47 ` [PATCH 4/6] iio: sx9500: refactor GPIO interrupt code Vlad Dogaru
2015-04-09 16:30   ` Jonathan Cameron
2015-04-03 12:47 ` [PATCH 5/6] iio: sx9500: add GPIO reset pin Vlad Dogaru
2015-04-09 16:31   ` Jonathan Cameron
2015-04-03 12:47 ` [PATCH 6/6] iio: sx9500: fix formatting Vlad Dogaru
2015-04-09 16:31   ` Jonathan Cameron

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=5526A524.9080908@kernel.org \
    --to=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=vlad.dogaru@intel.com \
    /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.