All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Sean Nyekjaer <sean@geanix.com>
Cc: linux-iio@vger.kernel.org, jic23@kernel.org,
	lorenzo.bianconi83@gmail.com, denis.ciocca@st.com,
	mario.tesi@st.com, armando.visconti@st.com, martin@geanix.com
Subject: Re: [RFC PATCH] iio: imu: st_lsm6dsx: filter motion events in driver
Date: Mon, 16 Sep 2019 14:22:14 +0200	[thread overview]
Message-ID: <20190916122214.GD16063@localhost.localdomain> (raw)
In-Reply-To: <88815877-abde-8e2a-cb3d-fabb556ad7e5@geanix.com>

[-- Attachment #1: Type: text/plain, Size: 2968 bytes --]

On Sep 16, Sean Nyekjaer wrote:
> 
> 
> On 16/09/2019 13.55, Lorenzo Bianconi wrote:
> > > 
> > > 
> > > On 16/09/2019 11.16, Lorenzo Bianconi wrote:
> > > > > +	if (hw->event_en_mask & BIT(chan->channel2))
> > > > > +		goto out;
> > > > Why do we need this?
> > > > 
> > > 
> > > Guess we need to check if 0 < hw->enable_event before disabling the
> > > sensor...
> > > > > +
> > > > >    	/* do not enable events if they are already enabled */
> > > > >    	if (state && hw->enable_event)
> > > > > -		return 0;
> > > > > +		goto out;
> > > 
> > > static int st_lsm6dsx_write_event_config(struct iio_dev *iio_dev,
> > >                                             const struct iio_chan_spec *chan,
> > >                                             enum iio_event_type type,
> > >                                             enum iio_event_direction dir,
> > >                                             int state)
> > > {
> > >          struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);
> > >          struct st_lsm6dsx_hw *hw = sensor->hw;
> > >          u8 _enable_event;
> > 
> > please use enable_event instead of _enable_event
> > 
> > >          int err = 0;
> > > 
> > >          if (type != IIO_EV_TYPE_THRESH)
> > >                  return -EINVAL;
> > > 
> > >          if (state) {
> > >                  _enable_event = hw->enable_event | BIT(chan->channel2);
> > > 
> > >                  /* do not enable events if they are already enabled */
> > >                  if (0 < hw->enable_event)
> > >                          goto out;
> > 
> > we do not need this since there is the check:
> > if (hw->enable_event == enable_event)
> > 	return 0;
> 
> I actually think this is needed as if a channel is enabled and another
> channel is enabled, then 'state' will be 1 and '0 < hw->enable_event' is
> true. Then we don't want to do the event_setup again.

got what you mean here, right..just please do:

if (hw->enable_event)
	goto out;

> 
> > 
> > >          } else {
> > >                  _enable_event = hw->enable_event & ~BIT(chan->channel2);
> > > 
> > >                  /* only turn off sensor if no events is enabled */
> > > 
> > > 
> > > 
> > > 
> > >                  if (0 != _enable_event)
> > >                          goto out;

if (enable_event)
	goto out;

> > 
> > we do not need this as well
> Like wise here, if we don't have this and to channels is enabled, if you
> deactivate one of the channels then enable_event indicates that a channel is
> active but the sensor is disabled.
> Guess that is not what we want :-)
> 
> > 
> > >          }
> > > 
> > >          /* stop here if no changes have been made */
> > >          if (hw->enable_event == _enable_event)
> > >                  return 0;
> > > 
> > >          err = st_lsm6dsx_event_setup(hw, state);
> > >          if (err < 0)
> > >                  return err;
> > > 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-13  9:07 [PATCH v8 0/5] enable motion events for st_lsm6dsx Sean Nyekjaer
2019-09-13  9:07 ` [PATCH v8 1/5] iio: imu: st_lsm6dsx: move interrupt thread to core Sean Nyekjaer
2019-09-13  9:07 ` [PATCH v8 2/5] iio: imu: st_lsm6dsx: add motion events Sean Nyekjaer
2019-09-13  9:07 ` [PATCH v8 3/5] iio: imu: st_lsm6dsx: add wakeup-source option Sean Nyekjaer
2019-09-15 13:42   ` Lorenzo Bianconi
2019-09-13  9:07 ` [PATCH v8 4/5] iio: imu: st_lsm6dsx: always enter interrupt thread Sean Nyekjaer
2019-09-15 12:33   ` Jonathan Cameron
2019-09-15 12:48     ` Lorenzo Bianconi
2019-09-15 13:00       ` Jonathan Cameron
2019-09-15 13:07         ` Lorenzo Bianconi
2019-09-13  9:07 ` [PATCH v8 5/5] iio: imu: st_lsm6dsx: add motion report function and call from interrupt Sean Nyekjaer
2019-09-15 12:30   ` Jonathan Cameron
2019-09-15 13:05     ` Lorenzo Bianconi
2019-09-15 13:18       ` Jonathan Cameron
2019-09-15 13:22         ` Sean Nyekjaer
2019-09-15 13:35           ` Jonathan Cameron
2019-09-16  9:02             ` [RFC PATCH] iio: imu: st_lsm6dsx: filter motion events in driver Sean Nyekjaer
2019-09-16  9:16               ` Lorenzo Bianconi
2019-09-16 11:29                 ` Sean Nyekjaer
2019-09-16 11:55                   ` Lorenzo Bianconi
2019-09-16 12:09                     ` Sean Nyekjaer
2019-09-16 12:22                       ` Lorenzo Bianconi [this message]
2019-09-15 13:41         ` [PATCH v8 5/5] iio: imu: st_lsm6dsx: add motion report function and call from interrupt Lorenzo Bianconi

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=20190916122214.GD16063@localhost.localdomain \
    --to=lorenzo@kernel.org \
    --cc=armando.visconti@st.com \
    --cc=denis.ciocca@st.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=lorenzo.bianconi83@gmail.com \
    --cc=mario.tesi@st.com \
    --cc=martin@geanix.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 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.