From: Vasileios Amoiridis Date: Wed, 30 Oct 2024 23:54:24 +0000 (+0100) Subject: iio: chemical: bme680: use s16 variable for temp value to avoid casting X-Git-Tag: v6.13-rc1~28^2~11^2~57 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f928099e5f5c3ce60ecbd70ea17614e9b253068f;p=thirdparty%2Flinux.git iio: chemical: bme680: use s16 variable for temp value to avoid casting 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 Link: https://patch.msgid.link/20241030235424.214935-2-vassilisamir@gmail.com Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c index 871921d81e703..6d11f91883672 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);