Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 321756
b: refs/heads/master
c: 2a9e066
h: refs/heads/master
v: v3
  • Loading branch information
Lars-Peter Clausen authored and Jonathan Cameron committed Aug 16, 2012
1 parent 369343a commit 54d9d55
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 680f8ea0e85c5c3a7283be99435d6461e8725348
refs/heads/master: 2a9e0662f6779d2074ecaa80ea5753d5f0cf1b93
29 changes: 18 additions & 11 deletions trunk/drivers/staging/iio/adc/ad7793.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,30 +617,37 @@ static int ad7793_read_raw(struct iio_dev *indio_dev,
return IIO_VAL_INT_PLUS_NANO;
} else {
/* 1170mV / 2^23 * 6 */
scale_uv = (1170ULL * 100000000ULL * 6ULL)
>> (chan->scan_type.realbits -
(unipolar ? 0 : 1));
scale_uv = (1170ULL * 100000000ULL * 6ULL);
}
break;
case IIO_TEMP:
/* Always uses unity gain and internal ref */
scale_uv = (2500ULL * 100000000ULL)
>> (chan->scan_type.realbits -
(unipolar ? 0 : 1));
/* 1170mV / 0.81 mV/C / 2^23 */
scale_uv = 1444444444444ULL;
break;
default:
return -EINVAL;
}

*val2 = do_div(scale_uv, 100000000) * 10;
*val = scale_uv;

scale_uv >>= (chan->scan_type.realbits - (unipolar ? 0 : 1));
*val = 0;
*val2 = scale_uv;
return IIO_VAL_INT_PLUS_NANO;
case IIO_CHAN_INFO_OFFSET:
if (!unipolar)
*val -= (1 << (chan->scan_type.realbits - 1));
*val = -(1 << (chan->scan_type.realbits - 1));
else
*val = 0;

/* Kelvin to Celsius */
if (chan->type == IIO_TEMP) {
unsigned long long offset;
unsigned int shift;

shift = chan->scan_type.realbits - (unipolar ? 0 : 1);
offset = 273ULL << shift;
do_div(offset, 1444);
*val -= offset;
}
return IIO_VAL_INT;
}
return -EINVAL;
Expand Down

0 comments on commit 54d9d55

Please sign in to comment.