iio: Add a hysteresis event info attribute
authorLars-Peter Clausen <lars@metafoo.de>
Mon, 7 Oct 2013 14:11:00 +0000 (15:11 +0100)
committerJonathan Cameron <jic23@kernel.org>
Sat, 12 Oct 2013 11:51:35 +0000 (12:51 +0100)
For some devices it is possible to configure a hysteresis for threshold (or
similar) events. This patch adds a new hysteresis event info type which allows
for easy creation and read/write handling of the sysfs attribute.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Documentation/ABI/testing/sysfs-bus-iio
drivers/iio/industrialio-event.c
include/linux/iio/types.h

index 2d73620874b2d88f5bb5a3b16cc01f9ccfad5978..b20e829d350f7fa207760fd4c43c6f9b7db7cb60 100644 (file)
@@ -537,6 +537,62 @@ Description:
                value is in raw device units or in processed units (as _raw
                and _input do on sysfs direct channel read attributes).
 
+What:          /sys/.../events/in_accel_x_thresh_rising_hysteresis
+What:          /sys/.../events/in_accel_x_thresh_falling_hysteresis
+What:          /sys/.../events/in_accel_x_thresh_either_hysteresis
+What:          /sys/.../events/in_accel_y_thresh_rising_hysteresis
+What:          /sys/.../events/in_accel_y_thresh_falling_hysteresis
+What:          /sys/.../events/in_accel_y_thresh_either_hysteresis
+What:          /sys/.../events/in_accel_z_thresh_rising_hysteresis
+What:          /sys/.../events/in_accel_z_thresh_falling_hysteresis
+What:          /sys/.../events/in_accel_z_thresh_either_hysteresis
+What:          /sys/.../events/in_anglvel_x_thresh_rising_hysteresis
+What:          /sys/.../events/in_anglvel_x_thresh_falling_hysteresis
+What:          /sys/.../events/in_anglvel_x_thresh_either_hysteresis
+What:          /sys/.../events/in_anglvel_y_thresh_rising_hysteresis
+What:          /sys/.../events/in_anglvel_y_thresh_falling_hysteresis
+What:          /sys/.../events/in_anglvel_y_thresh_either_hysteresis
+What:          /sys/.../events/in_anglvel_z_thresh_rising_hysteresis
+What:          /sys/.../events/in_anglvel_z_thresh_falling_hysteresis
+What:          /sys/.../events/in_anglvel_z_thresh_either_hysteresis
+What:          /sys/.../events/in_magn_x_thresh_rising_hysteresis
+What:          /sys/.../events/in_magn_x_thresh_falling_hysteresis
+What:          /sys/.../events/in_magn_x_thresh_either_hysteresis
+What:          /sys/.../events/in_magn_y_thresh_rising_hysteresis
+What:          /sys/.../events/in_magn_y_thresh_falling_hysteresis
+What:          /sys/.../events/in_magn_y_thresh_either_hysteresis
+What:          /sys/.../events/in_magn_z_thresh_rising_hysteresis
+What:          /sys/.../events/in_magn_z_thresh_falling_hysteresis
+What:          /sys/.../events/in_magn_z_thresh_either_hysteresis
+What:          /sys/.../events/in_voltageY_thresh_rising_hysteresis
+What:          /sys/.../events/in_voltageY_thresh_falling_hysteresis
+What:          /sys/.../events/in_voltageY_thresh_either_hysteresis
+What:          /sys/.../events/in_tempY_thresh_rising_hysteresis
+What:          /sys/.../events/in_tempY_thresh_falling_hysteresis
+What:          /sys/.../events/in_tempY_thresh_either_hysteresis
+What:          /sys/.../events/in_illuminance0_thresh_falling_hysteresis
+what:          /sys/.../events/in_illuminance0_thresh_rising_hysteresis
+what:          /sys/.../events/in_illuminance0_thresh_either_hysteresis
+what:          /sys/.../events/in_proximity0_thresh_falling_hysteresis
+what:          /sys/.../events/in_proximity0_thresh_rising_hysteresis
+what:          /sys/.../events/in_proximity0_thresh_either_hysteresis
+KernelVersion: 3.13
+Contact:       linux-iio@vger.kernel.org
+Description:
+               Specifies the hysteresis of threshold that the device is comparing
+               against for the events enabled by
+               <type>Y[_name]_thresh[_(rising|falling)]_hysteresis.
+               If separate attributes exist for the two directions, but
+               direction is not specified for this attribute, then a single
+               hysteresis value applies to both directions.
+               For falling events the hysteresis is added to the _value attribute for
+               this event to get the upper threshold for when the event goes back to
+               normal, for rising events the hysteresis is subtracted from the _value
+               attribute. E.g. if in_voltage0_raw_thresh_rising_value is set to 1200
+               and in_voltage0_raw_thresh_rising_hysteresis is set to 50. The event
+               will get activated once in_voltage0_raw goes above 1200 and will become
+               deactived again once the value falls below 1150.
+
 What:          /sys/.../events/in_accel_x_raw_roc_rising_value
 What:          /sys/.../events/in_accel_x_raw_roc_falling_value
 What:          /sys/.../events/in_accel_y_raw_roc_rising_value
index b7a5d7cbed42c4089d70b0eef8d270ec7b956ca5..dac15b9f9df8db9bf42518d1394875347b5fb0c6 100644 (file)
@@ -204,6 +204,7 @@ static const char * const iio_ev_dir_text[] = {
 static const char * const iio_ev_info_text[] = {
        [IIO_EV_INFO_ENABLE] = "en",
        [IIO_EV_INFO_VALUE] = "value",
+       [IIO_EV_INFO_HYSTERESIS] = "hysteresis",
 };
 
 static enum iio_event_direction iio_ev_attr_dir(struct iio_dev_attr *attr)
index 18339ef4ff5d4aadfc8aa5e694d6709e7b6554a6..4ac928ee31c5e4c59c03de6aff936190168bb1f2 100644 (file)
@@ -65,6 +65,7 @@ enum iio_event_type {
 enum iio_event_info {
        IIO_EV_INFO_ENABLE,
        IIO_EV_INFO_VALUE,
+       IIO_EV_INFO_HYSTERESIS,
 };
 
 enum iio_event_direction {