From patchwork Wed Jul 26 05:55:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shilpasri G Bhat X-Patchwork-Id: 9864223 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 74F736038F for ; Wed, 26 Jul 2017 05:56:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A06828722 for ; Wed, 26 Jul 2017 05:56:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EAC828725; Wed, 26 Jul 2017 05:56:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D114D28722 for ; Wed, 26 Jul 2017 05:56:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751354AbdGZF4u (ORCPT ); Wed, 26 Jul 2017 01:56:50 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:38218 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750911AbdGZF4t (ORCPT ); Wed, 26 Jul 2017 01:56:49 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6Q5ra4P005725 for ; Wed, 26 Jul 2017 01:56:49 -0400 Received: from e23smtp04.au.ibm.com (e23smtp04.au.ibm.com [202.81.31.146]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bxj3b71j8-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 26 Jul 2017 01:56:49 -0400 Received: from localhost by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 26 Jul 2017 15:56:46 +1000 Received: from d23relay10.au.ibm.com (202.81.31.229) by e23smtp04.au.ibm.com (202.81.31.210) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 26 Jul 2017 15:56:45 +1000 Received: from d23av05.au.ibm.com (d23av05.au.ibm.com [9.190.234.119]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6Q5uadS29622298; Wed, 26 Jul 2017 15:56:44 +1000 Received: from d23av05.au.ibm.com (localhost [127.0.0.1]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v6Q5uBOS006031; Wed, 26 Jul 2017 15:56:12 +1000 Received: from oc4502181600.in.ibm.com (oc4502181600.in.ibm.com [9.124.35.208]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v6Q5u7mW005220; Wed, 26 Jul 2017 15:56:08 +1000 From: Shilpasri G Bhat To: clg@kaod.org, linux@roeck-us.net Cc: jdelvare@suse.com, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, linux-hwmon@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, ego@linux.vnet.ibm.com, svaidy@linux.vnet.ibm.com, stewart@linux.vnet.ibm.com, Shilpasri G Bhat Subject: [RFC] hwmon: (ibmpowernv) Add support for reset-history sensors Date: Wed, 26 Jul 2017 11:25:38 +0530 X-Mailer: git-send-email 1.8.3.1 X-TM-AS-MML: disable x-cbid: 17072605-0012-0000-0000-00000257FBFF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17072605-0013-0000-0000-000007723AC8 Message-Id: <1501048538-23160-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-26_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707260089 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;