e1f4a3b6359a0f116c6d03be785462b8a3b86904
[openwrt/staging/thess.git] /
1 From 78b75ab3f8c9dfac563b81105a1b838ec37a940e Mon Sep 17 00:00:00 2001
2 From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 Date: Sun, 13 Oct 2019 10:55:15 +0100
4 Subject: [PATCH] iio: chemical: sps30: Explicity truncate constant by masking
5
6 When breaking up a constant to write to two 8 bit registers
7 it isn't obvious to sparse that it was intentional.
8
9 CHECK drivers/iio/chemical/sps30.c
10 drivers/iio/chemical/sps30.c:120:30: warning: cast truncates bits from constant value (8004 becomes 4)
11
12 So in the interests of minimising noisy warnings, let us add
13 a mask.
14
15 Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
16 Acked-by: Tomasz Duszynski <tduszyns@gmail.com>
17 ---
18 drivers/iio/chemical/sps30.c | 2 +-
19 1 file changed, 1 insertion(+), 1 deletion(-)
20
21 --- a/drivers/iio/chemical/sps30.c
22 +++ b/drivers/iio/chemical/sps30.c
23 @@ -117,7 +117,7 @@ static int sps30_do_cmd(struct sps30_sta
24 break;
25 case SPS30_READ_AUTO_CLEANING_PERIOD:
26 buf[0] = SPS30_AUTO_CLEANING_PERIOD >> 8;
27 - buf[1] = (u8)SPS30_AUTO_CLEANING_PERIOD;
28 + buf[1] = (u8)(SPS30_AUTO_CLEANING_PERIOD & 0xff);
29 /* fall through */
30 case SPS30_READ_DATA_READY_FLAG:
31 case SPS30_READ_DATA: