Skip to contentSkip to conversation

w1_therm: alarms support by adding sysfs entry. Updating doc

PATCH Superseded Akira Shimahara 1 participant 1 message Apr 29, 2020 W1 dallas's 1-wire bus

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 4/5 w1_therm: alarms support by adding sysfs entry. Updating doc

Patch for enhacement of w1_therm module. Adding device alarms settings by a dedicated sysfs entry alarms (RW) : read or write TH and TL in the device RAM. Checking devices in alarm state could be performed using the master search command.

Updating doc in Documentation/ABI/testing/sysfs-driver-w1_therm accordingly.

---
 .../ABI/testing/sysfs-driver-w1_therm         |  15 ++
 drivers/w1/slaves/w1_therm.c                  | 129 ++++++++++++++++++
 drivers/w1/slaves/w1_therm.h                  |  12 ++
 3 files changed, 156 insertions(+)
Documentation/ABI/testing/sysfs-driver-w1_therm +15 -0
index 279e13d..39488a4 100644
@@ -1,3 +1,18 @@
+What:		/sys/bus/w1/devices/.../alarms
+Date:		Apr 2020
+Contact:	Akira Shimahara <[email protected]>
+Description:
+		(RW) read or write TH and TL (Temperature High an Low) alarms.
+		Values shall be space separated and in the device range
+		(typical -55 degC to 125 degC). Values are integer as they
+		are store in a 8bit register in the device.
+		Lowest value is automatically put to TL.
+		Once set, alarms could be search at master level, refer to
+		Documentation/w1/w1_generic.rst for detailed information
+Users:		any user space application which wants to communicate with
+		w1_term device
+
+
 What:		/sys/bus/w1/devices/.../eeprom
 Date:		Apr 2020
 Contact:	Akira Shimahara <[email protected]>
drivers/w1/slaves/w1_therm.c +129 -0

165 lines not on this page · raw message

drivers/w1/slaves/w1_therm.h +12 -0
index 487156f..4f2dcf0 100644
@@ -287,6 +287,17 @@ static ssize_t resolution_store(struct device *device,
 static ssize_t eeprom_store(struct device *device,
 	struct device_attribute *attr, const char *buf, size_t size);
 
+/** @brief A callback function to set the alarms level
+ *  @param device represents the master device
+ */
+static ssize_t alarms_store(struct device *device,
+	struct device_attribute *attr, const char *buf, size_t size);
+
+/** @brief A callback function to get the alarms level
+ *  @return Low and High alarm, separate by one space
+ */
+static ssize_t alarms_show(struct device *device,
+	struct device_attribute *attr, char *buf);
 /*-----------------------------Attributes declarations----------------------*/
 
 static DEVICE_ATTR_RW(w1_slave);
@@ -295,6 +306,7 @@ static DEVICE_ATTR_RO(temperature);
 static DEVICE_ATTR_RO(ext_power);
 static DEVICE_ATTR_RW(resolution);
 static DEVICE_ATTR_WO(eeprom);
+static DEVICE_ATTR_RW(alarms);
 
 /*--------------------------Interface Functions-----------------------------*/
 
Signature · 1 line
2.25.4