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 11:16:49 +0200 [thread overview] Message-ID: <20190916091649.GA16063@localhost.localdomain> (raw) In-Reply-To: <20190916090222.597444-1-sean@geanix.com> [-- Attachment #1: Type: text/plain, Size: 3576 bytes --] > Do not report non enabled motion events. > Wakeup will still be on all channels as it's not possible to do the > filtering in hw. > > Signed-off-by: Sean Nyekjaer <sean@geanix.com> > --- > Hope it's okay to do this as an RFC. To get the most obvious stuff > reviewed before v9 > > drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 1 + > drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 20 ++++++++++++++++---- > 2 files changed, 17 insertions(+), 4 deletions(-) > > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h > index 938192212485..dd46209f94e8 100644 > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h > @@ -362,6 +362,7 @@ struct st_lsm6dsx_hw { > > u8 event_threshold; > bool enable_event; > + u8 event_en_mask; I think we do not need it, you could just use enable_event as bitmask (just convert it in u8) > struct st_lsm6dsx_reg irq_routing; > > u8 *buff; > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c > index 7596a6ed7d97..2d66e3758921 100644 > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c > @@ -1377,9 +1377,12 @@ static int st_lsm6dsx_write_event_config(struct iio_dev *iio_dev, > if (type != IIO_EV_TYPE_THRESH) > return -EINVAL; > > + if (hw->event_en_mask & BIT(chan->channel2)) > + goto out; Why do we need this? > + > /* do not enable events if they are already enabled */ > if (state && hw->enable_event) > - return 0; > + goto out; > > err = st_lsm6dsx_event_setup(hw, state); > if (err < 0) > @@ -1391,6 +1394,12 @@ static int st_lsm6dsx_write_event_config(struct iio_dev *iio_dev, > > hw->enable_event = state; > > +out: > + if (state) > + hw->event_en_mask |= BIT(chan->channel2); > + else > + hw->event_en_mask &= ~BIT(chan->channel2); you can use enable_event here instead of event_en_mask > + > return 0; > } > > @@ -1746,7 +1755,8 @@ void st_lsm6dsx_report_motion_event(struct st_lsm6dsx_hw *hw, int data) > { > s64 timestamp = iio_get_time_ns(hw->iio_devs[ST_LSM6DSX_ID_ACC]); > > - if (data & hw->settings->event_settings.wakeup_src_z_mask) > + if (data & hw->settings->event_settings.wakeup_src_z_mask && > + hw->event_en_mask & BIT(IIO_MOD_Z)) please add () if ((data & hw->settings->event_settings.wakeup_src_z_mask) && (hw->event_en_mask & BIT(IIO_MOD_Z)) > iio_push_event(hw->iio_devs[ST_LSM6DSX_ID_ACC], > IIO_MOD_EVENT_CODE(IIO_ACCEL, > 0, > @@ -1755,7 +1765,8 @@ void st_lsm6dsx_report_motion_event(struct st_lsm6dsx_hw *hw, int data) > IIO_EV_DIR_EITHER), > timestamp); > > - if (data & hw->settings->event_settings.wakeup_src_y_mask) > + if (data & hw->settings->event_settings.wakeup_src_y_mask && > + hw->event_en_mask & BIT(IIO_MOD_Y)) > iio_push_event(hw->iio_devs[ST_LSM6DSX_ID_ACC], > IIO_MOD_EVENT_CODE(IIO_ACCEL, > 0, > @@ -1764,7 +1775,8 @@ void st_lsm6dsx_report_motion_event(struct st_lsm6dsx_hw *hw, int data) > IIO_EV_DIR_EITHER), > timestamp); > > - if (data & hw->settings->event_settings.wakeup_src_x_mask) > + if (data & hw->settings->event_settings.wakeup_src_x_mask && > + hw->event_en_mask & BIT(IIO_MOD_X)) > iio_push_event(hw->iio_devs[ST_LSM6DSX_ID_ACC], > IIO_MOD_EVENT_CODE(IIO_ACCEL, > 0, > -- > 2.23.0 > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2019-09-16 9:16 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 [this message] 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 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=20190916091649.GA16063@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 \ --subject='Re: [RFC PATCH] iio: imu: st_lsm6dsx: filter motion events in driver' \ /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
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).