diff mbox

[07/11] sensor: add a type property

Message ID 1423117857-32759-8-git-send-email-clg@fr.ibm.com
State Changes Requested
Headers show

Commit Message

Cédric Le Goater Feb. 5, 2015, 6:30 a.m. UTC
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@fr.ibm.com>
---
 hw/dts.c            |    2 +-
 hw/fsp/fsp-sensor.c |   13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

Comments

Stewart Smith Feb. 13, 2015, 4:33 a.m. UTC | #1
Cédric Le Goater <clg@fr.ibm.com> writes:
> 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.

Patch looks good - I guess this points to some standard somewhere?
Documented in linux at all? skiboot?
Cédric Le Goater Feb. 16, 2015, 6:14 p.m. UTC | #2
On 02/13/2015 05:33 AM, Stewart Smith wrote:
> Cédric Le Goater <clg@fr.ibm.com> writes:
>> 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.
> 
> Patch looks good - I guess this points to some standard somewhere?
> Documented in linux at all? 

Well, I took sometime to look at the kernel code and the device trees and
I did not find anything. 

The 'type' property seemed to be quite freestyle to me.

> skiboot?

I added some documentation in skiboot for it but that's all. 

I now realize that patches 10 and 11 where never sent ... I tripped over 
a git send-email command using a 000* pattern. oups. fixing that now.

C.
diff mbox

Patch

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;
 }