Skip to content

Commit f928099

Browse files
vamoiridjic23
authored andcommitted
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 <vassilisamir@gmail.com> Link: https://patch.msgid.link/20241030235424.214935-2-vassilisamir@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 869aa5e commit f928099

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/iio/chemical/bme680_core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,7 @@ static int bme680_read_raw(struct iio_dev *indio_dev,
741741
{
742742
struct bme680_data *data = iio_priv(indio_dev);
743743
int chan_val, ret;
744+
s16 temp_chan_val;
744745

745746
guard(mutex)(&data->lock);
746747

@@ -757,11 +758,11 @@ static int bme680_read_raw(struct iio_dev *indio_dev,
757758
case IIO_CHAN_INFO_PROCESSED:
758759
switch (chan->type) {
759760
case IIO_TEMP:
760-
ret = bme680_read_temp(data, (s16 *)&chan_val);
761+
ret = bme680_read_temp(data, &temp_chan_val);
761762
if (ret)
762763
return ret;
763764

764-
*val = chan_val * 10;
765+
*val = temp_chan_val * 10;
765766
return IIO_VAL_INT;
766767
case IIO_PRESSURE:
767768
ret = bme680_read_press(data, &chan_val);

0 commit comments

Comments
 (0)