Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 321763
b: refs/heads/master
c: 4fcbcf9
h: refs/heads/master
i:
  321761: 030496f
  321759: f724436
v: v3
  • Loading branch information
Lars-Peter Clausen authored and Jonathan Cameron committed Aug 16, 2012
1 parent d8ae2e5 commit d250db9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 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: 58cdff6ee71b4ea00a6b822a52ebf9ceb0b6a7d5
refs/heads/master: 4fcbcf95b775acc430742a09fb3334dce08b6c10
26 changes: 12 additions & 14 deletions trunk/drivers/staging/iio/adc/ad7192.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,11 @@ static const struct attribute_group ad7195_attribute_group = {
.attrs = ad7195_attributes,
};

static unsigned int ad7192_get_temp_scale(bool unipolar)
{
return unipolar ? 2815 * 2 : 2815;
}

static int ad7192_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val,
Expand All @@ -824,17 +829,6 @@ static int ad7192_read_raw(struct iio_dev *indio_dev,
*val = (smpl >> chan->scan_type.shift) &
((1 << (chan->scan_type.realbits)) - 1);

switch (chan->type) {
case IIO_VOLTAGE:
break;
case IIO_TEMP:
*val -= 0x800000;
*val /= 2815; /* temp Kelvin */
*val -= 273; /* temp Celsius */
break;
default:
return -EINVAL;
}
return IIO_VAL_INT;

case IIO_CHAN_INFO_SCALE:
Expand All @@ -846,16 +840,20 @@ static int ad7192_read_raw(struct iio_dev *indio_dev,
mutex_unlock(&indio_dev->mlock);
return IIO_VAL_INT_PLUS_NANO;
case IIO_TEMP:
*val = 1000;
return IIO_VAL_INT;
*val = 0;
*val2 = 1000000000 / ad7192_get_temp_scale(unipolar);
return IIO_VAL_INT_PLUS_NANO;
default:
return -EINVAL;
}
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)
*val -= 273 * ad7192_get_temp_scale(unipolar);
return IIO_VAL_INT;
}

Expand Down

0 comments on commit d250db9

Please sign in to comment.