linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: linux-iio@vger.kernel.org, sean@geanix.com, martin@geanix.com,
	rjones@gateworks.com, lorenzo.bianconi@redhat.com,
	devicetree@vger.kernel.org
Subject: Re: [PATCH 07/13] iio: imu: st_lsm6dsx: rely on st_lsm6dsx_update_bits_locked configuring events
Date: Sat, 12 Oct 2019 13:22:48 +0100	[thread overview]
Message-ID: <20191012132248.2831a23a@archlinux> (raw)
In-Reply-To: <903ebb1b14412abdee3029417ae146515e49c685.1570367532.git.lorenzo@kernel.org>

On Sun,  6 Oct 2019 15:22:01 +0200
Lorenzo Bianconi <lorenzo@kernel.org> wrote:

> Rely on st_lsm6dsx_update_bits_locked in st_lsm6dsx_write_event and
> st_lsm6dsx_event_setup routines since they can run concurrently with
> sensor hub configuration
> 
> Fixes: b5969abfa8b8 ("iio: imu: st_lsm6dsx: add motion events")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 25 +++++++++++---------
>  1 file changed, 14 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 7e9e1ef81742..023646762b4a 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -1483,6 +1483,7 @@ static int st_lsm6dsx_write_raw(struct iio_dev *iio_dev,
>  static int st_lsm6dsx_event_setup(struct st_lsm6dsx_hw *hw, int state)
>  {
>  	const struct st_lsm6dsx_reg *reg;
> +	unsigned int data;
>  	int err;
>  
>  	if (!hw->settings->irq_config.irq1_func.addr)
> @@ -1490,17 +1491,17 @@ static int st_lsm6dsx_event_setup(struct st_lsm6dsx_hw *hw, int state)
>  
>  	reg = &hw->settings->event_settings.enable_reg;
>  	if (reg->addr) {
> -		err = regmap_update_bits(hw->regmap, reg->addr, reg->mask,
> -					 ST_LSM6DSX_SHIFT_VAL(state, reg->mask));
> +		data = ST_LSM6DSX_SHIFT_VAL(state, reg->mask);
> +		err = st_lsm6dsx_update_bits_locked(hw, reg->addr,
> +						    reg->mask, data);
>  		if (err < 0)
>  			return err;
>  	}
>  
>  	/* Enable wakeup interrupt */
> -	return regmap_update_bits(hw->regmap, hw->irq_routing->addr,
> -				  hw->irq_routing->mask,
> -				  ST_LSM6DSX_SHIFT_VAL(state,
> -					hw->irq_routing->mask));
> +	data = ST_LSM6DSX_SHIFT_VAL(state, hw->irq_routing->mask);
> +	return st_lsm6dsx_update_bits_locked(hw, hw->irq_routing->addr,
> +					     hw->irq_routing->mask, data);
>  }
>  
>  static int st_lsm6dsx_read_event(struct iio_dev *iio_dev,
> @@ -1531,6 +1532,8 @@ static int st_lsm6dsx_write_event(struct iio_dev *iio_dev,
>  {
>  	struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);
>  	struct st_lsm6dsx_hw *hw = sensor->hw;
> +	const struct st_lsm6dsx_reg *reg;
> +	unsigned int data;
>  	int err;
>  
>  	if (type != IIO_EV_TYPE_THRESH)
> @@ -1539,11 +1542,11 @@ static int st_lsm6dsx_write_event(struct iio_dev *iio_dev,
>  	if (val < 0 || val > 31)
>  		return -EINVAL;
>  
> -	err = regmap_update_bits(hw->regmap,
> -				 hw->settings->event_settings.wakeup_reg.addr,
> -				 hw->settings->event_settings.wakeup_reg.mask,
> -				 val);
> -	if (err)
> +	reg = &hw->settings->event_settings.wakeup_reg;
> +	data = ST_LSM6DSX_SHIFT_VAL(val, reg->mask);
> +	err = st_lsm6dsx_update_bits_locked(hw, reg->addr,
> +					    reg->mask, data);
> +	if (err < 0)
>  		return -EINVAL;
>  
>  	hw->event_threshold = val;


  reply	other threads:[~2019-10-12 12:22 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-06 13:21 [PATCH 00/13] various st_lsm6dsx fixes and missing bits Lorenzo Bianconi
2019-10-06 13:21 ` [PATCH 01/13] iio: imu: st_lsm6dsx: use st_lsm6dsx_read_locked in st_lsm6dsx_report_motion_event Lorenzo Bianconi
2019-10-07  7:54   ` Sean Nyekjaer
2019-10-12 12:08   ` Jonathan Cameron
2019-10-06 13:21 ` [PATCH 02/13] iio: imu: st_lsm6dsx: add sanity check for read_fifo pointer Lorenzo Bianconi
2019-10-06 13:21 ` [PATCH 03/13] iio: imu: st_lsm6dsx: move irq related definitions in irq_config Lorenzo Bianconi
2019-10-07  7:54   ` Sean Nyekjaer
2019-10-12 12:13     ` Jonathan Cameron
2019-10-06 13:21 ` [PATCH 04/13] iio: imu: st_lsm6dsx: do not access active-low/open-drain regs if not supported Lorenzo Bianconi
2019-10-12 12:14   ` Jonathan Cameron
2019-10-06 13:21 ` [PATCH 05/13] iio: imu: st_lsm6dsx: move bdu/boot and reset register info in hw_settings Lorenzo Bianconi
2019-10-12 12:19   ` Jonathan Cameron
2019-10-06 13:22 ` [PATCH 06/13] iio: imu: st_lsm6dsx: always check enable_reg in st_lsm6dsx_event_setup Lorenzo Bianconi
2019-10-07  7:55   ` Sean Nyekjaer
2019-10-12 12:21     ` Jonathan Cameron
2019-10-06 13:22 ` [PATCH 07/13] iio: imu: st_lsm6dsx: rely on st_lsm6dsx_update_bits_locked configuring events Lorenzo Bianconi
2019-10-12 12:22   ` Jonathan Cameron [this message]
2019-10-06 13:22 ` [PATCH 08/13] iio: imu: st_lsm6dsx: grab conf mutex in st_lsm6dsx_write_event_config Lorenzo Bianconi
2019-10-12 12:23   ` Jonathan Cameron
2019-10-06 13:22 ` [PATCH 09/13] iio: imu: st_lsm6dsx: fix checkpatch warning Lorenzo Bianconi
2019-10-12 12:24   ` Jonathan Cameron
2019-10-06 13:22 ` [PATCH 10/13] iio: imu: st_lsm6dsx: add wakeup_source in st_sensors_platform_data Lorenzo Bianconi
2019-10-12 12:25   ` Jonathan Cameron
2019-10-06 13:22 ` [PATCH 11/13] iio: imu: st_lsm6dsx: add missing kernel documenation Lorenzo Bianconi
2019-10-07  7:56   ` Sean Nyekjaer
2019-10-12 12:26     ` Jonathan Cameron
2019-10-06 13:22 ` [PATCH 12/13] dt-bindings: iio: imu: st_lsm6dsx: document missing wakeup-source property Lorenzo Bianconi
2019-10-07  7:56   ` Sean Nyekjaer
2019-10-15 20:34   ` Rob Herring
2019-10-06 13:22 ` [PATCH 13/13] iio: imu: st_lsm6dsx: enable wake-up event for LSM6DSO Lorenzo Bianconi
2019-10-12 12:28   ` Jonathan Cameron
2019-10-12 12:20 ` [PATCH 00/13] various st_lsm6dsx fixes and missing bits Jonathan Cameron
2019-10-12 12:26   ` Lorenzo Bianconi
2019-10-12 13:26     ` 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=20191012132248.2831a23a@archlinux \
    --to=jic23@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=lorenzo@kernel.org \
    --cc=martin@geanix.com \
    --cc=rjones@gateworks.com \
    --cc=sean@geanix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).