Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1447205
| From | Quentin Schulz <quentin.schulz@free-electrons.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2 2/4] iio: adc: add support for Allwinner SoCs ADC |
| Date | 2016-07-20 14:40 +0200 |
| Message-ID | <rWYX7-1pp-3@gated-at.bofh.it> (permalink) |
| References | <rV8ed-5Bf-7@gated-at.bofh.it> <rV8ed-5Bf-5@gated-at.bofh.it> <rWvV8-8mi-25@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
On 18/07/2016 15:18, Jonathan Cameron wrote:
[...]
>> +
>> + if (!wait_for_completion_timeout(&info->completion,
>> + msecs_to_jiffies(100))) {
>> + ret = -ETIMEDOUT;
>> + goto out;
>> + }
>> +
>> + if (info->flags & SUNXI_GPADC_ARCH_SUN4I)
>> + *val = info->temp_data * 133 - 257000;
> Why report as processed? I'd just report them as raw with the scale
> and offset provided. It's not a big thing, but if we can leave it so
> that the conversion only occurs when desired, why not?
>
> For in kernel users, this all happen 'automagically' anyway ;)
>
Mmmmh, in the code above we apply the scale on the raw value and then
the offset. While in iio_convert_raw_to_processed
(http://lxr.free-electrons.com/source/drivers/iio/inkern.c#L507), the
offset is applied before the scale.
The way would be to factorize the computation by scale:
Now: *val = raw * scale + offset
Then: *val = (raw + offset/scale) * scale
But the offset is an integer and offset/scale is therefore rounded.
Currently, we have the following values:
sun4i: -257000/133 = -1932.3308270676691
sun5i: -144700/100 = -1447
sun6i: -271000/167 = -1622.754491017964
Do we accept such rounding?
If not, we either stay with the processed value in read_raw or patch
inkern to add an offset to apply after having applied the scale to the
raw value (val2 from iio_channel_read is yet unused with
IIO_CHAN_INFO_OFFSET for example, we could use that to specify an
offset2 to apply after the switch(scale_type)-case).
[...]
Quentin
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 2/4] iio: adc: add support for Allwinner SoCs ADC Quentin Schulz <quentin.schulz@free-electrons.com> - 2016-07-15 12:10 +0200
Re: [PATCH v2 2/4] iio: adc: add support for Allwinner SoCs ADC Maxime Ripard <maxime.ripard@free-electrons.com> - 2016-07-18 15:00 +0200
Re: [PATCH v2 2/4] iio: adc: add support for Allwinner SoCs ADC Quentin Schulz <quentin.schulz@free-electrons.com> - 2016-07-19 11:10 +0200
Re: [PATCH v2 2/4] iio: adc: add support for Allwinner SoCs ADC Maxime Ripard <maxime.ripard@free-electrons.com> - 2016-07-19 14:50 +0200
Re: [PATCH v2 2/4] iio: adc: add support for Allwinner SoCs ADC Jonathan Cameron <jic23@kernel.org> - 2016-07-19 07:40 +0200
Re: [PATCH v2 2/4] iio: adc: add support for Allwinner SoCs ADC Quentin Schulz <quentin.schulz@free-electrons.com> - 2016-07-19 10:40 +0200
Re: [PATCH v2 2/4] iio: adc: add support for Allwinner SoCs ADC Jonathan Cameron <jic23@kernel.org> - 2016-07-20 17:00 +0200
Re: [PATCH v2 2/4] iio: adc: add support for Allwinner SoCs ADC Quentin Schulz <quentin.schulz@free-electrons.com> - 2016-07-21 14:20 +0200
Re: [PATCH v2 2/4] iio: adc: add support for Allwinner SoCs ADC Jonathan Cameron <jic23@kernel.org> - 2016-07-23 13:00 +0200
Re: [PATCH v2 2/4] iio: adc: add support for Allwinner SoCs ADC Quentin Schulz <quentin.schulz@free-electrons.com> - 2016-07-20 14:40 +0200
Re: [PATCH v2 2/4] iio: adc: add support for Allwinner SoCs ADC Crt Mori <cmo@melexis.com> - 2016-07-20 16:20 +0200
Re: [PATCH v2 2/4] iio: adc: add support for Allwinner SoCs ADC Jonathan Cameron <jic23@kernel.org> - 2016-07-20 17:00 +0200
csiph-web