Skip to content

Commit 75b9841

Browse files
hpmanoj14cfriedt
authored andcommitted
drivers: sensor: tsl2591: fix sign extension
Explicitly cast data->atime to uint32_t to prevent signed promotion and sign extension when multiplying with data->again. Signed-off-by: Manoj Purushothama <[email protected]>
1 parent a386d31 commit 75b9841

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/sensor/ams/tsl2591/tsl2591.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static int tsl2591_set_threshold(const struct device *dev, enum sensor_attribute
192192
int ret;
193193

194194
/* Convert from relative strength of visible light to raw value */
195-
cpl = data->atime * data->again;
195+
cpl = (uint32_t)data->atime * data->again;
196196
raw = ((val->val1 * cpl) / TSL2591_LUX_DF) +
197197
((val->val2 * cpl) / (1000000U * TSL2591_LUX_DF));
198198

0 commit comments

Comments
 (0)