All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Tiberiu Breana <tiberiu.a.breana@intel.com>, linux-iio@vger.kernel.org
Subject: Re: [PATCH 2/3] iio: light: Add Power Management for STK3310
Date: Sun, 19 Apr 2015 16:57:23 +0100	[thread overview]
Message-ID: <5533D063.5080505@kernel.org> (raw)
In-Reply-To: <1429003962-13922-3-git-send-email-tiberiu.a.breana@intel.com>

On 14/04/15 10:32, Tiberiu Breana wrote:
> Added suspend & resume functions to the stk3310 driver.
> 
> Signed-off-by: Tiberiu Breana <tiberiu.a.breana@intel.com>
Whilst we are here. It's always nice to have a series broken up into
bite sized chunks, but I have no objection to having things like this
in the main patch!

couple of little bits inline.

> ---
>  drivers/iio/light/stk3310.c | 41 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
> 
> diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
> index 5bcf5a0..bc09304 100644
> --- a/drivers/iio/light/stk3310.c
> +++ b/drivers/iio/light/stk3310.c
> @@ -82,6 +82,8 @@ enum stk3310_config_type {
>  struct stk3310_data {
>  	struct i2c_client *client;
>  	struct mutex lock;
> +	int als_enabled;
> +	int ps_enabled;
bool
>  	/* Cache table for storing config values */
>  	int cache[2][STK3310_TYPE_COUNT];
>  };
> @@ -385,6 +387,12 @@ static int stk3310_set_state(struct stk3310_data *data, u8 state)
>  
>  	mutex_unlock(&data->lock);
>  
> +	/* Don't reset the 'enabled' flags if we're going in standby */
> +	if (state != STK3310_STATE_STANDBY) {
> +		data->ps_enabled = (state & 0x01) ? 1 : 0;
data->ps_enabled = !!(state & 0x01);
> +		data->als_enabled = (state & 0x02) ? 1 : 0;
> +	}
> +
>  	return ret;
>  }
>  
> @@ -461,6 +469,38 @@ static int stk3310_remove(struct i2c_client *client)
>  	return stk3310_set_state(data, STK3310_STATE_STANDBY);
>  }
>  
> +#ifdef CONFIG_PM_SLEEP
> +static int stk3310_suspend(struct device *dev)
> +{
> +	struct stk3310_data *data;
> +
> +	data = iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
> +
> +	return stk3310_set_state(data, STK3310_STATE_STANDBY);
> +}
> +
> +static int stk3310_resume(struct device *dev)
> +{
> +	int state;
= 0;
> +	struct stk3310_data *data;
> +
> +	data = iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
> +	state = 0;
> +	if (data->ps_enabled)
> +		state |= STK3310_STATE_EN_PS;
> +	if (data->als_enabled)
> +		state |= STK3310_STATE_EN_ALS;
> +
> +	return stk3310_set_state(data, state);
> +}
> +
> +static SIMPLE_DEV_PM_OPS(stk3310_pm_ops, stk3310_suspend, stk3310_resume);
> +
> +#define STK3310_PM_OPS (&stk3310_pm_ops)
> +#else
> +#define STK3310_PM_OPS NULL
> +#endif
> +
>  static const struct i2c_device_id stk3310_i2c_id[] = {
>  	{"STK3310", 0},
>  	{"STK3311", 0},
> @@ -478,6 +518,7 @@ MODULE_DEVICE_TABLE(acpi, stk3310_acpi_id);
>  static struct i2c_driver stk3310_driver = {
>  	.driver = {
>  		.name = "stk3310",
> +		.pm = STK3310_PM_OPS,
>  		.acpi_match_table = ACPI_PTR(stk3310_acpi_id),
>  	},
>  	.probe =            stk3310_probe,
> 


  reply	other threads:[~2015-04-19 15:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-14  9:32 [PATCH 0/3] Add support for Sensortek STK3310 Tiberiu Breana
2015-04-14  9:32 ` [PATCH 1/3] iio: light: " Tiberiu Breana
2015-04-19 15:54   ` Jonathan Cameron
2015-04-14  9:32 ` [PATCH 2/3] iio: light: Add Power Management for STK3310 Tiberiu Breana
2015-04-19 15:57   ` Jonathan Cameron [this message]
2015-04-14  9:32 ` [PATCH 3/3] iio: light: Add threshold interrupt support " Tiberiu Breana
2015-04-19 16:08   ` 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=5533D063.5080505@kernel.org \
    --to=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=tiberiu.a.breana@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.