Re: [PATCH v1 2/4] iio: light: opt4001: Fix incompatible pointer type passed to div_u64_rem()

From: Jonathan Cameron

Date: Sun Jul 12 2026 - 20:43:31 EST


On Mon, 13 Jul 2026 01:54:49 +0530
Nikhil Gautam <nikhilgtr@xxxxxxxxx> wrote:

> div_u64_rem() takes a u32 * for the remainder but is passed val2,
> which is an int *. Use a local u32 for the remainder and assign the
> result to *val2.
State what affect (if any) that has.
>
> Signed-off-by: Nikhil Gautam <nikhilgtr@xxxxxxxxx>
Fix looks good, just add the tag for v2.

> ---
> drivers/iio/light/opt4001.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/light/opt4001.c b/drivers/iio/light/opt4001.c
> index f2cf496cc243..bdb1eadbd450 100644
> --- a/drivers/iio/light/opt4001.c
> +++ b/drivers/iio/light/opt4001.c
> @@ -173,6 +173,7 @@ static int opt4001_read_lux_value(struct iio_dev *indio_dev,
> u8 crc;
> u8 calc_crc;
> u64 lux_raw;
> + u32 rem;
> int ret;
>
> ret = regmap_read(chip->regmap, OPT4001_LIGHT1_MSB, &light1);
> @@ -199,8 +200,8 @@ static int opt4001_read_lux_value(struct iio_dev *indio_dev,
>
> lux_raw = lux_raw << exp;
> lux_raw = lux_raw * chip->chip_info->mul;
> - *val = div_u64_rem(lux_raw, chip->chip_info->div, val2);
> - *val2 = *val2 * 100;
> + *val = div_u64_rem(lux_raw, chip->chip_info->div, &rem);
> + *val2 = rem * 100;
>
> return IIO_VAL_INT_PLUS_NANO;
> }


L