All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Benson Leung <bleung@google.com>
Cc: Thierry Escande <thierry.escande@collabora.com>,
	Benson Leung <bleung@chromium.org>,
	Lee Jones <lee.jones@linaro.org>,
	linux-kernel@vger.kernel.org, gwendal@chromium.org,
	linux-iio@vger.kernel.org
Subject: Re: [PATCH 1/8] iio: cros_ec: Relax sampling frequency before suspending
Date: Sat, 12 Aug 2017 13:41:18 +0100	[thread overview]
Message-ID: <20170812134118.7bee61bd@archlinux> (raw)
In-Reply-To: <20170811032556.GA9629@decatoncale.mtv.corp.google.com>

On Thu, 10 Aug 2017 20:25:56 -0700
Benson Leung <bleung@google.com> wrote:

> Hi Thierry,
> 
> On Fri, Aug 11, 2017 at 12:16:43AM +0200, Thierry Escande wrote:
> > From: Gwendal Grignou <gwendal@chromium.org>
> > 
> > If an application set a tight sampling frequency, given the interrupt
> > use is a wakup source, suspend will not happen: the kernel will receive
> > a wake up interrupt and will cancel the suspend process.
> > 
> > Given cros_ec sensors type is non wake up, this patch adds prepare and
> > complete callbacks to set 1s sampling period just before suspend. This
> > ensures the sensor hub will not be a source of interrupt during the
> > suspend process.
> > 
> > Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> > Signed-off-by: Thierry Escande <thierry.escande@collabora.com>  
> 
> Remember to copy the original author, Gwendal Also, this is an iio patch,
> so you should make sure to send this to linux-iio@vger.kernel.org and to 
> Jonathan Cameron <jic23@kernel.org> as well.
Thanks,

Looks fine to me
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> > ---
> >  .../iio/common/cros_ec_sensors/cros_ec_sensors.c   |  1 +
> >  .../common/cros_ec_sensors/cros_ec_sensors_core.c  | 49 ++++++++++++++++++++++
> >  .../common/cros_ec_sensors/cros_ec_sensors_core.h  |  2 +
> >  drivers/iio/light/cros_ec_light_prox.c             |  1 +
> >  4 files changed, 53 insertions(+)
> > 
> > diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
> > index 38e8783..116da2c 100644
> > --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
> > +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
> > @@ -292,6 +292,7 @@ MODULE_DEVICE_TABLE(platform, cros_ec_sensors_ids);
> >  static struct platform_driver cros_ec_sensors_platform_driver = {
> >  	.driver = {
> >  		.name	= "cros-ec-sensors",
> > +		.pm	= &cros_ec_sensors_pm_ops,
> >  	},
> >  	.probe		= cros_ec_sensors_probe,
> >  	.id_table	= cros_ec_sensors_ids,
> > diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> > index 416cae5..a620eb5 100644
> > --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> > +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> > @@ -446,5 +446,54 @@ int cros_ec_sensors_core_write(struct cros_ec_sensors_core_state *st,
> >  }
> >  EXPORT_SYMBOL_GPL(cros_ec_sensors_core_write);
> >  
> > +static int __maybe_unused cros_ec_sensors_prepare(struct device *dev)
> > +{
> > +	struct platform_device *pdev = to_platform_device(dev);
> > +	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> > +	struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
> > +
> > +	if (st->curr_sampl_freq == 0)
> > +		return 0;
> > +
> > +	/*
> > +	 * If the sensors are sampled at high frequency, we will not be able to
> > +	 * sleep. Set sampling to a long period if necessary.
> > +	 */
> > +	if (st->curr_sampl_freq < CROS_EC_MIN_SUSPEND_SAMPLING_FREQUENCY) {
> > +		mutex_lock(&st->cmd_lock);
> > +		st->param.cmd = MOTIONSENSE_CMD_EC_RATE;
> > +		st->param.ec_rate.data = CROS_EC_MIN_SUSPEND_SAMPLING_FREQUENCY;
> > +		cros_ec_motion_send_host_cmd(st, 0);
> > +		mutex_unlock(&st->cmd_lock);
> > +	}
> > +	return 0;
> > +}
> > +
> > +static void __maybe_unused cros_ec_sensors_complete(struct device *dev)
> > +{
> > +	struct platform_device *pdev = to_platform_device(dev);
> > +	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> > +	struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
> > +
> > +	if (st->curr_sampl_freq == 0)
> > +		return;
> > +
> > +	if (st->curr_sampl_freq < CROS_EC_MIN_SUSPEND_SAMPLING_FREQUENCY) {
> > +		mutex_lock(&st->cmd_lock);
> > +		st->param.cmd = MOTIONSENSE_CMD_EC_RATE;
> > +		st->param.ec_rate.data = st->curr_sampl_freq;
> > +		cros_ec_motion_send_host_cmd(st, 0);
> > +		mutex_unlock(&st->cmd_lock);
> > +	}
> > +}
> > +
> > +const struct dev_pm_ops cros_ec_sensors_pm_ops = {
> > +#ifdef CONFIG_PM_SLEEP
> > +	.prepare = cros_ec_sensors_prepare,
> > +	.complete = cros_ec_sensors_complete
> > +#endif
> > +};
> > +EXPORT_SYMBOL_GPL(cros_ec_sensors_pm_ops);
> > +
> >  MODULE_DESCRIPTION("ChromeOS EC sensor hub core functions");
> >  MODULE_LICENSE("GPL v2");
> > diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.h b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.h
> > index 8bc2ca3..2edf68d 100644
> > --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.h
> > +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.h
> > @@ -169,6 +169,8 @@ int cros_ec_sensors_core_write(struct cros_ec_sensors_core_state *st,
> >  			       struct iio_chan_spec const *chan,
> >  			       int val, int val2, long mask);
> >  
> > +extern const struct dev_pm_ops cros_ec_sensors_pm_ops;
> > +
> >  /* List of extended channel specification for all sensors */
> >  extern const struct iio_chan_spec_ext_info cros_ec_sensors_ext_info[];
> >  
> > diff --git a/drivers/iio/light/cros_ec_light_prox.c b/drivers/iio/light/cros_ec_light_prox.c
> > index 7217223..f8658d4 100644
> > --- a/drivers/iio/light/cros_ec_light_prox.c
> > +++ b/drivers/iio/light/cros_ec_light_prox.c
> > @@ -279,6 +279,7 @@ MODULE_DEVICE_TABLE(platform, cros_ec_light_prox_ids);
> >  static struct platform_driver cros_ec_light_prox_platform_driver = {
> >  	.driver = {
> >  		.name	= "cros-ec-light-prox",
> > +		.pm	= &cros_ec_sensors_pm_ops,
> >  	},
> >  	.probe		= cros_ec_light_prox_probe,
> >  	.id_table	= cros_ec_light_prox_ids,
> > -- 
> > 2.7.4
> >   
> 


  reply	other threads:[~2017-08-12 12:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-10 22:16 [PATCH 0/8] platform/chrome: cros_ec: Fixes and improvements Thierry Escande
2017-08-10 22:16 ` [PATCH 1/8] iio: cros_ec: Relax sampling frequency before suspending Thierry Escande
2017-08-11  3:25   ` Benson Leung
2017-08-12 12:41     ` Jonathan Cameron [this message]
2017-08-10 22:16 ` [PATCH 2/8] mfd: cros_ec_i2c: move the system sleep pm ops to late Thierry Escande
2017-08-11  3:31   ` Benson Leung
2017-08-10 22:16 ` [PATCH 3/8] mfd: cros_ec: Stop the debugfs work when suspended Thierry Escande
2017-08-11  3:54   ` Benson Leung
2017-08-10 22:16 ` [PATCH 4/8] platform/chrome: cros_ec: register shutdown function for debugfs Thierry Escande
2017-08-11  4:01   ` Benson Leung
2017-08-10 22:16 ` [PATCH 5/8] mfd: cros_ec: fail early if we cannot identify the EC Thierry Escande
2017-08-11  4:06   ` Benson Leung
2017-08-10 22:16 ` [PATCH 6/8] mfd: cros_ec_i2c: add ACPI module device table Thierry Escande
2017-08-11  4:11   ` Benson Leung
2017-08-10 22:16 ` [PATCH 7/8] platform/chrome: cros_ec: Add sysfs entry to set keyboard wake lid angle Thierry Escande
2017-08-11  5:29   ` Benson Leung
2017-08-11 13:07     ` Thierry Escande
2017-08-10 22:16 ` [PATCH 8/8] platform/chrome: cros_ec: sysfs: Modify error handling Thierry Escande

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=20170812134118.7bee61bd@archlinux \
    --to=jic23@kernel.org \
    --cc=bleung@chromium.org \
    --cc=bleung@google.com \
    --cc=gwendal@chromium.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thierry.escande@collabora.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.