The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Petre Rodan <petre.rodan@subdimension.ro>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Jagath Jog J" <jagathjog1996@gmail.com>
Subject: Re: [PATCH 3/6] iio: accel: bma220: add tap detection
Date: Sat, 1 Nov 2025 09:56:42 +0200	[thread overview]
Message-ID: <aQW9OnJSrOzn_Sws@lipo.home.arpa> (raw)
In-Reply-To: <20251018181632.76851d4e@jic23-huawei>

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


Hello Jonathan,

thank you for the review.

On Sat, Oct 18, 2025 at 06:16:32PM +0100, Jonathan Cameron wrote:
> > +			ret = regmap_read(data->regmap, BMA220_REG_CONF3, &reg_val);
> > +			if (ret)
> > +				return ret;
> > +			*val = FIELD_GET(BMA220_TT_DUR_MSK, reg_val);
> 
> This needs to be in second if you are using duration. Is the register really in seconds?

this IC has a very small number of bits that configure duration/hysteresis/threshold levels. it's between 2 and 6 for each of them. in the case of high and low G events the duration is not even directly defined as a time interval, but as a count of samples that are over a threshold value.

I was hoping that simply passing along a unitless value between 0 and parameter_max would be enough to customize all the event parameters. this does mean that the driver makes the assumption that the user is familiar with the device datasheet and knows the number of bits every parameter has been allocated. should the driver provide a conversion table for tt_duration just like for _scale_table and _lpf_3dB_freq_Hz_table?

> > @@ -506,13 +777,36 @@ static irqreturn_t bma220_irq_handler(int irq, void *private)
> >  	struct bma220_data *data = iio_priv(indio_dev);
> >  	int ret;
> >  	unsigned int bma220_reg_if1;
> > +	s64 timestamp = iio_get_time_ns(indio_dev);
> > +
> > +	guard(mutex)(&data->lock);
> >  
> >  	ret = regmap_read(data->regmap, BMA220_REG_IF1, &bma220_reg_if1);
> >  	if (ret)
> >  		return IRQ_NONE;
> >  
> > -	if (FIELD_GET(BMA220_IF_DRDY, bma220_reg_if1))
> > +	if (FIELD_GET(BMA220_IF_DRDY, bma220_reg_if1)) {
> 
> Is it an either / or case? I.e. we can only have buffered reads with
> the data ready interrupt or events?   That does happen in some devices
> but is fairly unusual.

the driver got an interrupt, so it checks the source - it's either a data ready when the sensor is used to sample the environment or it's an event in which case it just sets the event.
now that you mention it I think I would miss events if both happened before the kernel executes the _irq_handler(), so I will rewrite this bit. if you ment something else please tell me.

best regards,
peter

> 
> >  		iio_trigger_poll_nested(data->trig);
> > +		return IRQ_HANDLED;
> > +	}
> > +
> > +	if (FIELD_GET(BMA220_IF_TT, bma220_reg_if1)) {
> > +
> > +		if (data->tap_type == BMA220_TAP_TYPE_SINGLE)
> > +			iio_push_event(indio_dev,
> > +				       IIO_MOD_EVENT_CODE(IIO_ACCEL, 0,
> > +							  IIO_MOD_X_OR_Y_OR_Z,
> > +							  IIO_EV_TYPE_GESTURE,
> > +							  IIO_EV_DIR_SINGLETAP),
> > +				       timestamp);
> > +		else
> > +			iio_push_event(indio_dev,
> > +				       IIO_MOD_EVENT_CODE(IIO_ACCEL, 0,
> > +							  IIO_MOD_X_OR_Y_OR_Z,
> > +							  IIO_EV_TYPE_GESTURE,
> > +							  IIO_EV_DIR_DOUBLETAP),
> > +				       timestamp);
> > +	}
> >  
> >  	return IRQ_HANDLED;
> >  }
> > 
> 

-- 
petre rodan

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

  reply	other threads:[~2025-11-01  7:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14 16:42 [PATCH 0/6] iio: accel: bma220: add events Petre Rodan
2025-10-14 16:42 ` [PATCH 1/6] iio: accel: bma220: white space cleanup Petre Rodan
2025-10-18 16:55   ` Jonathan Cameron
2025-10-14 16:42 ` [PATCH 2/6] iio: accel: bma220: remove useless include Petre Rodan
2025-10-18 16:55   ` Jonathan Cameron
2025-10-14 16:42 ` [PATCH 3/6] iio: accel: bma220: add tap detection Petre Rodan
2025-10-18 17:16   ` Jonathan Cameron
2025-11-01  7:56     ` Petre Rodan [this message]
2025-11-02 12:20       ` Jonathan Cameron
2025-11-07  0:30         ` Petre Rodan
2025-11-09 12:41           ` Jonathan Cameron
2025-10-14 16:43 ` [PATCH 4/6] iio: accel: bma220: add low-g event detection Petre Rodan
2025-10-18 17:20   ` Jonathan Cameron
2025-10-18 17:22   ` Jonathan Cameron
2025-10-14 16:43 ` [PATCH 5/6] iio: accel: bma220: add high-g " Petre Rodan
2025-10-14 16:43 ` [PATCH 6/6] iio: accel: bma220: add any-motion detection Petre Rodan
2025-10-18 17:32   ` 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=aQW9OnJSrOzn_Sws@lipo.home.arpa \
    --to=petre.rodan@subdimension.ro \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jagathjog1996@gmail.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.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