linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/25] iio:ad5064: Report scale as fractional value
@ 2013-09-28  9:31 Lars-Peter Clausen
  2013-09-28  9:31 ` [PATCH 02/25] iio:ad5360: " Lars-Peter Clausen
                   ` (24 more replies)
  0 siblings, 25 replies; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/dac/ad5064.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c
index b18e8c4..cb9c636 100644
--- a/drivers/iio/dac/ad5064.c
+++ b/drivers/iio/dac/ad5064.c
@@ -239,10 +239,9 @@ static int ad5064_read_raw(struct iio_dev *indio_dev,
 		if (scale_uv < 0)
 			return scale_uv;
 
-		scale_uv = (scale_uv * 100) >> chan->scan_type.realbits;
-		*val =  scale_uv / 100000;
-		*val2 = (scale_uv % 100000) * 10;
-		return IIO_VAL_INT_PLUS_MICRO;
+		*val = scale_uv / 1000;
+		*val2 = chan->scan_type.realbits;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	default:
 		break;
 	}
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 02/25] iio:ad5360: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  8:48   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 03/25] iio:ad5380: " Lars-Peter Clausen
                   ` (23 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/dac/ad5360.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/dac/ad5360.c b/drivers/iio/dac/ad5360.c
index d2da71e..b968af5 100644
--- a/drivers/iio/dac/ad5360.c
+++ b/drivers/iio/dac/ad5360.c
@@ -379,15 +379,14 @@ static int ad5360_read_raw(struct iio_dev *indio_dev,
 		*val = ret >> chan->scan_type.shift;
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		/* vout = 4 * vref * dac_code */
-		scale_uv = ad5360_get_channel_vref(st, chan->channel) * 4 * 100;
+		scale_uv = ad5360_get_channel_vref(st, chan->channel);
 		if (scale_uv < 0)
 			return scale_uv;
 
-		scale_uv >>= (chan->scan_type.realbits);
-		*val =  scale_uv / 100000;
-		*val2 = (scale_uv % 100000) * 10;
-		return IIO_VAL_INT_PLUS_MICRO;
+		/* vout = 4 * vref * dac_code */
+		*val = scale_uv * 4 / 1000;
+		*val2 = chan->scan_type.realbits;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	case IIO_CHAN_INFO_CALIBBIAS:
 		ret = ad5360_read(indio_dev, AD5360_READBACK_OFFSET,
 			chan->address);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 03/25] iio:ad5380: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
  2013-09-28  9:31 ` [PATCH 02/25] iio:ad5360: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  8:49   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 04/25] iio:ad5421: " Lars-Peter Clausen
                   ` (22 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/dac/ad5380.c | 40 +++++++++++++++++++---------------------
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c
index 4c791e6..a59ff0e 100644
--- a/drivers/iio/dac/ad5380.c
+++ b/drivers/iio/dac/ad5380.c
@@ -204,7 +204,6 @@ static int ad5380_read_raw(struct iio_dev *indio_dev,
 	struct iio_chan_spec const *chan, int *val, int *val2, long info)
 {
 	struct ad5380_state *st = iio_priv(indio_dev);
-	unsigned long scale_uv;
 	int ret;
 
 	switch (info) {
@@ -225,10 +224,9 @@ static int ad5380_read_raw(struct iio_dev *indio_dev,
 		val -= (1 << chan->scan_type.realbits) / 2;
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		scale_uv = ((2 * st->vref) >> chan->scan_type.realbits) * 100;
-		*val =  scale_uv / 100000;
-		*val2 = (scale_uv % 100000) * 10;
-		return IIO_VAL_INT_PLUS_MICRO;
+		*val = 2 * st->vref;
+		*val2 = chan->scan_type.realbits;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	default:
 		break;
 	}
@@ -271,72 +269,72 @@ static const struct ad5380_chip_info ad5380_chip_info_tbl[] = {
 	[ID_AD5380_3] = {
 		.channel_template = AD5380_CHANNEL(14),
 		.num_channels = 40,
-		.int_vref = 1250000,
+		.int_vref = 1250,
 	},
 	[ID_AD5380_5] = {
 		.channel_template = AD5380_CHANNEL(14),
 		.num_channels = 40,
-		.int_vref = 2500000,
+		.int_vref = 2500,
 	},
 	[ID_AD5381_3] = {
 		.channel_template = AD5380_CHANNEL(12),
 		.num_channels = 16,
-		.int_vref = 1250000,
+		.int_vref = 1250,
 	},
 	[ID_AD5381_5] = {
 		.channel_template = AD5380_CHANNEL(12),
 		.num_channels = 16,
-		.int_vref = 2500000,
+		.int_vref = 2500,
 	},
 	[ID_AD5382_3] = {
 		.channel_template = AD5380_CHANNEL(14),
 		.num_channels = 32,
-		.int_vref = 1250000,
+		.int_vref = 1250,
 	},
 	[ID_AD5382_5] = {
 		.channel_template = AD5380_CHANNEL(14),
 		.num_channels = 32,
-		.int_vref = 2500000,
+		.int_vref = 2500,
 	},
 	[ID_AD5383_3] = {
 		.channel_template = AD5380_CHANNEL(12),
 		.num_channels = 32,
-		.int_vref = 1250000,
+		.int_vref = 1250,
 	},
 	[ID_AD5383_5] = {
 		.channel_template = AD5380_CHANNEL(12),
 		.num_channels = 32,
-		.int_vref = 2500000,
+		.int_vref = 2500,
 	},
 	[ID_AD5390_3] = {
 		.channel_template = AD5380_CHANNEL(14),
 		.num_channels = 16,
-		.int_vref = 1250000,
+		.int_vref = 1250,
 	},
 	[ID_AD5390_5] = {
 		.channel_template = AD5380_CHANNEL(14),
 		.num_channels = 16,
-		.int_vref = 2500000,
+		.int_vref = 2500,
 	},
 	[ID_AD5391_3] = {
 		.channel_template = AD5380_CHANNEL(12),
 		.num_channels = 16,
-		.int_vref = 1250000,
+		.int_vref = 1250,
 	},
 	[ID_AD5391_5] = {
 		.channel_template = AD5380_CHANNEL(12),
 		.num_channels = 16,
-		.int_vref = 2500000,
+		.int_vref = 2500,
 	},
 	[ID_AD5392_3] = {
 		.channel_template = AD5380_CHANNEL(14),
 		.num_channels = 8,
-		.int_vref = 1250000,
+		.int_vref = 1250,
 	},
 	[ID_AD5392_5] = {
 		.channel_template = AD5380_CHANNEL(14),
 		.num_channels = 8,
-		.int_vref = 2500000,
+		.int_vref = 2500,
 	},
 };
 
@@ -395,7 +393,7 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap,
 		return ret;
 	}
 
-	if (st->chip_info->int_vref == 2500000)
+	if (st->chip_info->int_vref == 2500)
 		ctrl |= AD5380_CTRL_INT_VREF_2V5;
 
 	st->vref_reg = devm_regulator_get(dev, "vref");
@@ -411,7 +409,7 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap,
 		if (ret < 0)
 			goto error_disable_reg;
 
-		st->vref = ret;
+		st->vref = ret / 1000;
 	} else {
 		st->vref = st->chip_info->int_vref;
 		ctrl |= AD5380_CTRL_INT_VREF_EN;
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 04/25] iio:ad5421: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
  2013-09-28  9:31 ` [PATCH 02/25] iio:ad5360: " Lars-Peter Clausen
  2013-09-28  9:31 ` [PATCH 03/25] iio:ad5380: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  8:50   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 05/25] iio:ad5446: " Lars-Peter Clausen
                   ` (21 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/dac/ad5421.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/iio/dac/ad5421.c b/drivers/iio/dac/ad5421.c
index 1f78b14..567c4bd 100644
--- a/drivers/iio/dac/ad5421.c
+++ b/drivers/iio/dac/ad5421.c
@@ -281,18 +281,11 @@ static inline unsigned int ad5421_get_offset(struct ad5421_state *st)
 	return (min * (1 << 16)) / (max - min);
 }
 
-static inline unsigned int ad5421_get_scale(struct ad5421_state *st)
-{
-	unsigned int min, max;
-
-	ad5421_get_current_min_max(st, &min, &max);
-	return ((max - min) * 1000) / (1 << 16);
-}
-
 static int ad5421_read_raw(struct iio_dev *indio_dev,
 	struct iio_chan_spec const *chan, int *val, int *val2, long m)
 {
 	struct ad5421_state *st = iio_priv(indio_dev);
+	unsigned int min, max;
 	int ret;
 
 	if (chan->type != IIO_CURRENT)
@@ -306,9 +299,10 @@ static int ad5421_read_raw(struct iio_dev *indio_dev,
 		*val = ret;
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		*val = 0;
-		*val2 = ad5421_get_scale(st);
-		return IIO_VAL_INT_PLUS_MICRO;
+		ad5421_get_current_min_max(st, &min, &max);
+		*val = max - min;
+		*val2 = (1 << 16) * 1000;
+		return IIO_VAL_FRACTIONAL;
 	case IIO_CHAN_INFO_OFFSET:
 		*val = ad5421_get_offset(st);
 		return IIO_VAL_INT;
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 05/25] iio:ad5446: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (2 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 04/25] iio:ad5421: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  8:51   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 06/25] iio:ad5504: " Lars-Peter Clausen
                   ` (20 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/dac/ad5446.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/dac/ad5446.c b/drivers/iio/dac/ad5446.c
index 6dcb6d9..cb72f01 100644
--- a/drivers/iio/dac/ad5446.c
+++ b/drivers/iio/dac/ad5446.c
@@ -163,18 +163,15 @@ static int ad5446_read_raw(struct iio_dev *indio_dev,
 			   long m)
 {
 	struct ad5446_state *st = iio_priv(indio_dev);
-	unsigned long scale_uv;
 
 	switch (m) {
 	case IIO_CHAN_INFO_RAW:
 		*val = st->cached_val;
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		scale_uv = (st->vref_mv * 1000) >> chan->scan_type.realbits;
-		*val =  scale_uv / 1000;
-		*val2 = (scale_uv % 1000) * 1000;
-		return IIO_VAL_INT_PLUS_MICRO;
-
+		*val = st->vref_mv;
+		*val2 = chan->scan_type.realbits;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	}
 	return -EINVAL;
 }
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 06/25] iio:ad5504: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (3 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 05/25] iio:ad5446: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  8:52   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 07/25] iio:ad5624r: " Lars-Peter Clausen
                   ` (19 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/dac/ad5504.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c
index 31f4ff2..c0957a9 100644
--- a/drivers/iio/dac/ad5504.c
+++ b/drivers/iio/dac/ad5504.c
@@ -100,7 +100,6 @@ static int ad5504_read_raw(struct iio_dev *indio_dev,
 			   long m)
 {
 	struct ad5504_state *st = iio_priv(indio_dev);
-	unsigned long scale_uv;
 	int ret;
 
 	switch (m) {
@@ -113,11 +112,9 @@ static int ad5504_read_raw(struct iio_dev *indio_dev,
 
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		scale_uv = (st->vref_mv * 1000) >> chan->scan_type.realbits;
-		*val =  scale_uv / 1000;
-		*val2 = (scale_uv % 1000) * 1000;
-		return IIO_VAL_INT_PLUS_MICRO;
-
+		*val = st->vref_mv;
+		*val2 = chan->scan_type.realbits;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	}
 	return -EINVAL;
 }
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 07/25] iio:ad5624r: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (4 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 06/25] iio:ad5504: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  8:52   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 08/25] iio:ad5686: " Lars-Peter Clausen
                   ` (18 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/dac/ad5624r_spi.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/dac/ad5624r_spi.c b/drivers/iio/dac/ad5624r_spi.c
index dbb1289..774dd96 100644
--- a/drivers/iio/dac/ad5624r_spi.c
+++ b/drivers/iio/dac/ad5624r_spi.c
@@ -50,15 +50,12 @@ static int ad5624r_read_raw(struct iio_dev *indio_dev,
 			   long m)
 {
 	struct ad5624r_state *st = iio_priv(indio_dev);
-	unsigned long scale_uv;
 
 	switch (m) {
 	case IIO_CHAN_INFO_SCALE:
-		scale_uv = (st->vref_mv * 1000) >> chan->scan_type.realbits;
-		*val =  scale_uv / 1000;
-		*val2 = (scale_uv % 1000) * 1000;
-		return IIO_VAL_INT_PLUS_MICRO;
-
+		*val = st->vref_mv;
+		*val2 = chan->scan_type.realbits;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	}
 	return -EINVAL;
 }
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 08/25] iio:ad5686: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (5 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 07/25] iio:ad5624r: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  8:53   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 09/25] iio:ad5755: " Lars-Peter Clausen
                   ` (17 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/dac/ad5686.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
index f472b48..30e506e 100644
--- a/drivers/iio/dac/ad5686.c
+++ b/drivers/iio/dac/ad5686.c
@@ -201,7 +201,6 @@ static int ad5686_read_raw(struct iio_dev *indio_dev,
 			   long m)
 {
 	struct ad5686_state *st = iio_priv(indio_dev);
-	unsigned long scale_uv;
 	int ret;
 
 	switch (m) {
@@ -214,12 +213,9 @@ static int ad5686_read_raw(struct iio_dev *indio_dev,
 		*val = ret;
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		scale_uv = (st->vref_mv * 100000)
-			>> (chan->scan_type.realbits);
-		*val =  scale_uv / 100000;
-		*val2 = (scale_uv % 100000) * 10;
-		return IIO_VAL_INT_PLUS_MICRO;
-
+		*val = st->vref_mv;
+		*val2 = chan->scan_type.realbits;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	}
 	return -EINVAL;
 }
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 09/25] iio:ad5755: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (6 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 08/25] iio:ad5686: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  8:53   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 10/25] iio:ad5764: " Lars-Peter Clausen
                   ` (16 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/dac/ad5755.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c
index f305a0c..bd31dbc 100644
--- a/drivers/iio/dac/ad5755.c
+++ b/drivers/iio/dac/ad5755.c
@@ -253,15 +253,6 @@ static inline int ad5755_get_offset(struct ad5755_state *st,
 	return (min * (1 << chan->scan_type.realbits)) / (max - min);
 }
 
-static inline int ad5755_get_scale(struct ad5755_state *st,
-	struct iio_chan_spec const *chan)
-{
-	int min, max;
-
-	ad5755_get_min_max(st, chan, &min, &max);
-	return ((max - min) * 1000000000ULL) >> chan->scan_type.realbits;
-}
-
 static int ad5755_chan_reg_info(struct ad5755_state *st,
 	struct iio_chan_spec const *chan, long info, bool write,
 	unsigned int *reg, unsigned int *shift, unsigned int *offset)
@@ -303,13 +294,15 @@ static int ad5755_read_raw(struct iio_dev *indio_dev,
 {
 	struct ad5755_state *st = iio_priv(indio_dev);
 	unsigned int reg, shift, offset;
+	int min, max;
 	int ret;
 
 	switch (info) {
 	case IIO_CHAN_INFO_SCALE:
-		*val = 0;
-		*val2 = ad5755_get_scale(st, chan);
-		return IIO_VAL_INT_PLUS_NANO;
+		ad5755_get_min_max(st, chan, &min, &max);
+		*val = max - min;
+		*val2 = chan->scan_type.realbits;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	case IIO_CHAN_INFO_OFFSET:
 		*val = ad5755_get_offset(st, chan);
 		return IIO_VAL_INT;
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 10/25] iio:ad5764: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (7 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 09/25] iio:ad5755: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  8:54   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 11/25] iio:ad5791: " Lars-Peter Clausen
                   ` (15 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Also fix a off by one error in the comment describing the transfer function.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/dac/ad5764.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/dac/ad5764.c b/drivers/iio/dac/ad5764.c
index df7e028..a8ff5b2 100644
--- a/drivers/iio/dac/ad5764.c
+++ b/drivers/iio/dac/ad5764.c
@@ -217,7 +217,6 @@ static int ad5764_read_raw(struct iio_dev *indio_dev,
 	struct iio_chan_spec const *chan, int *val, int *val2, long info)
 {
 	struct ad5764_state *st = iio_priv(indio_dev);
-	unsigned long scale_uv;
 	unsigned int reg;
 	int vref;
 	int ret;
@@ -245,15 +244,14 @@ static int ad5764_read_raw(struct iio_dev *indio_dev,
 		*val = sign_extend32(*val, 5);
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		/* vout = 4 * vref + ((dac_code / 65535) - 0.5) */
+		/* vout = 4 * vref + ((dac_code / 65536) - 0.5) */
 		vref = ad5764_get_channel_vref(st, chan->channel);
 		if (vref < 0)
 			return vref;
 
-		scale_uv = (vref * 4 * 100) >> chan->scan_type.realbits;
-		*val = scale_uv / 100000;
-		*val2 = (scale_uv % 100000) * 10;
-		return IIO_VAL_INT_PLUS_MICRO;
+		*val = vref * 4 / 1000;
+		*val2 = chan->scan_type.realbits;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	case IIO_CHAN_INFO_OFFSET:
 		*val = -(1 << chan->scan_type.realbits) / 2;
 		return IIO_VAL_INT;
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 11/25] iio:ad5791: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (8 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 10/25] iio:ad5764: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  9:01   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 12/25] iio:max517: " Lars-Peter Clausen
                   ` (14 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/dac/ad5791.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c
index 3cee89b..d64acbd 100644
--- a/drivers/iio/dac/ad5791.c
+++ b/drivers/iio/dac/ad5791.c
@@ -270,9 +270,9 @@ static int ad5791_read_raw(struct iio_dev *indio_dev,
 		*val >>= chan->scan_type.shift;
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		*val = 0;
-		*val2 = (((u64)st->vref_mv) * 1000000ULL) >> chan->scan_type.realbits;
-		return IIO_VAL_INT_PLUS_MICRO;
+		*val = st->vref_mv;
+		*val2 = (1 << chan->scan_type.realbits) - 1;
+		return IIO_VAL_FRACTIONAL;
 	case IIO_CHAN_INFO_OFFSET:
 		val64 = (((u64)st->vref_neg_mv) << chan->scan_type.realbits);
 		do_div(val64, st->vref_mv);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 12/25] iio:max517: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (9 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 11/25] iio:ad5791: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  9:03   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 13/25] iio:mcp4725: " Lars-Peter Clausen
                   ` (13 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/dac/max517.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/dac/max517.c b/drivers/iio/dac/max517.c
index 83adcbf..d26be14 100644
--- a/drivers/iio/dac/max517.c
+++ b/drivers/iio/dac/max517.c
@@ -82,15 +82,13 @@ static int max517_read_raw(struct iio_dev *indio_dev,
 			   long m)
 {
 	struct max517_data *data = iio_priv(indio_dev);
-	unsigned int scale_uv;
 
 	switch (m) {
 	case IIO_CHAN_INFO_SCALE:
 		/* Corresponds to Vref / 2^(bits) */
-		scale_uv = (data->vref_mv[chan->channel] * 1000) >> 8;
-		*val =  scale_uv / 1000000;
-		*val2 = scale_uv % 1000000;
-		return IIO_VAL_INT_PLUS_MICRO;
+		*val = data->vref_mv[chan->channel];
+		*val2 = 8;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	default:
 		break;
 	}
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 13/25] iio:mcp4725: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (10 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 12/25] iio:max517: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-09-28  9:31 ` [PATCH 14/25] iio:ad7266: " Lars-Peter Clausen
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Peter Meerwald

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald <pmeerw@pmeerw.net>
---
 drivers/iio/dac/mcp4725.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c
index 6711a33..f0456f0 100644
--- a/drivers/iio/dac/mcp4725.c
+++ b/drivers/iio/dac/mcp4725.c
@@ -239,17 +239,15 @@ static int mcp4725_read_raw(struct iio_dev *indio_dev,
 			   int *val, int *val2, long mask)
 {
 	struct mcp4725_data *data = iio_priv(indio_dev);
-	unsigned long scale_uv;
 
 	switch (mask) {
 	case IIO_CHAN_INFO_RAW:
 		*val = data->dac_value;
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		scale_uv = (data->vref_mv * 1000) >> 12;
-		*val =  scale_uv / 1000000;
-		*val2 = scale_uv % 1000000;
-		return IIO_VAL_INT_PLUS_MICRO;
+		*val = data->vref_mv;
+		*val2 = 12;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	}
 	return -EINVAL;
 }
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 14/25] iio:ad7266: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (11 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 13/25] iio:mcp4725: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  9:05   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 15/25] iio:ad7476: " Lars-Peter Clausen
                   ` (11 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/adc/ad7266.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
index 656aa3e..f5723cb 100644
--- a/drivers/iio/adc/ad7266.c
+++ b/drivers/iio/adc/ad7266.c
@@ -27,7 +27,7 @@
 struct ad7266_state {
 	struct spi_device	*spi;
 	struct regulator	*reg;
-	unsigned long		vref_uv;
+	unsigned long		vref_mv;
 
 	struct spi_transfer	single_xfer[3];
 	struct spi_message	single_msg;
@@ -156,7 +156,7 @@ static int ad7266_read_raw(struct iio_dev *indio_dev,
 	struct iio_chan_spec const *chan, int *val, int *val2, long m)
 {
 	struct ad7266_state *st = iio_priv(indio_dev);
-	unsigned long scale_uv;
+	unsigned long scale_mv;
 	int ret;
 
 	switch (m) {
@@ -174,16 +174,15 @@ static int ad7266_read_raw(struct iio_dev *indio_dev,
 
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		scale_uv = (st->vref_uv * 100);
+		scale_mv = st->vref_mv;
 		if (st->mode == AD7266_MODE_DIFF)
-			scale_uv *= 2;
+			scale_mv *= 2;
 		if (st->range == AD7266_RANGE_2VREF)
-			scale_uv *= 2;
+			scale_mv *= 2;
 
-		scale_uv >>= chan->scan_type.realbits;
-		*val =  scale_uv / 100000;
-		*val2 = (scale_uv % 100000) * 10;
-		return IIO_VAL_INT_PLUS_MICRO;
+		*val = scale_mv;
+		*val2 = chan->scan_type.realbits;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	case IIO_CHAN_INFO_OFFSET:
 		if (st->range == AD7266_RANGE_2VREF &&
 			st->mode != AD7266_MODE_DIFF)
@@ -414,10 +413,10 @@ static int ad7266_probe(struct spi_device *spi)
 		if (ret < 0)
 			goto error_disable_reg;
 
-		st->vref_uv = ret;
+		st->vref_mv = ret / 1000;
 	} else {
 		/* Use internal reference */
-		st->vref_uv = 2500000;
+		st->vref_mv = 2500;
 	}
 
 	if (pdata) {
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 15/25] iio:ad7476: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (12 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 14/25] iio:ad7266: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  9:06   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 16/25] iio:ad7791: " Lars-Peter Clausen
                   ` (10 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/adc/ad7476.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
index 8d808b9..d141d45 100644
--- a/drivers/iio/adc/ad7476.c
+++ b/drivers/iio/adc/ad7476.c
@@ -127,10 +127,9 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
 		} else {
 			scale_uv = st->chip_info->int_vref_uv;
 		}
-		scale_uv >>= chan->scan_type.realbits;
-		*val =  scale_uv / 1000;
-		*val2 = (scale_uv % 1000) * 1000;
-		return IIO_VAL_INT_PLUS_MICRO;
+		*val = scale_uv / 1000;
+		*val2 = chan->scan_type.realbits;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	}
 	return -EINVAL;
 }
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 16/25] iio:ad7791: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (13 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 15/25] iio:ad7476: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  9:07   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 17/25] iio:at91: " Lars-Peter Clausen
                   ` (9 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/adc/ad7791.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/adc/ad7791.c b/drivers/iio/adc/ad7791.c
index c202035..c19f8fd 100644
--- a/drivers/iio/adc/ad7791.c
+++ b/drivers/iio/adc/ad7791.c
@@ -202,7 +202,6 @@ static int ad7791_read_raw(struct iio_dev *indio_dev,
 {
 	struct ad7791_state *st = iio_priv(indio_dev);
 	bool unipolar = !!(st->mode & AD7791_MODE_UNIPOLAR);
-	unsigned long long scale_pv;
 
 	switch (info) {
 	case IIO_CHAN_INFO_RAW:
@@ -220,23 +219,26 @@ static int ad7791_read_raw(struct iio_dev *indio_dev,
 	case IIO_CHAN_INFO_SCALE:
 		/* The monitor channel uses an internal reference. */
 		if (chan->address == AD7791_CH_AVDD_MONITOR) {
-			scale_pv = 5850000000000ULL;
+			/*
+			 * The signal is attenuated by a factor of 5 and
+			 * compared against a 1.17V internal reference.
+			 */
+			*val = 1170 * 5;
 		} else {
 			int voltage_uv;
 
 			voltage_uv = regulator_get_voltage(st->reg);
 			if (voltage_uv < 0)
 				return voltage_uv;
-			scale_pv = (unsigned long long)voltage_uv * 1000000;
+
+			*val = voltage_uv / 1000;
 		}
 		if (unipolar)
-			scale_pv >>= chan->scan_type.realbits;
+			*val2 = chan->scan_type.realbits;
 		else
-			scale_pv >>= chan->scan_type.realbits - 1;
-		*val2 = do_div(scale_pv, 1000000000);
-		*val = scale_pv;
+			*val2 = chan->scan_type.realbits - 1;
 
-		return IIO_VAL_INT_PLUS_NANO;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	}
 
 	return -EINVAL;
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 17/25] iio:at91: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (14 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 16/25] iio:ad7791: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  9:07   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 18/25] iio:max1363: " Lars-Peter Clausen
                   ` (8 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Josh Wu

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Josh Wu <josh.wu@atmel.com>
---
 drivers/iio/adc/at91_adc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 5c8f690..ce169d4 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -366,9 +366,9 @@ static int at91_adc_read_raw(struct iio_dev *idev,
 		return IIO_VAL_INT;
 
 	case IIO_CHAN_INFO_SCALE:
-		*val = (st->vref_mv * 1000) >> chan->scan_type.realbits;
-		*val2 = 0;
-		return IIO_VAL_INT_PLUS_MICRO;
+		*val = st->vref_mv;
+		*val2 = chan->scan_type.realbits;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	default:
 		break;
 	}
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 18/25] iio:max1363: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (15 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 17/25] iio:at91: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  9:08   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 19/25] staging:iio:ad7280a: " Lars-Peter Clausen
                   ` (7 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/adc/max1363.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c
index b4bc166..2b34d2f 100644
--- a/drivers/iio/adc/max1363.c
+++ b/drivers/iio/adc/max1363.c
@@ -397,7 +397,6 @@ static int max1363_read_raw(struct iio_dev *indio_dev,
 {
 	struct max1363_state *st = iio_priv(indio_dev);
 	int ret;
-	unsigned long scale_uv;
 
 	switch (m) {
 	case IIO_CHAN_INFO_RAW:
@@ -406,10 +405,9 @@ static int max1363_read_raw(struct iio_dev *indio_dev,
 			return ret;
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		scale_uv = st->vref_uv >> st->chip_info->bits;
-		*val = scale_uv / 1000;
-		*val2 = (scale_uv % 1000) * 1000;
-		return IIO_VAL_INT_PLUS_MICRO;
+		*val = st->vref_uv / 1000;
+		*val2 = st->chip_info->bits;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	default:
 		return -EINVAL;
 	}
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 19/25] staging:iio:ad7280a: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (16 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 18/25] iio:max1363: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  9:09   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 20/25] staging:iio:ad7606: " Lars-Peter Clausen
                   ` (6 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/staging/iio/adc/ad7280a.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index e7191e4..8209fa5 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -783,7 +783,6 @@ static int ad7280_read_raw(struct iio_dev *indio_dev,
 			   long m)
 {
 	struct ad7280_state *st = iio_priv(indio_dev);
-	unsigned int scale_uv;
 	int ret;
 
 	switch (m) {
@@ -804,13 +803,12 @@ static int ad7280_read_raw(struct iio_dev *indio_dev,
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
 		if ((chan->address & 0xFF) <= AD7280A_CELL_VOLTAGE_6)
-			scale_uv = (4000 * 1000) >> AD7280A_BITS;
+			*val = 4000;
 		else
-			scale_uv = (5000 * 1000) >> AD7280A_BITS;
+			*val = 5000;
 
-		*val =  scale_uv / 1000;
-		*val2 = (scale_uv % 1000) * 1000;
-		return IIO_VAL_INT_PLUS_MICRO;
+		*val2 = AD7280A_BITS;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	}
 	return -EINVAL;
 }
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 20/25] staging:iio:ad7606: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (17 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 19/25] staging:iio:ad7280a: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  9:10   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 21/25] staging:iio:ad7780: " Lars-Peter Clausen
                   ` (5 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/staging/iio/adc/ad7606_core.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c
index f042027..2083673 100644
--- a/drivers/staging/iio/adc/ad7606_core.c
+++ b/drivers/staging/iio/adc/ad7606_core.c
@@ -85,7 +85,6 @@ static int ad7606_read_raw(struct iio_dev *indio_dev,
 {
 	int ret;
 	struct ad7606_state *st = iio_priv(indio_dev);
-	unsigned int scale_uv;
 
 	switch (m) {
 	case IIO_CHAN_INFO_RAW:
@@ -101,11 +100,9 @@ static int ad7606_read_raw(struct iio_dev *indio_dev,
 		*val = (short) ret;
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		scale_uv = (st->range * 1000 * 2)
-			>> st->chip_info->channels[0].scan_type.realbits;
-		*val =  scale_uv / 1000;
-		*val2 = (scale_uv % 1000) * 1000;
-		return IIO_VAL_INT_PLUS_MICRO;
+		*val = st->range * 2;
+		*val2 = st->chip_info->channels[0].scan_type.realbits;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	}
 	return -EINVAL;
 }
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 21/25] staging:iio:ad7780: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (18 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 20/25] staging:iio:ad7606: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  9:10   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 22/25] staging:iio:ad799x: " Lars-Peter Clausen
                   ` (4 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/staging/iio/adc/ad7780.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index 4f2522a..273add3 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -90,17 +90,14 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
 			   long m)
 {
 	struct ad7780_state *st = iio_priv(indio_dev);
-	unsigned long scale_uv;
 
 	switch (m) {
 	case IIO_CHAN_INFO_RAW:
 		return ad_sigma_delta_single_conversion(indio_dev, chan, val);
 	case IIO_CHAN_INFO_SCALE:
-		scale_uv = (st->int_vref_mv * 100000 * st->gain)
-			>> (chan->scan_type.realbits - 1);
-		*val =  scale_uv / 100000;
-		*val2 = (scale_uv % 100000) * 10;
-		return IIO_VAL_INT_PLUS_MICRO;
+		*val = st->int_vref_mv * st->gain;
+		*val2 = chan->scan_type.realbits - 1;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	case IIO_CHAN_INFO_OFFSET:
 		*val -= (1 << (chan->scan_type.realbits - 1));
 		return IIO_VAL_INT;
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 22/25] staging:iio:ad799x: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (19 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 21/25] staging:iio:ad7780: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  9:11   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 23/25] staging:iio:ad7746: " Lars-Peter Clausen
                   ` (3 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/staging/iio/adc/ad799x_core.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c
index 3f5142b..eb6a690 100644
--- a/drivers/staging/iio/adc/ad799x_core.c
+++ b/drivers/staging/iio/adc/ad799x_core.c
@@ -163,7 +163,6 @@ static int ad799x_read_raw(struct iio_dev *indio_dev,
 {
 	int ret;
 	struct ad799x_state *st = iio_priv(indio_dev);
-	unsigned int scale_uv;
 
 	switch (m) {
 	case IIO_CHAN_INFO_RAW:
@@ -180,10 +179,9 @@ static int ad799x_read_raw(struct iio_dev *indio_dev,
 			RES_MASK(chan->scan_type.realbits);
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		scale_uv = (st->int_vref_mv * 1000) >> chan->scan_type.realbits;
-		*val =  scale_uv / 1000;
-		*val2 = (scale_uv % 1000) * 1000;
-		return IIO_VAL_INT_PLUS_MICRO;
+		*val = st->int_vref_mv;
+		*val2 = chan->scan_type.realbits;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	}
 	return -EINVAL;
 }
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 23/25] staging:iio:ad7746: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (20 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 22/25] staging:iio:ad799x: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  9:12   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 24/25] staging:iio:spear_adc: " Lars-Peter Clausen
                   ` (2 subsequent siblings)
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/staging/iio/cdc/ad7746.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
index 75a533b..862d68d 100644
--- a/drivers/staging/iio/cdc/ad7746.c
+++ b/drivers/staging/iio/cdc/ad7746.c
@@ -656,20 +656,21 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
 		switch (chan->type) {
 		case IIO_CAPACITANCE:
 			/* 8.192pf / 2^24 */
-			*val2 = 488;
 			*val =  0;
+			*val2 = 488;
+			ret = IIO_VAL_INT_PLUS_NANO;
 			break;
 		case IIO_VOLTAGE:
 			/* 1170mV / 2^23 */
-			*val2 = 139475;
-			*val =  0;
+			*val = 1170;
+			*val2 = 23;
+			ret = IIO_VAL_FRACTIONAL_LOG2;
 			break;
 		default:
-			ret =  -EINVAL;
-			goto out;
+			ret = -EINVAL;
+			break;
 		}
 
-		ret = IIO_VAL_INT_PLUS_NANO;
 		break;
 	default:
 		ret = -EINVAL;
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 24/25] staging:iio:spear_adc: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (21 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 23/25] staging:iio:ad7746: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  9:13   ` Jonathan Cameron
  2013-09-28  9:31 ` [PATCH 25/25] iio: Update unit of the voltage scale in the documentation Lars-Peter Clausen
  2013-10-01  8:46 ` [PATCH 01/25] iio:ad5064: Report scale as fractional value Jonathan Cameron
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Stefan Roese

Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Stefan Roese <sr@denx.de>
---
 drivers/staging/iio/adc/spear_adc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c
index 20f2d55..657e01b 100644
--- a/drivers/staging/iio/adc/spear_adc.c
+++ b/drivers/staging/iio/adc/spear_adc.c
@@ -168,10 +168,9 @@ static int spear_read_raw(struct iio_dev *indio_dev,
 		return IIO_VAL_INT;
 
 	case IIO_CHAN_INFO_SCALE:
-		scale_mv = (info->vref_external * 1000) >> DATA_BITS;
-		*val =  scale_mv / 1000;
-		*val2 = (scale_mv % 1000) * 1000;
-		return IIO_VAL_INT_PLUS_MICRO;
+		*val = info->vref_external;
+		*val2 = DATA_BITS;
+		return IIO_VAL_FRACTIONAL_LOG2;
 	}
 
 	return -EINVAL;
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 25/25] iio: Update unit of the voltage scale in the documentation
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (22 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 24/25] staging:iio:spear_adc: " Lars-Peter Clausen
@ 2013-09-28  9:31 ` Lars-Peter Clausen
  2013-10-01  9:14   ` Jonathan Cameron
  2013-10-01  8:46 ` [PATCH 01/25] iio:ad5064: Report scale as fractional value Jonathan Cameron
  24 siblings, 1 reply; 49+ messages in thread
From: Lars-Peter Clausen @ 2013-09-28  9:31 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

The documentation says that the result of raw * scale should be in microvolts,
but in reallity all drivers actually report the scale so that the result is in
millivolts. So update the documentation to match reallity.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 Documentation/ABI/testing/sysfs-bus-iio | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index ab1047c..2d736208 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -79,7 +79,7 @@ Description:
 		correspond to externally available input one of the named
 		versions may be used. The number must always be specified and
 		unique to allow association with event codes. Units after
-		application of scale and offset are microvolts.
+		application of scale and offset are millivolts.
 
 What:		/sys/bus/iio/devices/iio:deviceX/in_voltageY-voltageZ_raw
 KernelVersion:	2.6.35
@@ -90,7 +90,7 @@ Description:
 		physically equivalent inputs when non differential readings are
 		separately available. In differential only parts, then all that
 		is required is a consistent labeling.  Units after application
-		of scale and offset are microvolts.
+		of scale and offset are millivolts.
 
 What:		/sys/bus/iio/devices/iio:deviceX/in_capacitanceY_raw
 KernelVersion:	3.2
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH 01/25] iio:ad5064: Report scale as fractional value
  2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
                   ` (23 preceding siblings ...)
  2013-09-28  9:31 ` [PATCH 25/25] iio: Update unit of the voltage scale in the documentation Lars-Peter Clausen
@ 2013-10-01  8:46 ` Jonathan Cameron
  24 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  8:46 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

Thanks
> ---
>  drivers/iio/dac/ad5064.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c
> index b18e8c4..cb9c636 100644
> --- a/drivers/iio/dac/ad5064.c
> +++ b/drivers/iio/dac/ad5064.c
> @@ -239,10 +239,9 @@ static int ad5064_read_raw(struct iio_dev *indio_dev,
>  		if (scale_uv < 0)
>  			return scale_uv;
>  
> -		scale_uv = (scale_uv * 100) >> chan->scan_type.realbits;
> -		*val =  scale_uv / 100000;
> -		*val2 = (scale_uv % 100000) * 10;
> -		return IIO_VAL_INT_PLUS_MICRO;
> +		*val = scale_uv / 1000;
> +		*val2 = chan->scan_type.realbits;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	default:
>  		break;
>  	}
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 02/25] iio:ad5360: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 02/25] iio:ad5360: " Lars-Peter Clausen
@ 2013-10-01  8:48   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  8:48 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

Thanks
> ---
>  drivers/iio/dac/ad5360.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5360.c b/drivers/iio/dac/ad5360.c
> index d2da71e..b968af5 100644
> --- a/drivers/iio/dac/ad5360.c
> +++ b/drivers/iio/dac/ad5360.c
> @@ -379,15 +379,14 @@ static int ad5360_read_raw(struct iio_dev *indio_dev,
>  		*val = ret >> chan->scan_type.shift;
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_SCALE:
> -		/* vout = 4 * vref * dac_code */
> -		scale_uv = ad5360_get_channel_vref(st, chan->channel) * 4 * 100;
> +		scale_uv = ad5360_get_channel_vref(st, chan->channel);
>  		if (scale_uv < 0)
>  			return scale_uv;
>  
> -		scale_uv >>= (chan->scan_type.realbits);
> -		*val =  scale_uv / 100000;
> -		*val2 = (scale_uv % 100000) * 10;
> -		return IIO_VAL_INT_PLUS_MICRO;
> +		/* vout = 4 * vref * dac_code */
> +		*val = scale_uv * 4 / 1000;
> +		*val2 = chan->scan_type.realbits;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	case IIO_CHAN_INFO_CALIBBIAS:
>  		ret = ad5360_read(indio_dev, AD5360_READBACK_OFFSET,
>  			chan->address);
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 03/25] iio:ad5380: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 03/25] iio:ad5380: " Lars-Peter Clausen
@ 2013-10-01  8:49   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  8:49 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

Thanks
> ---
>  drivers/iio/dac/ad5380.c | 40 +++++++++++++++++++---------------------
>  1 file changed, 19 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c
> index 4c791e6..a59ff0e 100644
> --- a/drivers/iio/dac/ad5380.c
> +++ b/drivers/iio/dac/ad5380.c
> @@ -204,7 +204,6 @@ static int ad5380_read_raw(struct iio_dev *indio_dev,
>  	struct iio_chan_spec const *chan, int *val, int *val2, long info)
>  {
>  	struct ad5380_state *st = iio_priv(indio_dev);
> -	unsigned long scale_uv;
>  	int ret;
>  
>  	switch (info) {
> @@ -225,10 +224,9 @@ static int ad5380_read_raw(struct iio_dev *indio_dev,
>  		val -= (1 << chan->scan_type.realbits) / 2;
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_SCALE:
> -		scale_uv = ((2 * st->vref) >> chan->scan_type.realbits) * 100;
> -		*val =  scale_uv / 100000;
> -		*val2 = (scale_uv % 100000) * 10;
> -		return IIO_VAL_INT_PLUS_MICRO;
> +		*val = 2 * st->vref;
> +		*val2 = chan->scan_type.realbits;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	default:
>  		break;
>  	}
> @@ -271,72 +269,72 @@ static const struct ad5380_chip_info ad5380_chip_info_tbl[] = {
>  	[ID_AD5380_3] = {
>  		.channel_template = AD5380_CHANNEL(14),
>  		.num_channels = 40,
> -		.int_vref = 1250000,
> +		.int_vref = 1250,
>  	},
>  	[ID_AD5380_5] = {
>  		.channel_template = AD5380_CHANNEL(14),
>  		.num_channels = 40,
> -		.int_vref = 2500000,
> +		.int_vref = 2500,
>  	},
>  	[ID_AD5381_3] = {
>  		.channel_template = AD5380_CHANNEL(12),
>  		.num_channels = 16,
> -		.int_vref = 1250000,
> +		.int_vref = 1250,
>  	},
>  	[ID_AD5381_5] = {
>  		.channel_template = AD5380_CHANNEL(12),
>  		.num_channels = 16,
> -		.int_vref = 2500000,
> +		.int_vref = 2500,
>  	},
>  	[ID_AD5382_3] = {
>  		.channel_template = AD5380_CHANNEL(14),
>  		.num_channels = 32,
> -		.int_vref = 1250000,
> +		.int_vref = 1250,
>  	},
>  	[ID_AD5382_5] = {
>  		.channel_template = AD5380_CHANNEL(14),
>  		.num_channels = 32,
> -		.int_vref = 2500000,
> +		.int_vref = 2500,
>  	},
>  	[ID_AD5383_3] = {
>  		.channel_template = AD5380_CHANNEL(12),
>  		.num_channels = 32,
> -		.int_vref = 1250000,
> +		.int_vref = 1250,
>  	},
>  	[ID_AD5383_5] = {
>  		.channel_template = AD5380_CHANNEL(12),
>  		.num_channels = 32,
> -		.int_vref = 2500000,
> +		.int_vref = 2500,
>  	},
>  	[ID_AD5390_3] = {
>  		.channel_template = AD5380_CHANNEL(14),
>  		.num_channels = 16,
> -		.int_vref = 1250000,
> +		.int_vref = 1250,
>  	},
>  	[ID_AD5390_5] = {
>  		.channel_template = AD5380_CHANNEL(14),
>  		.num_channels = 16,
> -		.int_vref = 2500000,
> +		.int_vref = 2500,
>  	},
>  	[ID_AD5391_3] = {
>  		.channel_template = AD5380_CHANNEL(12),
>  		.num_channels = 16,
> -		.int_vref = 1250000,
> +		.int_vref = 1250,
>  	},
>  	[ID_AD5391_5] = {
>  		.channel_template = AD5380_CHANNEL(12),
>  		.num_channels = 16,
> -		.int_vref = 2500000,
> +		.int_vref = 2500,
>  	},
>  	[ID_AD5392_3] = {
>  		.channel_template = AD5380_CHANNEL(14),
>  		.num_channels = 8,
> -		.int_vref = 1250000,
> +		.int_vref = 1250,
>  	},
>  	[ID_AD5392_5] = {
>  		.channel_template = AD5380_CHANNEL(14),
>  		.num_channels = 8,
> -		.int_vref = 2500000,
> +		.int_vref = 2500,
>  	},
>  };
>  
> @@ -395,7 +393,7 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap,
>  		return ret;
>  	}
>  
> -	if (st->chip_info->int_vref == 2500000)
> +	if (st->chip_info->int_vref == 2500)
>  		ctrl |= AD5380_CTRL_INT_VREF_2V5;
>  
>  	st->vref_reg = devm_regulator_get(dev, "vref");
> @@ -411,7 +409,7 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap,
>  		if (ret < 0)
>  			goto error_disable_reg;
>  
> -		st->vref = ret;
> +		st->vref = ret / 1000;
>  	} else {
>  		st->vref = st->chip_info->int_vref;
>  		ctrl |= AD5380_CTRL_INT_VREF_EN;
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 04/25] iio:ad5421: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 04/25] iio:ad5421: " Lars-Peter Clausen
@ 2013-10-01  8:50   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  8:50 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

Thanks
> ---
>  drivers/iio/dac/ad5421.c | 16 +++++-----------
>  1 file changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5421.c b/drivers/iio/dac/ad5421.c
> index 1f78b14..567c4bd 100644
> --- a/drivers/iio/dac/ad5421.c
> +++ b/drivers/iio/dac/ad5421.c
> @@ -281,18 +281,11 @@ static inline unsigned int ad5421_get_offset(struct ad5421_state *st)
>  	return (min * (1 << 16)) / (max - min);
>  }
>  
> -static inline unsigned int ad5421_get_scale(struct ad5421_state *st)
> -{
> -	unsigned int min, max;
> -
> -	ad5421_get_current_min_max(st, &min, &max);
> -	return ((max - min) * 1000) / (1 << 16);
> -}
> -
>  static int ad5421_read_raw(struct iio_dev *indio_dev,
>  	struct iio_chan_spec const *chan, int *val, int *val2, long m)
>  {
>  	struct ad5421_state *st = iio_priv(indio_dev);
> +	unsigned int min, max;
>  	int ret;
>  
>  	if (chan->type != IIO_CURRENT)
> @@ -306,9 +299,10 @@ static int ad5421_read_raw(struct iio_dev *indio_dev,
>  		*val = ret;
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_SCALE:
> -		*val = 0;
> -		*val2 = ad5421_get_scale(st);
> -		return IIO_VAL_INT_PLUS_MICRO;
> +		ad5421_get_current_min_max(st, &min, &max);
> +		*val = max - min;
> +		*val2 = (1 << 16) * 1000;
> +		return IIO_VAL_FRACTIONAL;
>  	case IIO_CHAN_INFO_OFFSET:
>  		*val = ad5421_get_offset(st);
>  		return IIO_VAL_INT;
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 05/25] iio:ad5446: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 05/25] iio:ad5446: " Lars-Peter Clausen
@ 2013-10-01  8:51   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  8:51 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

Thanks,
> ---
>  drivers/iio/dac/ad5446.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5446.c b/drivers/iio/dac/ad5446.c
> index 6dcb6d9..cb72f01 100644
> --- a/drivers/iio/dac/ad5446.c
> +++ b/drivers/iio/dac/ad5446.c
> @@ -163,18 +163,15 @@ static int ad5446_read_raw(struct iio_dev *indio_dev,
>  			   long m)
>  {
>  	struct ad5446_state *st = iio_priv(indio_dev);
> -	unsigned long scale_uv;
>  
>  	switch (m) {
>  	case IIO_CHAN_INFO_RAW:
>  		*val = st->cached_val;
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_SCALE:
> -		scale_uv = (st->vref_mv * 1000) >> chan->scan_type.realbits;
> -		*val =  scale_uv / 1000;
> -		*val2 = (scale_uv % 1000) * 1000;
> -		return IIO_VAL_INT_PLUS_MICRO;
> -
> +		*val = st->vref_mv;
> +		*val2 = chan->scan_type.realbits;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	}
>  	return -EINVAL;
>  }
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 06/25] iio:ad5504: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 06/25] iio:ad5504: " Lars-Peter Clausen
@ 2013-10-01  8:52   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  8:52 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

Thanks,
> ---
>  drivers/iio/dac/ad5504.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c
> index 31f4ff2..c0957a9 100644
> --- a/drivers/iio/dac/ad5504.c
> +++ b/drivers/iio/dac/ad5504.c
> @@ -100,7 +100,6 @@ static int ad5504_read_raw(struct iio_dev *indio_dev,
>  			   long m)
>  {
>  	struct ad5504_state *st = iio_priv(indio_dev);
> -	unsigned long scale_uv;
>  	int ret;
>  
>  	switch (m) {
> @@ -113,11 +112,9 @@ static int ad5504_read_raw(struct iio_dev *indio_dev,
>  
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_SCALE:
> -		scale_uv = (st->vref_mv * 1000) >> chan->scan_type.realbits;
> -		*val =  scale_uv / 1000;
> -		*val2 = (scale_uv % 1000) * 1000;
> -		return IIO_VAL_INT_PLUS_MICRO;
> -
> +		*val = st->vref_mv;
> +		*val2 = chan->scan_type.realbits;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	}
>  	return -EINVAL;
>  }
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 07/25] iio:ad5624r: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 07/25] iio:ad5624r: " Lars-Peter Clausen
@ 2013-10-01  8:52   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  8:52 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

Thanks,
> ---
>  drivers/iio/dac/ad5624r_spi.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5624r_spi.c b/drivers/iio/dac/ad5624r_spi.c
> index dbb1289..774dd96 100644
> --- a/drivers/iio/dac/ad5624r_spi.c
> +++ b/drivers/iio/dac/ad5624r_spi.c
> @@ -50,15 +50,12 @@ static int ad5624r_read_raw(struct iio_dev *indio_dev,
>  			   long m)
>  {
>  	struct ad5624r_state *st = iio_priv(indio_dev);
> -	unsigned long scale_uv;
>  
>  	switch (m) {
>  	case IIO_CHAN_INFO_SCALE:
> -		scale_uv = (st->vref_mv * 1000) >> chan->scan_type.realbits;
> -		*val =  scale_uv / 1000;
> -		*val2 = (scale_uv % 1000) * 1000;
> -		return IIO_VAL_INT_PLUS_MICRO;
> -
> +		*val = st->vref_mv;
> +		*val2 = chan->scan_type.realbits;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	}
>  	return -EINVAL;
>  }
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 08/25] iio:ad5686: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 08/25] iio:ad5686: " Lars-Peter Clausen
@ 2013-10-01  8:53   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  8:53 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied
> ---
>  drivers/iio/dac/ad5686.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
> index f472b48..30e506e 100644
> --- a/drivers/iio/dac/ad5686.c
> +++ b/drivers/iio/dac/ad5686.c
> @@ -201,7 +201,6 @@ static int ad5686_read_raw(struct iio_dev *indio_dev,
>  			   long m)
>  {
>  	struct ad5686_state *st = iio_priv(indio_dev);
> -	unsigned long scale_uv;
>  	int ret;
>  
>  	switch (m) {
> @@ -214,12 +213,9 @@ static int ad5686_read_raw(struct iio_dev *indio_dev,
>  		*val = ret;
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_SCALE:
> -		scale_uv = (st->vref_mv * 100000)
> -			>> (chan->scan_type.realbits);
> -		*val =  scale_uv / 100000;
> -		*val2 = (scale_uv % 100000) * 10;
> -		return IIO_VAL_INT_PLUS_MICRO;
> -
> +		*val = st->vref_mv;
> +		*val2 = chan->scan_type.realbits;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	}
>  	return -EINVAL;
>  }
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 09/25] iio:ad5755: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 09/25] iio:ad5755: " Lars-Peter Clausen
@ 2013-10-01  8:53   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  8:53 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied.
> ---
>  drivers/iio/dac/ad5755.c | 17 +++++------------
>  1 file changed, 5 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c
> index f305a0c..bd31dbc 100644
> --- a/drivers/iio/dac/ad5755.c
> +++ b/drivers/iio/dac/ad5755.c
> @@ -253,15 +253,6 @@ static inline int ad5755_get_offset(struct ad5755_state *st,
>  	return (min * (1 << chan->scan_type.realbits)) / (max - min);
>  }
>  
> -static inline int ad5755_get_scale(struct ad5755_state *st,
> -	struct iio_chan_spec const *chan)
> -{
> -	int min, max;
> -
> -	ad5755_get_min_max(st, chan, &min, &max);
> -	return ((max - min) * 1000000000ULL) >> chan->scan_type.realbits;
> -}
> -
>  static int ad5755_chan_reg_info(struct ad5755_state *st,
>  	struct iio_chan_spec const *chan, long info, bool write,
>  	unsigned int *reg, unsigned int *shift, unsigned int *offset)
> @@ -303,13 +294,15 @@ static int ad5755_read_raw(struct iio_dev *indio_dev,
>  {
>  	struct ad5755_state *st = iio_priv(indio_dev);
>  	unsigned int reg, shift, offset;
> +	int min, max;
>  	int ret;
>  
>  	switch (info) {
>  	case IIO_CHAN_INFO_SCALE:
> -		*val = 0;
> -		*val2 = ad5755_get_scale(st, chan);
> -		return IIO_VAL_INT_PLUS_NANO;
> +		ad5755_get_min_max(st, chan, &min, &max);
> +		*val = max - min;
> +		*val2 = chan->scan_type.realbits;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	case IIO_CHAN_INFO_OFFSET:
>  		*val = ad5755_get_offset(st, chan);
>  		return IIO_VAL_INT;
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 10/25] iio:ad5764: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 10/25] iio:ad5764: " Lars-Peter Clausen
@ 2013-10-01  8:54   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  8:54 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Also fix a off by one error in the comment describing the transfer function.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

Thanks
> ---
>  drivers/iio/dac/ad5764.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5764.c b/drivers/iio/dac/ad5764.c
> index df7e028..a8ff5b2 100644
> --- a/drivers/iio/dac/ad5764.c
> +++ b/drivers/iio/dac/ad5764.c
> @@ -217,7 +217,6 @@ static int ad5764_read_raw(struct iio_dev *indio_dev,
>  	struct iio_chan_spec const *chan, int *val, int *val2, long info)
>  {
>  	struct ad5764_state *st = iio_priv(indio_dev);
> -	unsigned long scale_uv;
>  	unsigned int reg;
>  	int vref;
>  	int ret;
> @@ -245,15 +244,14 @@ static int ad5764_read_raw(struct iio_dev *indio_dev,
>  		*val = sign_extend32(*val, 5);
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_SCALE:
> -		/* vout = 4 * vref + ((dac_code / 65535) - 0.5) */
> +		/* vout = 4 * vref + ((dac_code / 65536) - 0.5) */
>  		vref = ad5764_get_channel_vref(st, chan->channel);
>  		if (vref < 0)
>  			return vref;
>  
> -		scale_uv = (vref * 4 * 100) >> chan->scan_type.realbits;
> -		*val = scale_uv / 100000;
> -		*val2 = (scale_uv % 100000) * 10;
> -		return IIO_VAL_INT_PLUS_MICRO;
> +		*val = vref * 4 / 1000;
> +		*val2 = chan->scan_type.realbits;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	case IIO_CHAN_INFO_OFFSET:
>  		*val = -(1 << chan->scan_type.realbits) / 2;
>  		return IIO_VAL_INT;
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 11/25] iio:ad5791: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 11/25] iio:ad5791: " Lars-Peter Clausen
@ 2013-10-01  9:01   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  9:01 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
The minus 1 in here had me confused for a bit, but that is indeed
the transfer function given in the datasheet.

Applied to the togreg branch of iio.git

Thanks,
> ---
>  drivers/iio/dac/ad5791.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c
> index 3cee89b..d64acbd 100644
> --- a/drivers/iio/dac/ad5791.c
> +++ b/drivers/iio/dac/ad5791.c
> @@ -270,9 +270,9 @@ static int ad5791_read_raw(struct iio_dev *indio_dev,
>  		*val >>= chan->scan_type.shift;
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_SCALE:
> -		*val = 0;
> -		*val2 = (((u64)st->vref_mv) * 1000000ULL) >> chan->scan_type.realbits;
> -		return IIO_VAL_INT_PLUS_MICRO;
> +		*val = st->vref_mv;
> +		*val2 = (1 << chan->scan_type.realbits) - 1;
> +		return IIO_VAL_FRACTIONAL;
>  	case IIO_CHAN_INFO_OFFSET:
>  		val64 = (((u64)st->vref_neg_mv) << chan->scan_type.realbits);
>  		do_div(val64, st->vref_mv);
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 12/25] iio:max517: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 12/25] iio:max517: " Lars-Peter Clausen
@ 2013-10-01  9:03   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  9:03 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio, Roland Stigge

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

This one should have had a cc for Roland so I've added it now.

Roland, shout if you have any comments on this! Whilst it is my
tree I'll probably not send another pull request to Greg until
the weekend.

Thanks,

Jonathan
> ---
>  drivers/iio/dac/max517.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/dac/max517.c b/drivers/iio/dac/max517.c
> index 83adcbf..d26be14 100644
> --- a/drivers/iio/dac/max517.c
> +++ b/drivers/iio/dac/max517.c
> @@ -82,15 +82,13 @@ static int max517_read_raw(struct iio_dev *indio_dev,
>  			   long m)
>  {
>  	struct max517_data *data = iio_priv(indio_dev);
> -	unsigned int scale_uv;
>  
>  	switch (m) {
>  	case IIO_CHAN_INFO_SCALE:
>  		/* Corresponds to Vref / 2^(bits) */
> -		scale_uv = (data->vref_mv[chan->channel] * 1000) >> 8;
> -		*val =  scale_uv / 1000000;
> -		*val2 = scale_uv % 1000000;
> -		return IIO_VAL_INT_PLUS_MICRO;
> +		*val = data->vref_mv[chan->channel];
> +		*val2 = 8;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	default:
>  		break;
>  	}
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 14/25] iio:ad7266: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 14/25] iio:ad7266: " Lars-Peter Clausen
@ 2013-10-01  9:05   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  9:05 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

Thanks
> ---
>  drivers/iio/adc/ad7266.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
> index 656aa3e..f5723cb 100644
> --- a/drivers/iio/adc/ad7266.c
> +++ b/drivers/iio/adc/ad7266.c
> @@ -27,7 +27,7 @@
>  struct ad7266_state {
>  	struct spi_device	*spi;
>  	struct regulator	*reg;
> -	unsigned long		vref_uv;
> +	unsigned long		vref_mv;
>  
>  	struct spi_transfer	single_xfer[3];
>  	struct spi_message	single_msg;
> @@ -156,7 +156,7 @@ static int ad7266_read_raw(struct iio_dev *indio_dev,
>  	struct iio_chan_spec const *chan, int *val, int *val2, long m)
>  {
>  	struct ad7266_state *st = iio_priv(indio_dev);
> -	unsigned long scale_uv;
> +	unsigned long scale_mv;
>  	int ret;
>  
>  	switch (m) {
> @@ -174,16 +174,15 @@ static int ad7266_read_raw(struct iio_dev *indio_dev,
>  
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_SCALE:
> -		scale_uv = (st->vref_uv * 100);
> +		scale_mv = st->vref_mv;
>  		if (st->mode == AD7266_MODE_DIFF)
> -			scale_uv *= 2;
> +			scale_mv *= 2;
>  		if (st->range == AD7266_RANGE_2VREF)
> -			scale_uv *= 2;
> +			scale_mv *= 2;
>  
> -		scale_uv >>= chan->scan_type.realbits;
> -		*val =  scale_uv / 100000;
> -		*val2 = (scale_uv % 100000) * 10;
> -		return IIO_VAL_INT_PLUS_MICRO;
> +		*val = scale_mv;
> +		*val2 = chan->scan_type.realbits;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	case IIO_CHAN_INFO_OFFSET:
>  		if (st->range == AD7266_RANGE_2VREF &&
>  			st->mode != AD7266_MODE_DIFF)
> @@ -414,10 +413,10 @@ static int ad7266_probe(struct spi_device *spi)
>  		if (ret < 0)
>  			goto error_disable_reg;
>  
> -		st->vref_uv = ret;
> +		st->vref_mv = ret / 1000;
>  	} else {
>  		/* Use internal reference */
> -		st->vref_uv = 2500000;
> +		st->vref_mv = 2500;
>  	}
>  
>  	if (pdata) {
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 15/25] iio:ad7476: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 15/25] iio:ad7476: " Lars-Peter Clausen
@ 2013-10-01  9:06   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  9:06 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

Thanks,
> ---
>  drivers/iio/adc/ad7476.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
> index 8d808b9..d141d45 100644
> --- a/drivers/iio/adc/ad7476.c
> +++ b/drivers/iio/adc/ad7476.c
> @@ -127,10 +127,9 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
>  		} else {
>  			scale_uv = st->chip_info->int_vref_uv;
>  		}
> -		scale_uv >>= chan->scan_type.realbits;
> -		*val =  scale_uv / 1000;
> -		*val2 = (scale_uv % 1000) * 1000;
> -		return IIO_VAL_INT_PLUS_MICRO;
> +		*val = scale_uv / 1000;
> +		*val2 = chan->scan_type.realbits;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	}
>  	return -EINVAL;
>  }
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 16/25] iio:ad7791: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 16/25] iio:ad7791: " Lars-Peter Clausen
@ 2013-10-01  9:07   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  9:07 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Nice cleanup in this one.

Applied to the togreg branch of iio.git

Thanks,
> ---
>  drivers/iio/adc/ad7791.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7791.c b/drivers/iio/adc/ad7791.c
> index c202035..c19f8fd 100644
> --- a/drivers/iio/adc/ad7791.c
> +++ b/drivers/iio/adc/ad7791.c
> @@ -202,7 +202,6 @@ static int ad7791_read_raw(struct iio_dev *indio_dev,
>  {
>  	struct ad7791_state *st = iio_priv(indio_dev);
>  	bool unipolar = !!(st->mode & AD7791_MODE_UNIPOLAR);
> -	unsigned long long scale_pv;
>  
>  	switch (info) {
>  	case IIO_CHAN_INFO_RAW:
> @@ -220,23 +219,26 @@ static int ad7791_read_raw(struct iio_dev *indio_dev,
>  	case IIO_CHAN_INFO_SCALE:
>  		/* The monitor channel uses an internal reference. */
>  		if (chan->address == AD7791_CH_AVDD_MONITOR) {
> -			scale_pv = 5850000000000ULL;
> +			/*
> +			 * The signal is attenuated by a factor of 5 and
> +			 * compared against a 1.17V internal reference.
> +			 */
> +			*val = 1170 * 5;
>  		} else {
>  			int voltage_uv;
>  
>  			voltage_uv = regulator_get_voltage(st->reg);
>  			if (voltage_uv < 0)
>  				return voltage_uv;
> -			scale_pv = (unsigned long long)voltage_uv * 1000000;
> +
> +			*val = voltage_uv / 1000;
>  		}
>  		if (unipolar)
> -			scale_pv >>= chan->scan_type.realbits;
> +			*val2 = chan->scan_type.realbits;
>  		else
> -			scale_pv >>= chan->scan_type.realbits - 1;
> -		*val2 = do_div(scale_pv, 1000000000);
> -		*val = scale_pv;
> +			*val2 = chan->scan_type.realbits - 1;
>  
> -		return IIO_VAL_INT_PLUS_NANO;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	}
>  
>  	return -EINVAL;
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 17/25] iio:at91: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 17/25] iio:at91: " Lars-Peter Clausen
@ 2013-10-01  9:07   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  9:07 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio, Josh Wu

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Josh Wu <josh.wu@atmel.com>
Applied to the togreg branch of iio.git

Thanks,
> ---
>  drivers/iio/adc/at91_adc.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> index 5c8f690..ce169d4 100644
> --- a/drivers/iio/adc/at91_adc.c
> +++ b/drivers/iio/adc/at91_adc.c
> @@ -366,9 +366,9 @@ static int at91_adc_read_raw(struct iio_dev *idev,
>  		return IIO_VAL_INT;
>  
>  	case IIO_CHAN_INFO_SCALE:
> -		*val = (st->vref_mv * 1000) >> chan->scan_type.realbits;
> -		*val2 = 0;
> -		return IIO_VAL_INT_PLUS_MICRO;
> +		*val = st->vref_mv;
> +		*val2 = chan->scan_type.realbits;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	default:
>  		break;
>  	}
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 18/25] iio:max1363: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 18/25] iio:max1363: " Lars-Peter Clausen
@ 2013-10-01  9:08   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  9:08 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

Thanks,
> ---
>  drivers/iio/adc/max1363.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c
> index b4bc166..2b34d2f 100644
> --- a/drivers/iio/adc/max1363.c
> +++ b/drivers/iio/adc/max1363.c
> @@ -397,7 +397,6 @@ static int max1363_read_raw(struct iio_dev *indio_dev,
>  {
>  	struct max1363_state *st = iio_priv(indio_dev);
>  	int ret;
> -	unsigned long scale_uv;
>  
>  	switch (m) {
>  	case IIO_CHAN_INFO_RAW:
> @@ -406,10 +405,9 @@ static int max1363_read_raw(struct iio_dev *indio_dev,
>  			return ret;
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_SCALE:
> -		scale_uv = st->vref_uv >> st->chip_info->bits;
> -		*val = scale_uv / 1000;
> -		*val2 = (scale_uv % 1000) * 1000;
> -		return IIO_VAL_INT_PLUS_MICRO;
> +		*val = st->vref_uv / 1000;
> +		*val2 = st->chip_info->bits;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	default:
>  		return -EINVAL;
>  	}
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 19/25] staging:iio:ad7280a: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 19/25] staging:iio:ad7280a: " Lars-Peter Clausen
@ 2013-10-01  9:09   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  9:09 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied
> ---
>  drivers/staging/iio/adc/ad7280a.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> index e7191e4..8209fa5 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -783,7 +783,6 @@ static int ad7280_read_raw(struct iio_dev *indio_dev,
>  			   long m)
>  {
>  	struct ad7280_state *st = iio_priv(indio_dev);
> -	unsigned int scale_uv;
>  	int ret;
>  
>  	switch (m) {
> @@ -804,13 +803,12 @@ static int ad7280_read_raw(struct iio_dev *indio_dev,
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_SCALE:
>  		if ((chan->address & 0xFF) <= AD7280A_CELL_VOLTAGE_6)
> -			scale_uv = (4000 * 1000) >> AD7280A_BITS;
> +			*val = 4000;
>  		else
> -			scale_uv = (5000 * 1000) >> AD7280A_BITS;
> +			*val = 5000;
>  
> -		*val =  scale_uv / 1000;
> -		*val2 = (scale_uv % 1000) * 1000;
> -		return IIO_VAL_INT_PLUS_MICRO;
> +		*val2 = AD7280A_BITS;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	}
>  	return -EINVAL;
>  }
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 20/25] staging:iio:ad7606: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 20/25] staging:iio:ad7606: " Lars-Peter Clausen
@ 2013-10-01  9:10   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  9:10 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied.
> ---
>  drivers/staging/iio/adc/ad7606_core.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c
> index f042027..2083673 100644
> --- a/drivers/staging/iio/adc/ad7606_core.c
> +++ b/drivers/staging/iio/adc/ad7606_core.c
> @@ -85,7 +85,6 @@ static int ad7606_read_raw(struct iio_dev *indio_dev,
>  {
>  	int ret;
>  	struct ad7606_state *st = iio_priv(indio_dev);
> -	unsigned int scale_uv;
>  
>  	switch (m) {
>  	case IIO_CHAN_INFO_RAW:
> @@ -101,11 +100,9 @@ static int ad7606_read_raw(struct iio_dev *indio_dev,
>  		*val = (short) ret;
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_SCALE:
> -		scale_uv = (st->range * 1000 * 2)
> -			>> st->chip_info->channels[0].scan_type.realbits;
> -		*val =  scale_uv / 1000;
> -		*val2 = (scale_uv % 1000) * 1000;
> -		return IIO_VAL_INT_PLUS_MICRO;
> +		*val = st->range * 2;
> +		*val2 = st->chip_info->channels[0].scan_type.realbits;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	}
>  	return -EINVAL;
>  }
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 21/25] staging:iio:ad7780: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 21/25] staging:iio:ad7780: " Lars-Peter Clausen
@ 2013-10-01  9:10   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  9:10 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
applied
> ---
>  drivers/staging/iio/adc/ad7780.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
> index 4f2522a..273add3 100644
> --- a/drivers/staging/iio/adc/ad7780.c
> +++ b/drivers/staging/iio/adc/ad7780.c
> @@ -90,17 +90,14 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
>  			   long m)
>  {
>  	struct ad7780_state *st = iio_priv(indio_dev);
> -	unsigned long scale_uv;
>  
>  	switch (m) {
>  	case IIO_CHAN_INFO_RAW:
>  		return ad_sigma_delta_single_conversion(indio_dev, chan, val);
>  	case IIO_CHAN_INFO_SCALE:
> -		scale_uv = (st->int_vref_mv * 100000 * st->gain)
> -			>> (chan->scan_type.realbits - 1);
> -		*val =  scale_uv / 100000;
> -		*val2 = (scale_uv % 100000) * 10;
> -		return IIO_VAL_INT_PLUS_MICRO;
> +		*val = st->int_vref_mv * st->gain;
> +		*val2 = chan->scan_type.realbits - 1;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	case IIO_CHAN_INFO_OFFSET:
>  		*val -= (1 << (chan->scan_type.realbits - 1));
>  		return IIO_VAL_INT;
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 22/25] staging:iio:ad799x: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 22/25] staging:iio:ad799x: " Lars-Peter Clausen
@ 2013-10-01  9:11   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  9:11 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied
> ---
>  drivers/staging/iio/adc/ad799x_core.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c
> index 3f5142b..eb6a690 100644
> --- a/drivers/staging/iio/adc/ad799x_core.c
> +++ b/drivers/staging/iio/adc/ad799x_core.c
> @@ -163,7 +163,6 @@ static int ad799x_read_raw(struct iio_dev *indio_dev,
>  {
>  	int ret;
>  	struct ad799x_state *st = iio_priv(indio_dev);
> -	unsigned int scale_uv;
>  
>  	switch (m) {
>  	case IIO_CHAN_INFO_RAW:
> @@ -180,10 +179,9 @@ static int ad799x_read_raw(struct iio_dev *indio_dev,
>  			RES_MASK(chan->scan_type.realbits);
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_SCALE:
> -		scale_uv = (st->int_vref_mv * 1000) >> chan->scan_type.realbits;
> -		*val =  scale_uv / 1000;
> -		*val2 = (scale_uv % 1000) * 1000;
> -		return IIO_VAL_INT_PLUS_MICRO;
> +		*val = st->int_vref_mv;
> +		*val2 = chan->scan_type.realbits;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	}
>  	return -EINVAL;
>  }
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 23/25] staging:iio:ad7746: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 23/25] staging:iio:ad7746: " Lars-Peter Clausen
@ 2013-10-01  9:12   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  9:12 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Should probably mention the tidying up in the commit message, but it is
trivial so I won't bother changing it ;)

Applied to the togreg branch of iio.git

Thanks
> ---
>  drivers/staging/iio/cdc/ad7746.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
> index 75a533b..862d68d 100644
> --- a/drivers/staging/iio/cdc/ad7746.c
> +++ b/drivers/staging/iio/cdc/ad7746.c
> @@ -656,20 +656,21 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
>  		switch (chan->type) {
>  		case IIO_CAPACITANCE:
>  			/* 8.192pf / 2^24 */
> -			*val2 = 488;
>  			*val =  0;
> +			*val2 = 488;
> +			ret = IIO_VAL_INT_PLUS_NANO;
>  			break;
>  		case IIO_VOLTAGE:
>  			/* 1170mV / 2^23 */
> -			*val2 = 139475;
> -			*val =  0;
> +			*val = 1170;
> +			*val2 = 23;
> +			ret = IIO_VAL_FRACTIONAL_LOG2;
>  			break;
>  		default:
> -			ret =  -EINVAL;
> -			goto out;
> +			ret = -EINVAL;
> +			break;
>  		}
>  
> -		ret = IIO_VAL_INT_PLUS_NANO;
>  		break;
>  	default:
>  		ret = -EINVAL;
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 24/25] staging:iio:spear_adc: Report scale as fractional value
  2013-09-28  9:31 ` [PATCH 24/25] staging:iio:spear_adc: " Lars-Peter Clausen
@ 2013-10-01  9:13   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  9:13 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio, Stefan Roese

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> Move the complexity of calculating the fixed point scale to the core.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Stefan Roese <sr@denx.de>
Applied to the togreg branch of iio.git

Thanks
> ---
>  drivers/staging/iio/adc/spear_adc.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c
> index 20f2d55..657e01b 100644
> --- a/drivers/staging/iio/adc/spear_adc.c
> +++ b/drivers/staging/iio/adc/spear_adc.c
> @@ -168,10 +168,9 @@ static int spear_read_raw(struct iio_dev *indio_dev,
>  		return IIO_VAL_INT;
>  
>  	case IIO_CHAN_INFO_SCALE:
> -		scale_mv = (info->vref_external * 1000) >> DATA_BITS;
> -		*val =  scale_mv / 1000;
> -		*val2 = (scale_mv % 1000) * 1000;
> -		return IIO_VAL_INT_PLUS_MICRO;
> +		*val = info->vref_external;
> +		*val2 = DATA_BITS;
> +		return IIO_VAL_FRACTIONAL_LOG2;
>  	}
>  
>  	return -EINVAL;
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 25/25] iio: Update unit of the voltage scale in the documentation
  2013-09-28  9:31 ` [PATCH 25/25] iio: Update unit of the voltage scale in the documentation Lars-Peter Clausen
@ 2013-10-01  9:14   ` Jonathan Cameron
  0 siblings, 0 replies; 49+ messages in thread
From: Jonathan Cameron @ 2013-10-01  9:14 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/28/13 10:31, Lars-Peter Clausen wrote:
> The documentation says that the result of raw * scale should be in microvolts,
> but in reallity all drivers actually report the scale so that the result is in
> millivolts. So update the documentation to match reallity.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
I've no idea how we ended up with this being wrong, but it does indeed need fixing!

Anyhow, applied to the togreg branch of iio.git

Thanks for a nice focussed, easy to review series,

Jonathan
> ---
>  Documentation/ABI/testing/sysfs-bus-iio | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
> index ab1047c..2d736208 100644
> --- a/Documentation/ABI/testing/sysfs-bus-iio
> +++ b/Documentation/ABI/testing/sysfs-bus-iio
> @@ -79,7 +79,7 @@ Description:
>  		correspond to externally available input one of the named
>  		versions may be used. The number must always be specified and
>  		unique to allow association with event codes. Units after
> -		application of scale and offset are microvolts.
> +		application of scale and offset are millivolts.
>  
>  What:		/sys/bus/iio/devices/iio:deviceX/in_voltageY-voltageZ_raw
>  KernelVersion:	2.6.35
> @@ -90,7 +90,7 @@ Description:
>  		physically equivalent inputs when non differential readings are
>  		separately available. In differential only parts, then all that
>  		is required is a consistent labeling.  Units after application
> -		of scale and offset are microvolts.
> +		of scale and offset are millivolts.
>  
>  What:		/sys/bus/iio/devices/iio:deviceX/in_capacitanceY_raw
>  KernelVersion:	3.2
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2013-10-01  8:13 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-28  9:31 [PATCH 01/25] iio:ad5064: Report scale as fractional value Lars-Peter Clausen
2013-09-28  9:31 ` [PATCH 02/25] iio:ad5360: " Lars-Peter Clausen
2013-10-01  8:48   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 03/25] iio:ad5380: " Lars-Peter Clausen
2013-10-01  8:49   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 04/25] iio:ad5421: " Lars-Peter Clausen
2013-10-01  8:50   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 05/25] iio:ad5446: " Lars-Peter Clausen
2013-10-01  8:51   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 06/25] iio:ad5504: " Lars-Peter Clausen
2013-10-01  8:52   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 07/25] iio:ad5624r: " Lars-Peter Clausen
2013-10-01  8:52   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 08/25] iio:ad5686: " Lars-Peter Clausen
2013-10-01  8:53   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 09/25] iio:ad5755: " Lars-Peter Clausen
2013-10-01  8:53   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 10/25] iio:ad5764: " Lars-Peter Clausen
2013-10-01  8:54   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 11/25] iio:ad5791: " Lars-Peter Clausen
2013-10-01  9:01   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 12/25] iio:max517: " Lars-Peter Clausen
2013-10-01  9:03   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 13/25] iio:mcp4725: " Lars-Peter Clausen
2013-09-28  9:31 ` [PATCH 14/25] iio:ad7266: " Lars-Peter Clausen
2013-10-01  9:05   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 15/25] iio:ad7476: " Lars-Peter Clausen
2013-10-01  9:06   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 16/25] iio:ad7791: " Lars-Peter Clausen
2013-10-01  9:07   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 17/25] iio:at91: " Lars-Peter Clausen
2013-10-01  9:07   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 18/25] iio:max1363: " Lars-Peter Clausen
2013-10-01  9:08   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 19/25] staging:iio:ad7280a: " Lars-Peter Clausen
2013-10-01  9:09   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 20/25] staging:iio:ad7606: " Lars-Peter Clausen
2013-10-01  9:10   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 21/25] staging:iio:ad7780: " Lars-Peter Clausen
2013-10-01  9:10   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 22/25] staging:iio:ad799x: " Lars-Peter Clausen
2013-10-01  9:11   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 23/25] staging:iio:ad7746: " Lars-Peter Clausen
2013-10-01  9:12   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 24/25] staging:iio:spear_adc: " Lars-Peter Clausen
2013-10-01  9:13   ` Jonathan Cameron
2013-09-28  9:31 ` [PATCH 25/25] iio: Update unit of the voltage scale in the documentation Lars-Peter Clausen
2013-10-01  9:14   ` Jonathan Cameron
2013-10-01  8:46 ` [PATCH 01/25] iio:ad5064: Report scale as fractional value Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).