From patchwork Mon Jun 19 12:52:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 9796011 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 001BA600C5 for ; Mon, 19 Jun 2017 14:37:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D19DF26C9B for ; Mon, 19 Jun 2017 14:37:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C62B226E46; Mon, 19 Jun 2017 14:37:36 +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 38F6B26C9B for ; Mon, 19 Jun 2017 14:37:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750911AbdFSOhg (ORCPT ); Mon, 19 Jun 2017 10:37:36 -0400 Received: from 14.mo4.mail-out.ovh.net ([46.105.40.29]:41425 "EHLO 14.mo4.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751175AbdFSOhf (ORCPT ); Mon, 19 Jun 2017 10:37:35 -0400 X-Greylist: delayed 3292 seconds by postgrey-1.27 at vger.kernel.org; Mon, 19 Jun 2017 10:37:35 EDT Received: from player772.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo4.mail-out.ovh.net (Postfix) with ESMTP id BAD39721E6 for ; Mon, 19 Jun 2017 14:52:33 +0200 (CEST) Received: from zorba.kaod.org (LFbn-1-10652-153.w90-89.abo.wanadoo.fr [90.89.238.153]) (Authenticated sender: postmaster@kaod.org) by player772.ha.ovh.net (Postfix) with ESMTPSA id 96FDF740074; Mon, 19 Jun 2017 14:52:21 +0200 (CEST) Subject: Re: [PATCH] hwmon: (ibmpowernv) Add current(A) sensors To: Shilpasri G Bhat , linux@roeck-us.net, stewart@linux.vnet.ibm.com References: <1497864333-16969-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> Cc: jdelvare@suse.com, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, svaidy@linux.vnet.ibm.com, ego@linux.vnet.ibm.com, linux-hwmon@vger.kernel.org From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= Message-ID: <56a39618-dc4f-385c-77c3-5c9be92e2d48@kaod.org> Date: Mon, 19 Jun 2017 14:52:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1497864333-16969-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> X-Ovh-Tracer-Id: 14488361480184761247 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeljedrkeehgdehlecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd 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 On 06/19/2017 11:25 AM, Shilpasri G Bhat wrote: > This patch exports current(A) sensors in inband sensors copied to > main memory by OCC. > > Signed-off-by: Shilpasri G Bhat > --- > drivers/hwmon/ibmpowernv.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c > index 862b832..e0557f9 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", "ibm,opal-sensor-current"}, > }; > > struct sensor_data { > I know why you are doing that but that is the old (cr?@#!y) way to define sensor types. we should try to improve thing a little more and use the "sensor-type" property only. I think the patch below should help you adding new types without too much changes to your skiboot patchset. Could you please check ? Thanks, C. From: Cédric Le Goater Subject: [PATCH] hwmon: (ibmpowernv) introduce a legacy_compatibles array Date: Mon, 19 Jun 2017 14:29:29 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Today, the type of a PowerNV sensor system is determined with the "compatible" property for legacy Firmwares and with the "sensor-type" for newer ones. The same array of strings is used for both to do the matching and this raises some issue to introduce new sensor types. Let's introduce two different arrays (legacy and current) to make things easier for new sensor types. Signed-off-by: Cédric Le Goater --- drivers/hwmon/ibmpowernv.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux.git/drivers/hwmon/ibmpowernv.c =================================================================== --- linux.git.orig/drivers/hwmon/ibmpowernv.c +++ linux.git/drivers/hwmon/ibmpowernv.c @@ -55,17 +55,27 @@ enum sensors { #define INVALID_INDEX (-1U) +/* + * 'compatible' string properties for sensor types as defined in old + * PowerNV firmware (skiboot). These are ordered as 'enum sensors'. + */ +static const char * const legacy_compatibles[] = { + "ibm,opal-sensor-cooling-fan", + "ibm,opal-sensor-amb-temp", + "ibm,opal-sensor-power-supply", + "ibm,opal-sensor-power" +}; + static struct sensor_group { - const char *name; - const char *compatible; + const char *name; /* matches property 'sensor-type' */ struct attribute_group group; u32 attr_count; u32 hwmon_index; } sensor_groups[] = { - {"fan", "ibm,opal-sensor-cooling-fan"}, - {"temp", "ibm,opal-sensor-amb-temp"}, - {"in", "ibm,opal-sensor-power-supply"}, - {"power", "ibm,opal-sensor-power"} + { "fan" }, + { "temp" }, + { "in" }, + { "power" } }; struct sensor_data { @@ -239,8 +249,8 @@ static int get_sensor_type(struct device enum sensors type; const char *str; - for (type = 0; type < MAX_SENSOR_TYPE; type++) { - if (of_device_is_compatible(np, sensor_groups[type].compatible)) + for (type = 0; type < ARRAY_SIZE(legacy_compatibles); type++) { + if (of_device_is_compatible(np, legacy_compatibles[type])) return type; }