mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 22:14:03 +02:00
iio: light: opt4060: Fix pointer type passed to div_u64_rem()
div_u64_rem() expects a u32 * for the remainder, but
opt4060_read_ev_period() passes val2, which is declared as an
int *. While this has no functional impact, it triggers a pointer type
mismatch.
There is no behavioural change because int and u32 have the same
size and representation on all supported architectures, and the
remainder is always less than MICRO, so it fits within the positive
range of int.
Use a local u32 to receive the remainder before assigning it to
*val2.
Fixes: 0c6db4506a ("iio: light: Add support for TI OPT4060 color sensor")
Signed-off-by: Vidhu Sarwal <vidhu.linux@gmail.com>
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
This commit is contained in:
parent
b7e6e9af0d
commit
0ba0ed0d42
|
|
@ -713,6 +713,7 @@ static ssize_t opt4060_read_ev_period(struct opt4060_chip *chip, int *val,
|
|||
{
|
||||
int ret, pers, fault_count, int_time;
|
||||
u64 uval;
|
||||
u32 rem;
|
||||
|
||||
int_time = opt4060_int_time_reg[chip->int_time][0];
|
||||
|
||||
|
|
@ -738,7 +739,8 @@ static ssize_t opt4060_read_ev_period(struct opt4060_chip *chip, int *val,
|
|||
}
|
||||
|
||||
uval = mul_u32_u32(int_time, pers);
|
||||
*val = div_u64_rem(uval, MICRO, val2);
|
||||
*val = div_u64_rem(uval, MICRO, &rem);
|
||||
*val2 = rem;
|
||||
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user