Skip to content

Commit cc8e0e0

Browse files
committed
iio: adc: ad4630: Use right shift operator for scale calculation
The ADC input range value is never negative and so there is no need to use shift_right() to calculate the scale. Make direct use of right shift operator for scale calculation. This fixes 'comparison of unsigned expression in ‘< 0’ is always false' build warn. Signed-off-by: Marcelo Schmitt <[email protected]>
1 parent 35917c9 commit cc8e0e0

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/iio/adc/ad4630.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@ static int ad4630_set_chan_offset(struct iio_dev *indio_dev, int ch, int offset)
530530
static void ad4630_fill_scale_tbl(struct ad4630_state *st)
531531
{
532532
int val, val2, tmp0, tmp1, i;
533-
u64 tmp2;
534533

535534
val2 = st->chip->modes[st->out_data].channels->scan_type.realbits;
536535
for (i = 0; i < ARRAY_SIZE(ad4630_gains); i++) {
@@ -539,8 +538,7 @@ static void ad4630_fill_scale_tbl(struct ad4630_state *st)
539538
val = mult_frac(val, ad4630_gains_frac[i][1] * MILLI,
540539
ad4630_gains_frac[i][0]);
541540
/* Would multiply by NANO here but we already multiplied by MILLI */
542-
tmp2 = shift_right((u64)val * MICRO, val2);
543-
tmp0 = (int)div_s64_rem(tmp2, NANO, &tmp1);
541+
tmp0 = (int)div_u64_rem(((u64)val * MICRO) >> val2, NANO, &tmp1);
544542
st->scale_tbl[i][0] = tmp0; /* Integer part */
545543
st->scale_tbl[i][1] = abs(tmp1); /* Fractional part */
546544
}

0 commit comments

Comments
 (0)