aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenny Manne <jenny.v.manne@gmail.com>2021-08-06 11:52:43 +0200
committerHans Verkuil <hverkuil@xs4all.nl>2021-09-09 10:40:34 +0200
commitf60e316d6f7bef8bdb5973130f9dc34c187b0013 (patch)
tree76155548d462f6a01a4dc8ab61202e3b0dcc84a1
parenta4bd381a6d5fd7429b653c4a0050bb5e4a36735c (diff)
industrialio-core.c: add min and max voltage for iio framework
Add minimum and maximum values for the iio framework that are measured over time. A read resets the value. Signed-off-by: Jenny Manne <jenny.v.manne@gmail.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
-rw-r--r--Documentation/ABI/testing/sysfs-bus-iio10
-rw-r--r--drivers/iio/industrialio-core.c1
-rw-r--r--drivers/iio/inkern.c6
-rw-r--r--include/linux/iio/consumer.h17
-rw-r--r--include/linux/iio/types.h1
5 files changed, 34 insertions, 1 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 6ad47a67521c..94e00147b097 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -347,6 +347,16 @@ Description:
used for averaging is device specific. The converting rules for
normal raw values also applies to the averaged raw values.
+What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_min_max_raw
+KernelVersion: 3.5
+Contact: linux-iio@vger.kernel.org
+Description:
+ Min and max raw measurement from channel X. Min and max values
+ are displayed on one line, separated with a single space.
+ These values are reset every time they are read. The converting
+ rules for normal raw values also applies to the min and max raw
+ values.
+
What: /sys/bus/iio/devices/iio:deviceX/in_accel_offset
What: /sys/bus/iio/devices/iio:deviceX/in_accel_x_offset
What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_offset
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 6d2175eb7af2..c702dbf4992d 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -168,6 +168,7 @@ static const char * const iio_chan_info_postfix[] = {
[IIO_CHAN_INFO_OVERSAMPLING_RATIO] = "oversampling_ratio",
[IIO_CHAN_INFO_THERMOCOUPLE_TYPE] = "thermocouple_type",
[IIO_CHAN_INFO_CALIBAMBIENT] = "calibambient",
+ [IIO_CHAN_INFO_MIN_MAX_RAW] = "min_max_raw",
};
/**
* iio_device_id() - query the unique ID for the device
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 391a3380a1d1..681fc1e3dac5 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -724,6 +724,12 @@ int iio_read_channel_scale(struct iio_channel *chan, int *val, int *val2)
}
EXPORT_SYMBOL_GPL(iio_read_channel_scale);
+int iio_read_channel_min_max_raw(struct iio_channel *chan, int *val, int *val2)
+{
+ return iio_read_channel_attribute(chan, val, val2, IIO_CHAN_INFO_MIN_MAX_RAW);
+}
+EXPORT_SYMBOL_GPL(iio_read_channel_min_max_raw);
+
static int iio_channel_read_avail(struct iio_channel *chan,
const int **vals, int *type, int *length,
enum iio_chan_info_enum info)
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index 5fa5957586cf..12a14fa9c17a 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -221,12 +221,27 @@ int iio_read_channel_raw(struct iio_channel *chan,
* Note raw reads from iio channels are in adc counts and hence
* scale will need to be applied if standard units required.
*
- * In opposit to the normal iio_read_channel_raw this function
+ * In opposite to the normal iio_read_channel_raw this function
* returns the average of multiple reads.
*/
int iio_read_channel_average_raw(struct iio_channel *chan, int *val);
/**
+ * iio_read_channel_min_max_raw() - read from a given channel
+ * @chan: The channel being queried.
+ * @val: Min and max values in array.
+ * @val2: Number of values.
+ *
+ * Note raw reads from iio channels are in adc counts and hence
+ * scale will need to be applied if standard units required.
+ *
+ * This function returns the min and max values recorded so far.
+ *
+ * The min and max values are also reset after every read.
+ */
+int iio_read_channel_min_max_raw(struct iio_channel *chan, int *val, int *val2);
+
+/**
* iio_read_channel_processed() - read processed value from a given channel
* @chan: The channel being queried.
* @val: Value read back.
diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
index 84b3f8175cc6..4a6e95f795d2 100644
--- a/include/linux/iio/types.h
+++ b/include/linux/iio/types.h
@@ -62,6 +62,7 @@ enum iio_chan_info_enum {
IIO_CHAN_INFO_OVERSAMPLING_RATIO,
IIO_CHAN_INFO_THERMOCOUPLE_TYPE,
IIO_CHAN_INFO_CALIBAMBIENT,
+ IIO_CHAN_INFO_MIN_MAX_RAW,
};
#endif /* _IIO_TYPES_H_ */

Privacy Policy