From: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
To: Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>
Cc: linux-hwmon@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-kernel@vger.kernel.org, svaidy@linux.vnet.ibm.com,
ego@linux.vnet.ibm.com, akshay.adiga@linux.vnet.ibm.com,
andrew@aj.id.au, clg@kaod.org,
Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
Subject: [PATCH] hwmon: (ibmpowernv) Add min/max attributes and current sensors
Date: Fri, 21 Apr 2017 10:01:52 +0530 [thread overview]
Message-ID: <1492749112-32465-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> (raw)
Add support for adding min/max values for the inband sensors copied by
OCC to main memory. And also add current(mA) sensors to the list.
Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
---
drivers/hwmon/ibmpowernv.c | 55 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 53 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c
index 6d2e660..1f329fa8 100644
--- a/drivers/hwmon/ibmpowernv.c
+++ b/drivers/hwmon/ibmpowernv.c
@@ -50,6 +50,7 @@ enum sensors {
TEMP,
POWER_SUPPLY,
POWER_INPUT,
+ CURRENT,
MAX_SENSOR_TYPE,
};
@@ -65,7 +66,8 @@ enum sensors {
{"fan", "ibm,opal-sensor-cooling-fan"},
{"temp", "ibm,opal-sensor-amb-temp"},
{"in", "ibm,opal-sensor-power-supply"},
- {"power", "ibm,opal-sensor-power"}
+ {"power", "ibm,opal-sensor-power"},
+ {"curr"}, /* Follows newer device tree compatible ibm,opal-sensor */
};
struct sensor_data {
@@ -287,6 +289,7 @@ static int populate_attr_groups(struct platform_device *pdev)
opal = of_find_node_by_path("/ibm,opal/sensors");
for_each_child_of_node(opal, np) {
const char *label;
+ int len;
if (np->name == NULL)
continue;
@@ -298,10 +301,14 @@ static int populate_attr_groups(struct platform_device *pdev)
sensor_groups[type].attr_count++;
/*
- * add a new attribute for labels
+ * add attributes for labels, min and max
*/
if (!of_property_read_string(np, "label", &label))
sensor_groups[type].attr_count++;
+ if (of_find_property(np, "sensor-data-min", &len))
+ sensor_groups[type].attr_count++;
+ if (of_find_property(np, "sensor-data-max", &len))
+ sensor_groups[type].attr_count++;
}
of_node_put(opal);
@@ -428,6 +435,50 @@ static int create_device_attrs(struct platform_device *pdev)
pgroups[type]->attrs[sensor_groups[type].attr_count++] =
&sdata[count++].dev_attr.attr;
}
+
+ if (!of_property_read_u32(np, "sensor-data-max", &sensor_id)) {
+ switch (type) {
+ case POWER_INPUT:
+ attr_name = "input_highest";
+ break;
+ case TEMP:
+ attr_name = "max";
+ break;
+ default:
+ attr_name = "highest";
+ break;
+ }
+
+ sdata[count].id = sensor_id;
+ sdata[count].type = type;
+ sdata[count].hwmon_index = sdata[count - 1].hwmon_index;
+ create_hwmon_attr(&sdata[count], attr_name,
+ show_sensor);
+ pgroups[type]->attrs[sensor_groups[type].attr_count++] =
+ &sdata[count++].dev_attr.attr;
+ }
+
+ if (!of_property_read_u32(np, "sensor-data-min", &sensor_id)) {
+ switch (type) {
+ case POWER_INPUT:
+ attr_name = "input_lowest";
+ break;
+ case TEMP:
+ attr_name = "min";
+ break;
+ default:
+ attr_name = "lowest";
+ break;
+ }
+
+ sdata[count].id = sensor_id;
+ sdata[count].type = type;
+ sdata[count].hwmon_index = sdata[count - 1].hwmon_index;
+ create_hwmon_attr(&sdata[count], attr_name,
+ show_sensor);
+ pgroups[type]->attrs[sensor_groups[type].attr_count++] =
+ &sdata[count++].dev_attr.attr;
+ }
}
exit_put_node:
--
1.8.3.1
next reply other threads:[~2017-04-21 4:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-21 4:31 Shilpasri G Bhat [this message]
2017-04-21 11:47 ` [PATCH] hwmon: (ibmpowernv) Add min/max attributes and current sensors Cédric Le Goater
2017-04-21 12:39 ` Shilpasri G Bhat
2017-04-22 6:11 ` Michael Ellerman
2017-04-25 14:28 ` Cédric Le Goater
2017-04-25 14:32 ` Cédric Le Goater
2017-04-25 14:34 ` Cédric Le Goater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1492749112-32465-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com \
--to=shilpa.bhat@linux.vnet.ibm.com \
--cc=akshay.adiga@linux.vnet.ibm.com \
--cc=andrew@aj.id.au \
--cc=clg@kaod.org \
--cc=ego@linux.vnet.ibm.com \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
--cc=svaidy@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).