From patchwork Wed Mar 18 15:47:44 2015 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: 451520 X-Patchwork-Delegate: benh@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B258F1400B6 for ; Thu, 19 Mar 2015 02:53:49 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 946C31A1095 for ; Thu, 19 Mar 2015 02:53:49 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 727C81A051A for ; Thu, 19 Mar 2015 02:47:59 +1100 (AEDT) Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 18 Mar 2015 15:47:56 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 18 Mar 2015 15:47:54 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id DA53017D8019; Wed, 18 Mar 2015 15:48:18 +0000 (GMT) Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t2IFlr3B9240872; Wed, 18 Mar 2015 15:47:53 GMT Received: from d06av11.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t2IFlq5p017416; Wed, 18 Mar 2015 09:47:53 -0600 Received: from hermes.kaod.org (sig-9-83-179-180.evts.uk.ibm.com [9.83.179.180]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t2IFlnt4017183; Wed, 18 Mar 2015 09:47:52 -0600 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: lm-sensors@lm-sensors.org Subject: [PATCH 4/5] hwmon: (ibmpowernv) change create_hwmon_attr_name() prototype Date: Wed, 18 Mar 2015 16:47:44 +0100 Message-Id: <1426693665-10797-5-git-send-email-clg@fr.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1423117857-32759-1-git-send-email-clg@fr.ibm.com> References: <1423117857-32759-1-git-send-email-clg@fr.ibm.com> MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15031815-0009-0000-0000-000003875A9B Cc: Stewart Smith , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Jean Delvare , Neelesh Gupta , skiboot@lists.ozlabs.org, linuxppc-dev@lists.ozlabs.org, Guenter Roeck X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" It simplifies the creation of the hwmon attributes and will help when support for a new device tree layout is added. The patch also changes the name of the routine to parse_opal_node_name(). Signed-off-by: Cédric Le Goater --- drivers/hwmon/ibmpowernv.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c index edcc4ffa5ad0..570d2360b698 100644 --- a/drivers/hwmon/ibmpowernv.c +++ b/drivers/hwmon/ibmpowernv.c @@ -155,28 +155,22 @@ static const char *convert_opal_attr_name(enum sensors type, * which need to be mapped as fan2_input, temp1_max respectively before * populating them inside hwmon device class. */ -static int create_hwmon_attr_name(struct device *dev, enum sensors type, - const char *node_name, - char *hwmon_attr_name) +static int parse_opal_node_name(const char *node_name, enum sensors type, + u32 *index, const char **hwmon_attr_name) { char attr_suffix[MAX_ATTR_LEN]; const char *attr_name; - u32 index; int err; - err = get_sensor_index_attr(node_name, &index, attr_suffix); - if (err) { - dev_err(dev, "Sensor device node name '%s' is invalid\n", - node_name); + err = get_sensor_index_attr(node_name, index, attr_suffix); + if (err) return err; - } attr_name = convert_opal_attr_name(type, attr_suffix); if (!attr_name) return -ENOENT; - snprintf(hwmon_attr_name, MAX_ATTR_LEN, "%s%d_%s", - sensor_groups[type].name, index, attr_name); + *hwmon_attr_name = attr_name; return 0; } @@ -252,6 +246,9 @@ static int create_device_attrs(struct platform_device *pdev) } for_each_child_of_node(opal, np) { + const char *attr_name; + u32 opal_index; + if (np->name == NULL) continue; @@ -268,10 +265,17 @@ static int create_device_attrs(struct platform_device *pdev) sdata[count].id = sensor_id; sdata[count].type = type; - err = create_hwmon_attr_name(&pdev->dev, type, np->name, - sdata[count].name); - if (err) + + err = parse_opal_node_name(np->name, type, &opal_index, + &attr_name); + if (err) { + dev_err(&pdev->dev, "Sensor device node name '%s' is invalid\n", + np->name); goto exit_put_node; + } + + snprintf(sdata[count].name, MAX_ATTR_LEN, "%s%d_%s", + sensor_groups[type].name, opal_index, attr_name); sysfs_attr_init(&sdata[count].dev_attr.attr); sdata[count].dev_attr.attr.name = sdata[count].name;