From patchwork Thu Sep 4 12:01:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 36700 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A9934202E4 for ; Thu, 4 Sep 2014 12:04:21 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rp18sf50856081iec.8 for ; Thu, 04 Sep 2014 05:04:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=1bmMjw6G+DPtI6X3wbHwVgZcWQvbFAifSABfXD0jHEY=; b=ZZjthMvm30f4F/OUF/kvbmG6Fzo2oXelCPNhsuZ/wTov9LYUGe/L5olSsf5OOSYeD4 NSl3dWtw6JCE/aOXlsMq2ErrsieDvUfq2gFY5niWbnwaYNQKN191+1mviPwpz3+A43+Q rYMWpSAAG7kWdufJrjMEmOEsmnsmQxKdptsUa+Eaa3mbwsvJ0r6Lx6/NWVJnEBNP7Edy cQuS600dmLDI+4SxSNVcVZ1ZHGGL3YFDhf07C78yYLRM6y2CS0XQzyy5dekNrAU0bIw+ 7TKPuJA0f97YFBVP93s+RX60Jb/U6QDhA1IEgBSnGyscn+86KV3y85ytoWjis/nf/pks SL8g== X-Gm-Message-State: ALoCoQn7qaWJjWi1CQX4823sH3VRZgG/mEieqJe1zyLWQTc9gRYJijuJhEyy8DGYAn+OTE+R9/CU X-Received: by 10.182.115.229 with SMTP id jr5mr2253353obb.38.1409832261247; Thu, 04 Sep 2014 05:04:21 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.40.180 with SMTP id x49ls206378qgx.97.gmail; Thu, 04 Sep 2014 05:04:21 -0700 (PDT) X-Received: by 10.220.95.132 with SMTP id d4mr3093801vcn.33.1409832261126; Thu, 04 Sep 2014 05:04:21 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id rk7si5466678vcb.45.2014.09.04.05.04.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Sep 2014 05:04:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id ij19so10287282vcb.26 for ; Thu, 04 Sep 2014 05:04:21 -0700 (PDT) X-Received: by 10.220.169.72 with SMTP id x8mr506071vcy.45.1409832261038; Thu, 04 Sep 2014 05:04:21 -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.221.45.67 with SMTP id uj3csp824547vcb; Thu, 4 Sep 2014 05:04:20 -0700 (PDT) X-Received: by 10.70.96.102 with SMTP id dr6mr8180270pdb.86.1409832260204; Thu, 04 Sep 2014 05:04:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lp3si3076549pab.230.2014.09.04.05.04.14 for ; Thu, 04 Sep 2014 05:04:14 -0700 (PDT) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754002AbaIDMDM (ORCPT + 15 others); Thu, 4 Sep 2014 08:03:12 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:42803 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753774AbaIDMDL (ORCPT ); Thu, 4 Sep 2014 08:03:11 -0400 Received: by mail-pa0-f45.google.com with SMTP id bj1so19703959pad.4 for ; Thu, 04 Sep 2014 05:03:11 -0700 (PDT) X-Received: by 10.66.167.105 with SMTP id zn9mr7802437pab.103.1409832189075; Thu, 04 Sep 2014 05:03:09 -0700 (PDT) Received: from localhost ([122.167.123.172]) by mx.google.com with ESMTPSA id c6sm1527873pbu.59.2014.09.04.05.03.07 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 04 Sep 2014 05:03:08 -0700 (PDT) From: Viresh Kumar To: sre@kernel.org, dbaryshkov@gmail.com, dwmw2@infradead.org, anton@enomsg.org Cc: linux-pm@vger.kernel.org, linaro-kernel@lists.linaro.org, Viresh Kumar Subject: [PATCH 13/15] power-supply: Check for failures only when we can fail Date: Thu, 4 Sep 2014 17:31:34 +0530 Message-Id: X-Mailer: git-send-email 2.0.3.693.g996b0fd In-Reply-To: <2eacd908a8094887cc1796f75ae0513be8a3e36d.1409831636.git.viresh.kumar@linaro.org> References: <2eacd908a8094887cc1796f75ae0513be8a3e36d.1409831636.git.viresh.kumar@linaro.org> In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , In power_supply_show_property() routine, we call ->get_property() conditionally and should check for failure in that case only. There is no point comparing 'ret' for errors when 'ret' is surely zero. Signed-off-by: Viresh Kumar --- drivers/power/power_supply_sysfs.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c index 750a202..c23b1b2 100644 --- a/drivers/power/power_supply_sysfs.c +++ b/drivers/power/power_supply_sysfs.c @@ -73,19 +73,20 @@ static ssize_t power_supply_show_property(struct device *dev, const ptrdiff_t off = attr - power_supply_attrs; union power_supply_propval value; - if (off == POWER_SUPPLY_PROP_TYPE) + if (off == POWER_SUPPLY_PROP_TYPE) { value.intval = psy->type; - else + } else { ret = psy->get_property(psy, off, &value); - if (ret < 0) { - if (ret == -ENODATA) - dev_dbg(dev, "driver has no data for `%s' property\n", - attr->attr.name); - else if (ret != -ENODEV) - dev_err(dev, "driver failed to report `%s' property: %zd\n", - attr->attr.name, ret); - return ret; + if (ret < 0) { + if (ret == -ENODATA) + dev_dbg(dev, "driver has no data for `%s' property\n", + attr->attr.name); + else if (ret != -ENODEV) + dev_err(dev, "driver failed to report `%s' property: %zd\n", + attr->attr.name, ret); + return ret; + } } if (off == POWER_SUPPLY_PROP_STATUS)