Skip to content

Commit

Permalink
iio: chemical: bme680: use s16 variable for temp value to avoid casting
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Vasileios Amoiridis authored and Jonathan Cameron committed Nov 1, 2024
1 parent 869aa5e commit f928099
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/iio/chemical/bme680_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down

0 comments on commit f928099

Please sign in to comment.