diff mbox series

[V2,4/4] sensors: occ: Filter out de-configured sensors

Message ID 1513322463-24801-5-git-send-email-shilpa.bhat@linux.vnet.ibm.com
State Superseded
Headers show
Series sensors: occ: Add energy counter and fixes for parsing sensors | expand

Commit Message

Shilpasri G Bhat Dec. 15, 2017, 7:21 a.m. UTC
OCC copies APSS, GPU sensors on platforms that dont have them. The
de-configured sensors are copied with 0 sensor values. So filter
out the zero'ed environment sensors as they are not present on
the system.

Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
---
 hw/occ-sensor.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/hw/occ-sensor.c b/hw/occ-sensor.c
index bc5085a..e41c850 100644
--- a/hw/occ-sensor.c
+++ b/hw/occ-sensor.c
@@ -706,6 +706,17 @@  static void add_sensor_node(const char *loc, const char *type, int i, int attr,
 	*phandle = node->phandle;
 }
 
+static bool check_sensor_sample(struct occ_sensor_data_header *hb, u32 offset)
+{
+	struct occ_sensor_record *ping, *pong;
+
+	ping = (struct occ_sensor_record *)((u64)hb + hb->reading_ping_offset
+					     + offset);
+	pong = (struct occ_sensor_record *)((u64)hb + hb->reading_pong_offset
+					     + offset);
+	return ping->sample || pong->sample;
+}
+
 void occ_sensors_init(void)
 {
 	struct proc_chip *chip;
@@ -759,6 +770,9 @@  void occ_sensors_init(void)
 			if (!(md[i].type & HWMON_SENSORS_MASK))
 				continue;
 
+			if (!check_sensor_sample(hb, md[i].reading_offset))
+				continue;
+
 			if (md[i].location == OCC_SENSOR_LOC_CORE) {
 				int num = parse_entity(md[i].name, NULL);