All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Bakker <kees@ijzerbout.nl>
To: Vasileios Amoiridis <vassilisamir@gmail.com>, jic23@kernel.org
Cc: dan.carpenter@linaro.org, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] iio: pressure: bmp280: Use char instead of s32 for data buffer
Date: Fri, 11 Oct 2024 20:59:28 +0200	[thread overview]
Message-ID: <7e9d8b56-2033-4ca6-905a-e761f43cecef@ijzerbout.nl> (raw)
In-Reply-To: <20240930202353.38203-3-vassilisamir@gmail.com>

Op 30-09-2024 om 22:23 schreef Vasileios Amoiridis:
> As it was reported and discussed here [1], storing the sensor data in an
> endian aware s32 buffer is not optimal. Advertising the timestamp as an
> addition of 2 s32 variables which is also implied is again not the best
> practice. For that reason, change the s32 sensor_data buffer to a u8
> buffer and align it properly.
>
> [1]: https://lore.kernel.org/linux-iio/73d13cc0-afb9-4306-b498-5d821728c3ba@stanley.mountain/
>
> Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
> ---
>   drivers/iio/pressure/bmp280-core.c | 72 ++++++++++++++++++------------
>   drivers/iio/pressure/bmp280.h      |  4 +-
>   2 files changed, 46 insertions(+), 30 deletions(-)
> [...]
> @@ -2199,7 +2210,7 @@ static irqreturn_t bmp580_trigger_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;
> +	int ret, offset;
>   
>   	guard(mutex)(&data->lock);
>   
> @@ -2211,13 +2222,15 @@ static irqreturn_t bmp580_trigger_handler(int irq, void *p)
>   		goto out;
>   	}
>   
> -	/* Temperature calculations */
> -	memcpy(&data->sensor_data[1], &data->buf[0], 3);
> -
>   	/* Pressure calculations */
> -	memcpy(&data->sensor_data[0], &data->buf[3], 3);
> +	memcpy(&data->sensor_data[offset], &data->buf[3], 3);
Variable offset is not initialized.
> +
> +	offset += sizeof(s32);
> +
> +	/* Temperature calculations */
> +	memcpy(&data->sensor_data[offset], &data->buf[0], 3);
>   
> -	iio_push_to_buffers_with_timestamp(indio_dev, &data->sensor_data,
> +	iio_push_to_buffers_with_timestamp(indio_dev, data->sensor_data,
>   					   iio_get_time_ns(indio_dev));
>   
>   out:
>

  reply	other threads:[~2024-10-11 18:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-30 20:23 [PATCH v3 0/2] pressure: bmp280: Improve pushing of data to buffer Vasileios Amoiridis
2024-09-30 20:23 ` [PATCH v3 1/2] iio: pressure: bmp280: Use unsigned type for raw values Vasileios Amoiridis
2024-09-30 20:23 ` [PATCH v3 2/2] iio: pressure: bmp280: Use char instead of s32 for data buffer Vasileios Amoiridis
2024-10-11 18:59   ` Kees Bakker [this message]
2024-10-06 14:05 ` [PATCH v3 0/2] pressure: bmp280: Improve pushing of data to buffer Jonathan Cameron
2024-10-07 19:35   ` 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=7e9d8b56-2033-4ca6-905a-e761f43cecef@ijzerbout.nl \
    --to=kees@ijzerbout.nl \
    --cc=dan.carpenter@linaro.org \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.