Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752592AbdHIWUN (ORCPT ); Wed, 9 Aug 2017 18:20:13 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57058 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752465AbdHIWUL (ORCPT ); Wed, 9 Aug 2017 18:20:11 -0400 From: Eddie James To: linux@roeck-us.net Cc: jdelvare@suse.com, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, joel@jms.id.au, jk@ozlabs.org, andrew@aj.id.au, cbostic@linux.vnet.ibm.com, eajames@linux.vnet.ibm.com, "Edward A. James" Subject: [PATCH 3/4] drivers/hwmon/pmbus: Add generic alarm bit for iin and pin Date: Wed, 9 Aug 2017 17:19:16 -0500 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1502317157-12648-1-git-send-email-eajames@linux.vnet.ibm.com> References: <1502317157-12648-1-git-send-email-eajames@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17080922-0024-0000-0000-000016FF79EE X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007515; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000219; SDB=6.00899999; UDB=6.00450535; IPR=6.00680205; BA=6.00005520; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016617; XFM=3.00000015; UTC=2017-08-09 22:19:34 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17080922-0025-0000-0000-00004C379FAF Message-Id: <1502317157-12648-4-git-send-email-eajames@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-08-09_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1708090349 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2270 Lines: 58 From: "Edward A. James" Add PB_STATUS_INPUT as the generic alarm bit for iin and pin. We also need to redo the status register checking before setting up the boolean attribute, since it won't necessarily check STATUS_WORD if the device doesn't support it, which we need for this bit. Signed-off-by: Edward A. James --- drivers/hwmon/pmbus/pmbus_core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 277d170..1a51f8f 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -1045,6 +1045,7 @@ static int pmbus_add_sensor_attrs_one(struct i2c_client *client, const struct pmbus_sensor_attr *attr) { struct pmbus_sensor *base; + bool upper = !!(attr->gbit & 0xff00); /* need to check STATUS_WORD */ int ret; if (attr->label) { @@ -1065,10 +1066,13 @@ static int pmbus_add_sensor_attrs_one(struct i2c_client *client, /* * Add generic alarm attribute only if there are no individual * alarm attributes, if there is a global alarm bit, and if - * the generic status register for this page is accessible. + * the generic status register (word or byte, depending on + * which global bit is set) for this page is accessible. */ if (!ret && attr->gbit && - pmbus_check_status_register(client, page)) { + ((upper && pmbus_check_word_register(client, page, + PMBUS_STATUS_WORD)) || + (!upper && pmbus_check_status_register(client, page)))) { ret = pmbus_add_boolean(data, name, "alarm", index, NULL, NULL, PB_STATUS_BASE + page, @@ -1324,6 +1328,7 @@ static int pmbus_add_sensor_attrs(struct i2c_client *client, .func = PMBUS_HAVE_IIN, .sfunc = PMBUS_HAVE_STATUS_INPUT, .sbase = PB_STATUS_INPUT_BASE, + .gbit = PB_STATUS_INPUT, .limit = iin_limit_attrs, .nlimit = ARRAY_SIZE(iin_limit_attrs), }, { @@ -1408,6 +1413,7 @@ static int pmbus_add_sensor_attrs(struct i2c_client *client, .func = PMBUS_HAVE_PIN, .sfunc = PMBUS_HAVE_STATUS_INPUT, .sbase = PB_STATUS_INPUT_BASE, + .gbit = PB_STATUS_INPUT, .limit = pin_limit_attrs, .nlimit = ARRAY_SIZE(pin_limit_attrs), }, { -- 1.8.3.1