linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Jagath Jog J <jagathjog1996@gmail.com>
Cc: dan@dlrobertson.com, andy.shevchenko@gmail.com,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 6/9] iio: accel: bma400: Add step change event
Date: Sun, 1 May 2022 17:31:10 +0100	[thread overview]
Message-ID: <20220501173110.67a18bf9@jic23-huawei> (raw)
In-Reply-To: <20220420211105.14654-7-jagathjog1996@gmail.com>

On Thu, 21 Apr 2022 02:41:02 +0530
Jagath Jog J <jagathjog1996@gmail.com> wrote:

> Added support for event when there is a detection of step change.
> INT1 pin is used to interrupt and event is pushed to userspace.
> 
> Signed-off-by: Jagath Jog J <jagathjog1996@gmail.com>
Hi Jagath,

A query about handling of multiple interrupts...

> ---
>  drivers/iio/accel/bma400.h      |  2 +
>  drivers/iio/accel/bma400_core.c | 75 +++++++++++++++++++++++++++++++++
>  2 files changed, 77 insertions(+)
> 
>   * Read-write configuration registers
> diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c
> index aafb5a40944d..fe101df7b773 100644
> --- a/drivers/iio/accel/bma400_core.c
> +++ b/drivers/iio/accel/bma400_core.c

>  
>  static const struct iio_trigger_ops bma400_trigger_ops = {
> @@ -971,6 +1035,7 @@ static irqreturn_t bma400_interrupt(int irq, void *private)
>  {
>  	struct iio_dev *indio_dev = private;
>  	struct bma400_data *data = iio_priv(indio_dev);
> +	s64 timestamp = iio_get_time_ns(indio_dev);
>  	int ret;
>  
>  	/* Lock to protect the data->status */
> @@ -981,6 +1046,16 @@ static irqreturn_t bma400_interrupt(int irq, void *private)
>  	if (ret)
>  		goto unlock_err;
>  
> +	if (FIELD_GET(BMA400_STEP_STAT_MASK, le16_to_cpu(data->status))) {
> +		iio_push_event(indio_dev,
> +			       IIO_EVENT_CODE(IIO_STEPS, 0, IIO_NO_MOD,
> +					      IIO_EV_DIR_NONE,
> +					      IIO_EV_TYPE_CHANGE, 0, 0, 0),
> +			       timestamp);
> +		mutex_unlock(&data->mutex);

Is it possible for two interrupt sources to be active at the same time?
Given the device is clearing interrupts on read (which is unusual enough to
make me check that on the datasheet) you will loose any other events.

Normal trick is to act on all set bits and if any of them were acted on
return HANDLED.

> +		return IRQ_HANDLED;
> +	}
> +
>  	if (FIELD_GET(BMA400_INT_DRDY_MSK, le16_to_cpu(data->status))) {
>  		mutex_unlock(&data->mutex);
>  		iio_trigger_poll_chained(data->trig);


  reply	other threads:[~2022-05-01 16:23 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20 21:10 [PATCH v4 0/9] iio: accel: bma400: Add buffer, step and activity/inactivity Jagath Jog J
2022-04-20 21:10 ` [PATCH v4 1/9] iio: accel: bma400: Fix the scale min and max macro values Jagath Jog J
2022-04-27 12:28   ` Andy Shevchenko
2022-04-20 21:10 ` [PATCH v4 2/9] iio: accel: bma400: Reordering of header files Jagath Jog J
2022-04-20 21:10 ` [PATCH v4 3/9] iio: accel: bma400: conversion to device-managed function Jagath Jog J
2022-04-20 21:11 ` [PATCH v4 4/9] iio: accel: bma400: Add triggered buffer support Jagath Jog J
2022-04-27 12:34   ` Andy Shevchenko
2022-05-01 16:20     ` Jonathan Cameron
2022-05-01 20:25       ` Jagath Jog J
2022-05-07 16:00         ` Jonathan Cameron
2022-04-20 21:11 ` [PATCH v4 5/9] iio: accel: bma400: Add separate channel for step counter Jagath Jog J
2022-04-27 12:34   ` Andy Shevchenko
2022-04-27 21:01     ` Jagath Jog J
2022-04-20 21:11 ` [PATCH v4 6/9] iio: accel: bma400: Add step change event Jagath Jog J
2022-05-01 16:31   ` Jonathan Cameron [this message]
2022-05-01 20:27     ` Jagath Jog J
2022-04-20 21:11 ` [PATCH v4 7/9] iio: accel: bma400: Add activity recognition support Jagath Jog J
2022-04-20 21:11 ` [PATCH v4 8/9] iio: accel: bma400: Add debugfs register access support Jagath Jog J
2022-05-01 16:34   ` Jonathan Cameron
2022-04-20 21:11 ` [PATCH v4 9/9] iio: accel: bma400: Add support for activity and inactivity events Jagath Jog J
2022-04-21  6:45   ` kernel test robot
2022-04-24 16:20     ` Jonathan Cameron
2022-04-27  3:01       ` Jagath Jog J
2022-04-27 13:45         ` Andy Shevchenko
2022-04-26 11:04 ` [PATCH v4 0/9] iio: accel: bma400: Add buffer, step and activity/inactivity Andy Shevchenko
2022-04-26 11:05   ` Andy Shevchenko
2022-04-26 12:28     ` Jagath Jog J
2022-05-01 16:36 ` 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=20220501173110.67a18bf9@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=dan@dlrobertson.com \
    --cc=jagathjog1996@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).