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, linus.walleij@linaro.org,
semen.protsenko@linaro.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 5/5] iio: pressure: bmp280: Add triggered buffer support
Date: Sun, 19 May 2024 15:35:01 +0100 [thread overview]
Message-ID: <20240519153501.7d30c7c2@jic23-huawei> (raw)
In-Reply-To: <20240512230524.53990-6-vassilisamir@gmail.com>
On Mon, 13 May 2024 01:05:24 +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>
>
> +static irqreturn_t bmp280_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, adc_humidity, t_fine;
> + u8 sizeof_burst_read;
> + int ret;
> +
> + guard(mutex)(&data->lock);
> +
> + /*
> + * If humidity channel is enabled it means that we are called for the
> + * BME280 humidity sensor.
> + */
> + if (test_bit(BME280_HUMID, indio_dev->active_scan_mask))
The only thing I though a bit about on this review was whether this
combined function really makes sense, or should we just move to two
separate handlers. It's marginal, but given you had it done this way
let us stick with this.
Definitely something to keep in mind for future changes though that may
make this more complex still. For now it's fine.
Applied to the togreg branch of iio.git but given timing that is for now
only pushed out as testing and I'll rebase it on rc1 once available.
Thanks,
Jonathan
> + sizeof_burst_read = BME280_BURST_READ_BYTES;
> + else
> + sizeof_burst_read = BMP280_BURST_READ_BYTES;
> +
> + /* Burst read data registers */
> + ret = regmap_bulk_read(data->regmap, BMP280_REG_PRESS_MSB,
> + data->buf, sizeof_burst_read);
> + if (ret) {
> + dev_err(data->dev, "failed to burst read sensor data\n");
> + goto out;
> + }
> +
> + /* Temperature calculations */
> + adc_temp = FIELD_GET(BMP280_MEAS_TRIM_MASK, get_unaligned_be24(&data->buf[3]));
> + if (adc_temp == BMP280_TEMP_SKIPPED) {
> + dev_err(data->dev, "reading temperature skipped\n");
> + goto out;
> + }
> +
> + data->sensor_data[1] = bmp280_compensate_temp(data, adc_temp);
> +
> + /* Pressure calculations */
> + adc_press = FIELD_GET(BMP280_MEAS_TRIM_MASK, get_unaligned_be24(&data->buf[0]));
> + if (adc_press == BMP280_PRESS_SKIPPED) {
> + dev_err(data->dev, "reading pressure skipped\n");
> + goto out;
> + }
> +
> + t_fine = bmp280_calc_t_fine(data, adc_temp);
> +
> + data->sensor_data[0] = bmp280_compensate_press(data, adc_press, t_fine);
> +
> + /* Humidity calculations */
> + if (test_bit(BME280_HUMID, indio_dev->active_scan_mask)) {
> + adc_humidity = get_unaligned_be16(&data->buf[6]);
> +
> + if (adc_humidity == BMP280_HUMIDITY_SKIPPED) {
> + dev_err(data->dev, "reading humidity skipped\n");
> + goto out;
> + }
> + data->sensor_data[2] = bme280_compensate_humidity(data, adc_humidity, t_fine);
> + }
> +
> + iio_push_to_buffers_with_timestamp(indio_dev, &data->sensor_data,
> + iio_get_time_ns(indio_dev));
> +
> +out:
> + iio_trigger_notify_done(indio_dev->trig);
> +
> + return IRQ_HANDLED;
> +}
> +
>
next prev parent reply other threads:[~2024-05-19 14:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-12 23:05 [PATCH v7 0/5] iio: pressure: bmp280: Add triggered buffer support and Vasileios Amoiridis
2024-05-12 23:05 ` [PATCH v7 1/5] iio: pressure: bmp280: Refactorize reading functions Vasileios Amoiridis
2024-05-19 14:22 ` Jonathan Cameron
2024-05-12 23:05 ` [PATCH v7 2/5] iio: pressure: bmp280: Introduce new cleanup routines Vasileios Amoiridis
2024-05-19 14:24 ` Jonathan Cameron
2024-05-12 23:05 ` [PATCH v7 3/5] iio: pressure: bmp280: Generalize read_{temp,press,humid}() functions Vasileios Amoiridis
2024-05-19 14:28 ` Jonathan Cameron
2024-05-12 23:05 ` [PATCH v7 4/5] iio: pressure: bmp280: Add SCALE, RAW values in channels and refactorize them Vasileios Amoiridis
2024-05-19 14:30 ` Jonathan Cameron
2024-05-12 23:05 ` [PATCH v7 5/5] iio: pressure: bmp280: Add triggered buffer support Vasileios Amoiridis
2024-05-19 14:35 ` Jonathan Cameron [this message]
2024-05-29 20:12 ` Jonathan Cameron
2024-05-29 23:49 ` 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=20240519153501.7d30c7c2@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=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=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