Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Vasileios Amoiridis and committed by
Jonathan Cameron
f928099e 869aa5e8

+3 -2
+3 -2
drivers/iio/chemical/bme680_core.c
··· 741 741 { 742 742 struct bme680_data *data = iio_priv(indio_dev); 743 743 int chan_val, ret; 744 + s16 temp_chan_val; 744 745 745 746 guard(mutex)(&data->lock); 746 747 ··· 758 757 case IIO_CHAN_INFO_PROCESSED: 759 758 switch (chan->type) { 760 759 case IIO_TEMP: 761 - ret = bme680_read_temp(data, (s16 *)&chan_val); 760 + ret = bme680_read_temp(data, &temp_chan_val); 762 761 if (ret) 763 762 return ret; 764 763 765 - *val = chan_val * 10; 764 + *val = temp_chan_val * 10; 766 765 return IIO_VAL_INT; 767 766 case IIO_PRESSURE: 768 767 ret = bme680_read_press(data, &chan_val);