Skip to content

Commit

Permalink
iio:adc:qcom-spmi-vadc : fix undefined __divdi3
Browse files Browse the repository at this point in the history
A simple do_div call works here as all the signed 64 bit is
actually small and unsigned at this point, and the numerator is
u32.

Introduce a temporary u64 variable to avoid type comparison warnings
on some architectures.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Cc: Rama Krishna Phani A <rphani@codeaurora.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
  • Loading branch information
Jonathan Cameron committed Jan 10, 2017
1 parent c3b2fdd commit 2bd72d8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/iio/adc/qcom-spmi-vadc.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,13 +658,15 @@ static int vadc_scale_die_temp(struct vadc_priv *vadc,
{
const struct vadc_prescale_ratio *prescale;
s64 voltage = 0;
u64 temp; /* Temporary variable for do_div */

vadc_scale_calib(vadc, adc_code, prop, &voltage);

if (voltage > 0) {
prescale = &vadc_prescale_ratios[prop->prescale];
voltage = voltage * prescale->den;
voltage /= (prescale->num * 2);
temp = voltage * prescale->den;
do_div(temp, prescale->num * 2);
voltage = temp;
} else {
voltage = 0;
}
Expand Down

0 comments on commit 2bd72d8

Please sign in to comment.