Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1039379AbdDUMkv (ORCPT ); Fri, 21 Apr 2017 08:40:51 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:49607 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1039347AbdDUMkt (ORCPT ); Fri, 21 Apr 2017 08:40:49 -0400 Subject: Re: [PATCH] hwmon: (ibmpowernv) Add min/max attributes and current sensors To: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= , Jean Delvare , Guenter Roeck , Paul Mackerras , Michael Ellerman References: <1492749112-32465-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> 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 From: Shilpasri G Bhat Date: Fri, 21 Apr 2017 18:09:48 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-TM-AS-MML: disable x-cbid: 17042112-0040-0000-0000-0000030A6EE1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042112-0041-0000-0000-00000C8290B9 Message-Id: <66e927c1-ceec-679d-8eaf-c6686b24b3a7@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-04-21_09:,, 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-1703280000 definitions=main-1704210233 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4129 Lines: 146 Hi Cedric, On 04/21/2017 05:17 PM, C?dric Le Goater wrote: > Hello Shilpasri, > > On 04/21/2017 06:31 AM, Shilpasri G Bhat wrote: >> 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 >> --- >> 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 */ > > why isn't there a compatible string ? > Skiboot exports "ibm,opal-sensor" as compatible string for all the inband sensors. Now if I define that as the compatible string here, then all the sensors would get identified as "curr" type of sensor by the driver. >> }; >> >> 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++; > > We are negating of_property_read_string() above, but not below. > I wonder why ? of_find_property() returns 'struct property *' while of_property_read_string() returns 0 on success. > >> + 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; >> + } > > May be we could use a converting routine here ? create_device_attrs() > is getting big. Okay will do. > >> + 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; >> + } > > same here. Sure. Thanks and Regards, Shilpa > > Thanks, > > C. >> + 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: >> >