Re: [PATCH v1 0/3] iio: afe: rescale: Add INFO_PROCESSED support
From: Peter Rosin
Date: Tue Jun 11 2019 - 07:07:28 EST
On 2019-06-11 11:56, MylÃne Josserand wrote:
> Hello everyone,
> You will find a small series that add the support of processed values
> for iio-rescale driver.
> Thanks to that, it is possible to read processed values in sysfs instead
> of getting only raw and scale values.
> Here is an example for a 3v3 voltage reading:
> # cat /sys/bus/iio/devices/iio\:device1/in_voltage0_scale
> # cat /sys/bus/iio/devices/iio\:device1/in_voltage0_raw
> # cat /sys/bus/iio/devices/iio\:device1/in_voltage0_input
> It is also possible to read directly the processed values using iio-hwmon
> driver (see example in patch03):
> # cat /sys/class/hwmon/hwmon0/in1_input
> I seperated my series in 3 patches:
> - Patch01: Move the scale conversion into a function to prepare the
> support of IIO_CHAN_INFO_PROCESSED.
> - Patch02: Add the support of IIO_CHAN_INFO_PROCESSED.
> - Patch03: Add an example of the use of hwmon and voltage-divider nodes
> in device-tree.
> If you have any feedbacks on it, I will be pleased to read them!
The last patch about hwmon has nothing to do with this series, and
should be possible as-is without any code changes. No? AFAICT,
iio_hwmon calls iio_read_channel_processed, which calls
iio_convert_raw_to_processed_unlocked in case IIO_CHAN_INFO_PROCESSES
is not handled by the driver. Is that not working?
There is also libiio in userspace that provides the scale as a double
and makes the conversion to a processed value trivial, so the series
is really mostly about the convenience of having a human directly
seeing the processed value in sysfs. Right?
If that is deemed valuable, then I think it should be fixed in a
central location, and not individually for each and every driver.
Anyway, not my call, just stating my opinion, but those are the
reasons for me not adding a processed channel from the very beginning.
> Best regards,
> MylÃne Josserand (3):
> iio: afe: rescale: Move scale conversion to new function
> iio: afe: rescale: Add support of CHAN_INFO_PROCESSED
> dt-bindings: iio: afe: Add hwmon example
> .../bindings/iio/afe/voltage-divider.txt | 24 ++++++
> drivers/iio/afe/iio-rescale.c | 96 ++++++++++++++++------
> 2 files changed, 96 insertions(+), 24 deletions(-)