From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH 03/25] iio:ad5380: Report scale as fractional value
Date: Tue, 01 Oct 2013 09:49:52 +0100 [thread overview]
Message-ID: <524A8CB0.7010804@kernel.org> (raw)
In-Reply-To: <1380360717-26103-3-git-send-email-lars@metafoo.de>
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;
>
next prev parent reply other threads:[~2013-10-01 7:49 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=524A8CB0.7010804@kernel.org \
--to=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).