Skip to content

Commit f71869b

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 69dcfc6 commit f71869b

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
@@ -528,7 +528,6 @@ static int ad4630_set_chan_offset(struct iio_dev *indio_dev, int ch, int offset)
528528
static void ad4630_fill_scale_tbl(struct ad4630_state *st)
529529
{
530530
int val, val2, tmp0, tmp1, i;
531-
u64 tmp2;
532531

533532
val2 = st->chip->modes[st->out_data].channels->scan_type.realbits;
534533
for (i = 0; i < ARRAY_SIZE(ad4630_gains); i++) {
@@ -537,8 +536,7 @@ static void ad4630_fill_scale_tbl(struct ad4630_state *st)
537536
val = mult_frac(val, ad4630_gains_frac[i][1] * MILLI,
538537
ad4630_gains_frac[i][0]);
539538
/* Would multiply by NANO here but we already multiplied by MILLI */
540-
tmp2 = shift_right((u64)val * MICRO, val2);
541-
tmp0 = (int)div_s64_rem(tmp2, NANO, &tmp1);
539+
tmp0 = (int)div_u64_rem(((u64)val * MICRO) >> val2, NANO, &tmp1);
542540
st->scale_tbl[i][0] = tmp0; /* Integer part */
543541
st->scale_tbl[i][1] = abs(tmp1); /* Fractional part */
544542
}

0 commit comments

Comments
 (0)