From patchwork Wed Apr 23 17:27:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Moll X-Patchwork-Id: 28927 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E128E203AC for ; Wed, 23 Apr 2014 17:29:14 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id e16sf4497355qcx.2 for ; Wed, 23 Apr 2014 10:29:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=EPC1SezzSTJhAkZ3gFnGTInWcF+gfjUB5vKrFZcKTiY=; b=d/U3DIkHcldWDjdNvLkXSA6WDKgeVLsK65oyOzb/e+eNIYHzL3gIXa4Krwwlt6Hq0z XVk43rxU3qVxIiOJ/YN7ssV/uY4C5tPqLVvXrg/VM5NDX20eZwqe2mSsYkoEepLtpPQz mLbzsf5lMCBdUuAfeZ3zG3pS4YhgQgE0w3AtQPgvf++TOKJRdOGdLkYFLSLGT21rOyrj sLGPEE0fsCIaPyoRQF1GibR6K0N7HhuO+gX1fHKKuuXcmf/faRK8IFFNUDCtOZBybVA5 MtQvVNbI9dEyFV+xSsB5wh2KB3Y0ju7UdIjola/zN/Kc4ugwTW2R8ijwF9saCkcYDpHN DZug== X-Gm-Message-State: ALoCoQmG5Ef1iFqedh+X4+2qC7qslibbjqGe4VnqRxLjl4UX3sAgn6s3Gdf6U1qSWOGoldMktmnb X-Received: by 10.236.182.230 with SMTP id o66mr21668259yhm.12.1398274154359; Wed, 23 Apr 2014 10:29:14 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.31.52 with SMTP id e49ls730267qge.19.gmail; Wed, 23 Apr 2014 10:29:14 -0700 (PDT) X-Received: by 10.220.167.2 with SMTP id o2mr42976997vcy.8.1398274154187; Wed, 23 Apr 2014 10:29:14 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id vv9si306146vcb.91.2014.04.23.10.29.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Apr 2014 10:29:14 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id hr9so1579369vcb.1 for ; Wed, 23 Apr 2014 10:29:14 -0700 (PDT) X-Received: by 10.52.26.161 with SMTP id m1mr12987926vdg.24.1398274154068; Wed, 23 Apr 2014 10:29:14 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp120724vcb; Wed, 23 Apr 2014 10:29:13 -0700 (PDT) X-Received: by 10.15.53.69 with SMTP id q45mr64129745eew.22.1398274153047; Wed, 23 Apr 2014 10:29:13 -0700 (PDT) Received: from flocki.atrpms.net (m.at.physik.fu-berlin.de. [160.45.254.30]) by mx.google.com with ESMTPS id u5si4123966een.233.2014.04.23.10.29.12 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 23 Apr 2014 10:29:13 -0700 (PDT) Received-SPF: none (google.com: lm-sensors-bounces@lm-sensors.org does not designate permitted sender hosts) client-ip=160.45.254.30; Received: from localhost ([::1] helo=m.at.physik.fu-berlin.de) by flocki.atrpms.net with esmtp (Exim 4.80.1) id 1Wd0yf-0005vX-Vq; Wed, 23 Apr 2014 19:28:59 +0200 Received: from fw-tnat.austin.arm.com ([217.140.110.23] helo=collaborate-mta1.arm.com) by mail1.atrpms.net with esmtp (Exim 4.80.1) id 1Wd0yP-0005uR-0s for lm-sensors@lm-sensors.org; Wed, 23 Apr 2014 19:28:43 +0200 Received: from hornet.Cambridge.Arm.com (hornet.cambridge.arm.com [10.2.201.45]) by collaborate-mta1.arm.com (Postfix) with ESMTP id DF6E113FB97; Wed, 23 Apr 2014 12:27:18 -0500 (CDT) X-ACL-Warn: From: Pawel Moll To: Jean Delvare , Guenter Roeck Date: Wed, 23 Apr 2014 18:27:05 +0100 Message-Id: <1398274025-13618-3-git-send-email-pawel.moll@arm.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1398274025-13618-1-git-send-email-pawel.moll@arm.com> References: <1398274025-13618-1-git-send-email-pawel.moll@arm.com> X-HELO-Warning: Remote host 217.140.110.23 (fw-tnat.austin.arm.com) incorrectly presented itself as collaborate-mta1.arm.com X-Scanned: No viruses found. X-Spam-Status: No (score -2.1) X-Spam-Level: -- X-Spam-Report: No (score -2.1) -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.4 AWL AWL: From: address is in the auto white-list X-Scan-Signature: 2a7c481dc829bd5fbb6f6496719c36e1 Cc: Pawel Moll , lm-sensors@lm-sensors.org Subject: [lm-sensors] [PATCH 2/2] hwmon: vexpress: Avoid creating non-existing attributes X-BeenThere: lm-sensors@lm-sensors.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: lm-sensors-bounces@lm-sensors.org Errors-To: lm-sensors-bounces@lm-sensors.org X-Scanned: No viruses found. X-Spam-Status: No (score -1.8) X-Spam-Level: - X-Spam-Report: No (score -1.8) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 AWL AWL: From: address is in the auto white-list X-Scan-Signature: 2d12d33d28c6d1859e63fa02b278ba0f X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: pawel.moll@arm.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 The 'label' attribute was always created but returned -ENOENT if there is no label and such behaviour is undefined from libsensors' point of view. Fixed by providing is_visible method in the attributes group, so the attribute is not created at all when unnecessary. Reported-by: Guenter Roeck Signed-off-by: Pawel Moll --- drivers/hwmon/vexpress.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/vexpress.c b/drivers/hwmon/vexpress.c index 7f96905..8242b75 100644 --- a/drivers/hwmon/vexpress.c +++ b/drivers/hwmon/vexpress.c @@ -43,9 +43,6 @@ static ssize_t vexpress_hwmon_label_show(struct device *dev, { const char *label = of_get_property(dev->of_node, "label", NULL); - if (!label) - return -ENOENT; - return snprintf(buffer, PAGE_SIZE, "%s\n", label); } @@ -84,6 +81,20 @@ static ssize_t vexpress_hwmon_u64_show(struct device *dev, to_sensor_dev_attr(dev_attr)->index)); } +static umode_t vexpress_hwmon_attr_is_visible(struct kobject *kobj, + struct attribute *attr, int index) +{ + struct device *dev = kobj_to_dev(kobj); + struct device_attribute *dev_attr = container_of(attr, + struct device_attribute, attr); + + if (dev_attr->show == vexpress_hwmon_label_show && + !of_get_property(dev->of_node, "label", NULL)) + return 0; + + return attr->mode; +} + static DEVICE_ATTR(name, S_IRUGO, vexpress_hwmon_name_show, NULL); #define VEXPRESS_HWMON_ATTRS(_name, _label_attr, _input_attr) \ @@ -105,6 +116,7 @@ static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, vexpress_hwmon_u32_show, NULL, 1000); static VEXPRESS_HWMON_ATTRS(volt, in1_label, in1_input); static struct attribute_group vexpress_hwmon_group_volt = { + .is_visible = vexpress_hwmon_attr_is_visible, .attrs = vexpress_hwmon_attrs_volt, }; static struct vexpress_hwmon_type vexpress_hwmon_volt = { @@ -121,6 +133,7 @@ static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, vexpress_hwmon_u32_show, NULL, 1000); static VEXPRESS_HWMON_ATTRS(amp, curr1_label, curr1_input); static struct attribute_group vexpress_hwmon_group_amp = { + .is_visible = vexpress_hwmon_attr_is_visible, .attrs = vexpress_hwmon_attrs_amp, }; static struct vexpress_hwmon_type vexpress_hwmon_amp = { @@ -136,6 +149,7 @@ static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, vexpress_hwmon_u32_show, NULL, 1000); static VEXPRESS_HWMON_ATTRS(temp, temp1_label, temp1_input); static struct attribute_group vexpress_hwmon_group_temp = { + .is_visible = vexpress_hwmon_attr_is_visible, .attrs = vexpress_hwmon_attrs_temp, }; static struct vexpress_hwmon_type vexpress_hwmon_temp = { @@ -151,6 +165,7 @@ static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, vexpress_hwmon_u32_show, NULL, 1); static VEXPRESS_HWMON_ATTRS(power, power1_label, power1_input); static struct attribute_group vexpress_hwmon_group_power = { + .is_visible = vexpress_hwmon_attr_is_visible, .attrs = vexpress_hwmon_attrs_power, }; static struct vexpress_hwmon_type vexpress_hwmon_power = { @@ -166,6 +181,7 @@ static SENSOR_DEVICE_ATTR(energy1_input, S_IRUGO, vexpress_hwmon_u64_show, NULL, 1); static VEXPRESS_HWMON_ATTRS(energy, energy1_label, energy1_input); static struct attribute_group vexpress_hwmon_group_energy = { + .is_visible = vexpress_hwmon_attr_is_visible, .attrs = vexpress_hwmon_attrs_energy, }; static struct vexpress_hwmon_type vexpress_hwmon_energy = {