public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Vasileios Amoiridis <vassilisamir@gmail.com>
Cc: lars@metafoo.de, andriy.shevchenko@linux.intel.com,
	ang.iglesiasg@gmail.com, mazziesaccount@gmail.com,
	ak@it-klinger.de, petre.rodan@subdimension.ro,
	phil@raspberrypi.com, 579lpy@gmail.com,
	u.kleine-koenig@pengutronix.de, biju.das.jz@bp.renesas.com,
	linus.walleij@linaro.org, semen.protsenko@linaro.org,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 6/6] iio: pressure: bmp280: Add triggered buffer support
Date: Sat, 13 Apr 2024 18:06:51 +0100	[thread overview]
Message-ID: <20240413180651.1eedce99@jic23-huawei> (raw)
In-Reply-To: <20240407172920.264282-7-vassilisamir@gmail.com>

On Sun,  7 Apr 2024 19:29:20 +0200
Vasileios Amoiridis <vassilisamir@gmail.com> wrote:

> BMP2xx, BME280, BMP3xx, and BMP5xx use continuous buffers for their
> temperature, pressure and humidity readings. This facilitates the
> use of burst/bulk reads in order to acquire data faster. The
> approach is different from the one used in oneshot captures.
> 
> BMP085 & BMP1xx devices use a completely different measurement
> process that is well defined and is used in their buffer_handler().
> 
> Suggested-by: Angel Iglesias <ang.iglesiasg@gmail.com>
> Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Hi,

A few things inline.

Jonathan

> ---
>  drivers/iio/pressure/Kconfig       |   2 +
>  drivers/iio/pressure/bmp280-core.c | 338 +++++++++++++++++++++++++++--
>  drivers/iio/pressure/bmp280-spi.c  |   8 +-
>  drivers/iio/pressure/bmp280.h      |  21 +-
>  4 files changed, 347 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig
> index 3ad38506028e..0b5406a3f85d 100644
> --- a/drivers/iio/pressure/Kconfig
> +++ b/drivers/iio/pressure/Kconfig
> @@ -31,6 +31,8 @@ config BMP280
>  	select REGMAP
>  	select BMP280_I2C if (I2C)
>  	select BMP280_SPI if (SPI_MASTER)
> +	select IIO_BUFFER
> +	select IIO_TRIGGERED_BUFFER
>  	help
>  	  Say yes here to build support for Bosch Sensortec BMP180, BMP280, BMP380
>  	  and BMP580 pressure and temperature sensors. Also supports the BME280 with
> diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
> index 1b894feb717b..32dd35475826 100644
> --- a/drivers/iio/pressure/bmp280-core.c
> +++ b/drivers/iio/pressure/bmp280-core.c
> @@ -41,7 +41,10 @@

>
> 
>  
> +static irqreturn_t bmp580_buffer_handler(int irq, void *p)
> +{
> +	struct iio_poll_func *pf = p;
> +	struct iio_dev *indio_dev = pf->indio_dev;
> +	struct bmp280_data *data = iio_priv(indio_dev);
> +	s32 adc_temp, adc_press;
> +	int ret;
> +
> +	guard(mutex)(&data->lock);
> +
> +	/* If humidity channel is enabled it means that we are called for the
> +	 * BME280 humidity sensor.
Please match IIO multiline comment syntax. Like most of the kernel.

	/*
	 * If ...

> +	 */
> +



...

> diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h
> index ccba779d7a83..0373d5f9b9a8 100644
> --- a/drivers/iio/pressure/bmp280.h
> +++ b/drivers/iio/pressure/bmp280.h
> @@ -301,6 +301,16 @@

>  /* Core exported structs */
>  
>  static const char *const bmp280_supply_names[] = {
> @@ -394,13 +404,19 @@ struct bmp280_data {
>  	 */
>  	int sampling_freq;
>  
> +	/*
> +	 * Data to push to userspace triggered buffer. Up to 3 channels and
> +	 * s64 timestamp, aligned.
> +	 */
> +	s32 sensor_data[5] __aligned(8);
For the timestamp to be aligned (which is the reason this is __aligned(8))
when landing at the end of the buffer, the buffer needs to be a multiple of 8
bytes.

3 channel, 32bit padding, s64 timestamp. So [6]

On the todo list is to add runtime checking to the IIO core on these buffers
being big enough which would have caught this, but I haven't gotten started
on that project yet.

Jonathan
> +

  reply	other threads:[~2024-04-13 17:07 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-07 17:29 [PATCH v4 0/6] Driver cleanup and series to add triggered buffer Vasileios Amoiridis
2024-04-07 17:29 ` [PATCH v4 1/6] iio: pressure: bmp280: Various driver cleanups Vasileios Amoiridis
2024-04-13 16:52   ` Jonathan Cameron
2024-04-14 16:19     ` Vasileios Amoiridis
2024-04-14 18:13       ` Jonathan Cameron
2024-04-14 23:41     ` Vasileios Amoiridis
2024-04-07 17:29 ` [PATCH v4 2/6] iio: pressure: bmp280: Refactorize reading functions Vasileios Amoiridis
2024-04-13 16:56   ` Jonathan Cameron
2024-04-07 17:29 ` [PATCH v4 3/6] iio: pressure: bmp280: Introduce new cleanup routines Vasileios Amoiridis
2024-04-13 16:58   ` Jonathan Cameron
2024-04-07 17:29 ` [PATCH v4 4/6] iio: pressure: bmp280: Generalize read_{temp,press,humid}() functions Vasileios Amoiridis
2024-04-07 17:29 ` [PATCH v4 5/6] iio: pressure: bmp280: Add SCALE, RAW values in channels and refactorize them Vasileios Amoiridis
2024-04-07 17:29 ` [PATCH v4 6/6] iio: pressure: bmp280: Add triggered buffer support Vasileios Amoiridis
2024-04-13 17:06   ` Jonathan Cameron [this message]
2024-04-07 21:51 ` [PATCH v4 0/6] Driver cleanup and series to add triggered buffer Angel Iglesias
2024-04-08 15:01   ` Andy Shevchenko
2024-04-08 16:58     ` Vasileios Amoiridis

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=20240413180651.1eedce99@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=579lpy@gmail.com \
    --cc=ak@it-klinger.de \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ang.iglesiasg@gmail.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mazziesaccount@gmail.com \
    --cc=petre.rodan@subdimension.ro \
    --cc=phil@raspberrypi.com \
    --cc=semen.protsenko@linaro.org \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=vassilisamir@gmail.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