[Skiboot] [PATCH v2 07/13] sensor: add a type property

Cédric Le Goater clg at fr.ibm.com
Sat Feb 21 01:27:30 AEDT 2015


The hwmon framework in Linux needs a type for the sensors it exposes
in userspace through the sysfs interface. This patch gives Linux a hand
on what is dealing with when parsing the sensor device tree.

Signed-off-by: Cédric Le Goater <clg at fr.ibm.com>
---
 hw/dts.c            |    2 +-
 hw/fsp/fsp-sensor.c |   13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/hw/dts.c b/hw/dts.c
index 434f0add9efa..cdfaba4fab51 100644
--- a/hw/dts.c
+++ b/hw/dts.c
@@ -215,7 +215,7 @@ bool dts_sensor_create_nodes(struct dt_node *sensors)
 			handler = sensor_make_handler(sensor_class,
 					c->pir, SENSOR_DTS_ATTR_TEMP_TRIP);
 			dt_add_property_cells(node, "sensor-status", handler);
-
+			dt_add_property_string(node, "sensor-type", "temp");
 		}
 	}
 
diff --git a/hw/fsp/fsp-sensor.c b/hw/fsp/fsp-sensor.c
index a44a42bb82bd..0d45c07703ce 100644
--- a/hw/fsp/fsp-sensor.c
+++ b/hw/fsp/fsp-sensor.c
@@ -637,6 +637,17 @@ out:
 
 #define MAX_NAME	64
 
+static const char *convert_frc_to_sensor_type(int frc)
+{
+	switch (frc) {
+	case SENSOR_FRC_POWER_SUPPLY:	return "power";
+	case SENSOR_FRC_COOLING_FAN:	return "fan";
+	case SENSOR_FRC_AMB_TEMP:	return "temp";
+	default:
+		return "";
+	}
+}
+
 static struct dt_node *sensor_get_node(struct dt_node *sensors,
 				struct sensor_header *header)
 {
@@ -663,6 +674,8 @@ static struct dt_node *sensor_get_node(struct dt_node *sensors,
 		node = dt_new(sensors, name);
 
 		dt_add_property_string(node, "compatible", "ibm,opal-sensor");
+		dt_add_property_string(node, "sensor-type",
+				convert_frc_to_sensor_type(header->frc));
 	}
 	return node;
 }
-- 
1.7.10.4



More information about the Skiboot mailing list