From: Vasileios Amoiridis <vassilisamir@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Vasileios Amoiridis <vassilisamir@gmail.com>,
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, linus.walleij@linaro.org,
semen.protsenko@linaro.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 10/10] iio: pressure: bmp280: Add triggered buffer support
Date: Mon, 6 May 2024 01:57:55 +0200 [thread overview]
Message-ID: <20240505235755.GC17986@vamoiridPC> (raw)
In-Reply-To: <20240505203456.0c4c0c90@jic23-huawei>
On Sun, May 05, 2024 at 08:34:56PM +0100, Jonathan Cameron wrote:
> On Mon, 29 Apr 2024 21:00:46 +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 Vasileois,
>
> Just one question on this inline. (patches 8 and 9 look good to me)
>
> For v6, only need to send the patches that I haven't already applied.
>
> Thanks,
>
> Jonathan
>
> >
> > +static irqreturn_t bmp180_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);
> > + int ret, chan_value;
> > +
> > + guard(mutex)(&data->lock);
> > +
> > + ret = bmp180_read_temp(data, &chan_value);
> > + if (ret < 0)
> > + return IRQ_HANDLED;
> > +
> > + data->sensor_data[1] = chan_value;
> > +
> > + ret = bmp180_read_press(data, &chan_value);
>
> So I 'think' that after all the refactoring you end up reading the temperature
> twice. To avoid that you need to pull the read_temp() and read_press()
> function implementations here and only do the (currently duplicated) steps once.
>
> You seem to have done this for the other case, but missed the bmp180?
> Maybe I'm missing some reason it doesn't work for this one!
>
Hi Jonathan!
So, I didn't miss it. This is an old sensor and in order to get data out, the
procedure is much more constrained. As you can see in the datasheet [1] in page
11 there is a well defined process on how to read the data out. It's not
possible to make a burst read here. Hence, the strange bmp180_measure() function
in order to wait for an EOC before reading the values. Indeed I am reading the
temperature 2 times which is not optimal but in order to read both of them I
would have to:
a) either get the temperature out of the bmp180_read_press() function
(which would ruin a bit consistency with the other bmpxxx_read_press() functions)
b) make a bmp180_get_sensor_data() which would look like bmp180_get_press() but
also gives temperature (which won't look that good).
That's why I didn't touch it. If you think it makes more sense to do it, I can
follow one of the 2 approaches, whichever you think would make more sense.
Cheers,
Vasilis
[1]: https://cdn-shop.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf
> > + if (ret < 0)
> > + return IRQ_HANDLED;
> > +
> > + data->sensor_data[0] = chan_value;
> > +
> > + iio_push_to_buffers_with_timestamp(indio_dev, &data->sensor_data,
> > + iio_get_time_ns(indio_dev));
> > +
> > + iio_trigger_notify_done(indio_dev->trig);
> > +
> > + return IRQ_HANDLED;
> > +}
next prev parent reply other threads:[~2024-05-05 23:57 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 19:00 [PATCH v5 00/10] iio: pressure: bmp280: Driver cleanup and add triggered buffer support Vasileios Amoiridis
2024-04-29 19:00 ` [PATCH v5 01/10] iio: pressure: bmp280: Improve indentation and line wrapping Vasileios Amoiridis
2024-05-05 18:51 ` Jonathan Cameron
2024-05-06 0:04 ` Vasileios Amoiridis
2024-05-06 12:38 ` Jonathan Cameron
2024-04-29 19:00 ` [PATCH v5 02/10] iio: pressure: bmp280: Use BME prefix for BME280 specifics Vasileios Amoiridis
2024-05-05 18:53 ` Jonathan Cameron
2024-04-29 19:00 ` [PATCH v5 03/10] iio: pressure: bmp280: Add identifier names in function definitions Vasileios Amoiridis
2024-05-05 18:54 ` Jonathan Cameron
2024-04-29 19:00 ` [PATCH v5 04/10] iio: pressure: bmp280: Add more intuitive name for bmp180_measure() Vasileios Amoiridis
2024-04-29 19:00 ` [PATCH v5 05/10] iio: pressure: bmp280: Make return values consistent Vasileios Amoiridis
2024-05-05 19:08 ` Jonathan Cameron
2024-05-05 23:08 ` Vasileios Amoiridis
2024-04-29 19:00 ` [PATCH v5 06/10] iio: pressure: bmp280: Refactorize reading functions Vasileios Amoiridis
2024-05-05 19:21 ` Jonathan Cameron
2024-05-05 23:47 ` Vasileios Amoiridis
2024-05-06 12:46 ` Jonathan Cameron
2024-04-29 19:00 ` [PATCH v5 07/10] iio: pressure: bmp280: Introduce new cleanup routines Vasileios Amoiridis
2024-05-05 19:22 ` Jonathan Cameron
2024-04-29 19:00 ` [PATCH v5 08/10] iio: pressure: bmp280: Generalize read_{temp,press,humid}() functions Vasileios Amoiridis
2024-04-29 19:00 ` [PATCH v5 09/10] iio: pressure: bmp280: Add SCALE, RAW values in channels and refactorize them Vasileios Amoiridis
2024-04-29 19:00 ` [PATCH v5 10/10] iio: pressure: bmp280: Add triggered buffer support Vasileios Amoiridis
2024-05-05 19:34 ` Jonathan Cameron
2024-05-05 23:57 ` Vasileios Amoiridis [this message]
2024-05-06 12:50 ` 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=20240505235755.GC17986@vamoiridPC \
--to=vassilisamir@gmail.com \
--cc=579lpy@gmail.com \
--cc=ak@it-klinger.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=ang.iglesiasg@gmail.com \
--cc=jic23@kernel.org \
--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 \
/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