[Skiboot] [PATCH 07/11] sensor: add a type property
Cédric Le Goater
clg at fr.ibm.com
Thu Feb 5 17:30:55 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 b5498d95924b..46391cdbedcc 100644
--- a/hw/dts.c
+++ b/hw/dts.c
@@ -220,7 +220,7 @@ bool dts_sensor_create_nodes(void)
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 90bed4e90922..13fd5cdeb5d1 100644
--- a/hw/fsp/fsp-sensor.c
+++ b/hw/fsp/fsp-sensor.c
@@ -636,6 +636,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)
{
@@ -662,6 +673,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