linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] hwmon: (ibmpowernv) Add support for reset-history sensors
@ 2017-07-26  5:55 Shilpasri G Bhat
  2017-08-09  4:32 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Shilpasri G Bhat @ 2017-07-26  5:55 UTC (permalink / raw)
  To: clg, linux
  Cc: jdelvare, benh, paulus, mpe, linux-hwmon, linuxppc-dev,
	linux-kernel, ego, svaidy, stewart, Shilpasri G Bhat

In P9, OCC allows for clearing the sensor min-max history. This patch
exports attribute to reset history when set will clear the history of
all the sensors owned by CSM and belonging to the chip.

Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
---
This patch is on top of this patchset:
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1453891.html

This patch creates a non-standard attribute called as reset_historyX
which clears the lowest and highest of all the sensors like power,
temperature, voltage belonging to the chip.

 drivers/hwmon/ibmpowernv.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c
index 5ccdd0b..611e472 100644
--- a/drivers/hwmon/ibmpowernv.c
+++ b/drivers/hwmon/ibmpowernv.c
@@ -51,6 +51,7 @@ enum sensors {
 	POWER_SUPPLY,
 	POWER_INPUT,
 	CURRENT,
+	RESET_HISTORY,
 	MAX_SENSOR_TYPE,
 };
 
@@ -78,6 +79,7 @@ enum sensors {
 	{ "in"    },
 	{ "power" },
 	{ "curr"  },
+	{ "reset_history" },
 };
 
 struct sensor_data {
@@ -126,6 +128,25 @@ static ssize_t show_label(struct device *dev, struct device_attribute *devattr,
 	return sprintf(buf, "%s\n", sdata->label);
 }
 
+static ssize_t store_reset_history(struct device *dev,
+				   struct device_attribute *devattr,
+				   const char *buf, size_t count)
+{
+	struct sensor_data *sdata = container_of(devattr, struct sensor_data,
+						 dev_attr);
+	int rc;
+	int reset;
+
+	rc = kstrtoint(buf, 0, &reset);
+	if (rc)
+		return rc;
+
+	if (reset == 1)
+		rc = opal_sensor_groups_clear_history(sdata->id);
+
+	return rc ? rc : count;
+}
+
 static int __init get_logical_cpu(int hwcpu)
 {
 	int cpu;
@@ -458,6 +479,16 @@ static int create_device_attrs(struct platform_device *pdev)
 
 		create_hwmon_attr(&sdata[count], attr_name, show_sensor);
 
+		if (type == RESET_HISTORY) {
+			snprintf(sdata[count].name, MAX_ATTR_LEN, "%s%d",
+				 sensor_groups[type].name,
+				 sdata[count].hwmon_index);
+
+			sdata[count].dev_attr.attr.mode = 0220;
+			sdata[count].dev_attr.store = store_reset_history;
+			sdata[count].dev_attr.show = NULL;
+		}
+
 		pgroups[type]->attrs[sensor_groups[type].attr_count++] =
 				&sdata[count++].dev_attr.attr;
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC] hwmon: (ibmpowernv) Add support for reset-history sensors
  2017-07-26  5:55 [RFC] hwmon: (ibmpowernv) Add support for reset-history sensors Shilpasri G Bhat
@ 2017-08-09  4:32 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2017-08-09  4:32 UTC (permalink / raw)
  To: Shilpasri G Bhat, clg
  Cc: jdelvare, benh, paulus, mpe, linux-hwmon, linuxppc-dev,
	linux-kernel, ego, svaidy, stewart

On 07/25/2017 10:55 PM, Shilpasri G Bhat wrote:
> In P9, OCC allows for clearing the sensor min-max history. This patch
> exports attribute to reset history when set will clear the history of
> all the sensors owned by CSM and belonging to the chip.
> 
> Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
> ---
> This patch is on top of this patchset:
> https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1453891.html
> 
> This patch creates a non-standard attribute called as reset_historyX
> which clears the lowest and highest of all the sensors like power,
> temperature, voltage belonging to the chip.
> 
>   drivers/hwmon/ibmpowernv.c | 31 +++++++++++++++++++++++++++++++
>   1 file changed, 31 insertions(+)
> 
> diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c
> index 5ccdd0b..611e472 100644
> --- a/drivers/hwmon/ibmpowernv.c
> +++ b/drivers/hwmon/ibmpowernv.c
> @@ -51,6 +51,7 @@ enum sensors {
>   	POWER_SUPPLY,
>   	POWER_INPUT,
>   	CURRENT,
> +	RESET_HISTORY,
>   	MAX_SENSOR_TYPE,
>   };
>   
> @@ -78,6 +79,7 @@ enum sensors {
>   	{ "in"    },
>   	{ "power" },
>   	{ "curr"  },
> +	{ "reset_history" },
>   };
>   
>   struct sensor_data {
> @@ -126,6 +128,25 @@ static ssize_t show_label(struct device *dev, struct device_attribute *devattr,
>   	return sprintf(buf, "%s\n", sdata->label);
>   }
>   
> +static ssize_t store_reset_history(struct device *dev,
> +				   struct device_attribute *devattr,
> +				   const char *buf, size_t count)
> +{
> +	struct sensor_data *sdata = container_of(devattr, struct sensor_data,
> +						 dev_attr);
> +	int rc;
> +	int reset;
> +
> +	rc = kstrtoint(buf, 0, &reset);
> +	if (rc)
> +		return rc;
> +
> +	if (reset == 1)
> +		rc = opal_sensor_groups_clear_history(sdata->id);
> +

Which of course doesn't exist, so it is hard to determine if this is
all that is offered.

I'd rather stick with the existing ABI, which resets the history either
per sensor(inX_reset_history) or per group (in_reset_history).

Guenter

> +	return rc ? rc : count;
> +}
> +
>   static int __init get_logical_cpu(int hwcpu)
>   {
>   	int cpu;
> @@ -458,6 +479,16 @@ static int create_device_attrs(struct platform_device *pdev)
>   
>   		create_hwmon_attr(&sdata[count], attr_name, show_sensor);
>   
> +		if (type == RESET_HISTORY) {
> +			snprintf(sdata[count].name, MAX_ATTR_LEN, "%s%d",
> +				 sensor_groups[type].name,
> +				 sdata[count].hwmon_index);
> +
> +			sdata[count].dev_attr.attr.mode = 0220;
> +			sdata[count].dev_attr.store = store_reset_history;
> +			sdata[count].dev_attr.show = NULL;
> +		}
> +
>   		pgroups[type]->attrs[sensor_groups[type].attr_count++] =
>   				&sdata[count++].dev_attr.attr;
>   
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-09  4:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-26  5:55 [RFC] hwmon: (ibmpowernv) Add support for reset-history sensors Shilpasri G Bhat
2017-08-09  4:32 ` Guenter Roeck

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).