From: Jonathan Cameron <jic23@kernel.org>
To: Vasileios Amoiridis <vassilisamir@gmail.com>
Cc: dan.carpenter@linaro.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] iio: chemical: bme680: use s16 variable for temp value to avoid casting
Date: Thu, 31 Oct 2024 19:22:00 +0000 [thread overview]
Message-ID: <20241031192200.649a0ea1@jic23-huawei> (raw)
In-Reply-To: <20241030235424.214935-2-vassilisamir@gmail.com>
On Thu, 31 Oct 2024 00:54:24 +0100
Vasileios Amoiridis <vassilisamir@gmail.com> wrote:
> Use local s16 variable for the temperature channel to avoid casting it
> later before passing it to the bme680_read_temp() function. This way,
> possible endianness and initialization issues are avoided.
>
> Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Applied.
> ---
> drivers/iio/chemical/bme680_core.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c
> index 871921d81e70..6d11f9188367 100644
> --- a/drivers/iio/chemical/bme680_core.c
> +++ b/drivers/iio/chemical/bme680_core.c
> @@ -741,6 +741,7 @@ static int bme680_read_raw(struct iio_dev *indio_dev,
> {
> struct bme680_data *data = iio_priv(indio_dev);
> int chan_val, ret;
> + s16 temp_chan_val;
>
> guard(mutex)(&data->lock);
>
> @@ -757,11 +758,11 @@ static int bme680_read_raw(struct iio_dev *indio_dev,
> case IIO_CHAN_INFO_PROCESSED:
> switch (chan->type) {
> case IIO_TEMP:
> - ret = bme680_read_temp(data, (s16 *)&chan_val);
> + ret = bme680_read_temp(data, &temp_chan_val);
> if (ret)
> return ret;
>
> - *val = chan_val * 10;
> + *val = temp_chan_val * 10;
> return IIO_VAL_INT;
> case IIO_PRESSURE:
> ret = bme680_read_press(data, &chan_val);
prev parent reply other threads:[~2024-10-31 19:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-30 23:54 [PATCH v1 0/1] iio: chemical: bme680: resolve issue reported by Vasileios Amoiridis
2024-10-30 23:54 ` [PATCH v1] iio: chemical: bme680: use s16 variable for temp value to avoid casting Vasileios Amoiridis
2024-10-31 19:22 ` Jonathan Cameron [this message]
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=20241031192200.649a0ea1@jic23-huawei \
--to=jic23@kernel.org \
--cc=dan.carpenter@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®