From patchwork Mon Jun 2 06:59:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 31245 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EB2BE203C2 for ; Mon, 2 Jun 2014 06:59:27 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id va2sf24430931obc.5 for ; Sun, 01 Jun 2014 23:59:26 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=lLYuNO9H1aXzJpsqAgnGtOKw3BFWngh+JVJyPMG+h94=; b=hMfHjl8dM/skIHAclDwIZiadLSuR2MOxqX0tHRGe4DeIYPcvqMnZTHQI8h0gf5E7HY k1qP5NZ6FeFLoftyWevIopvJ5PbGH8uO8kRBNQkURP5xOWKp2U0xytStUW9tGGPd5Jkf RqBAvuIUxSvZ7nKyl3qMPQnUF8tIVcfZs9W4ibq7iGQy6eRYkD33pRtRKykukFBXe+bN SM5p2+9Pd0wwozZYepcKV+ZmkGBLVeY1eN4rDDoLX1dWyrWVZhoBNOw+OVViYlds2BKo EEXWz6Ofk2bGLMzIKxcV3dHhxulYIaoenyxaD3PcOqAkkz9n89WwLFGPW/dpR1BRmHpV 9O2A== X-Gm-Message-State: ALoCoQno/T7IIY4z+klMnxSVZelDqbsU8dd3RYs4GgR6VBp882n7TROnXI/F1JIJqicNvl+sM58S X-Received: by 10.42.229.194 with SMTP id jj2mr12097011icb.18.1401692366915; Sun, 01 Jun 2014 23:59:26 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.1 with SMTP id p1ls1900306qga.97.gmail; Sun, 01 Jun 2014 23:59:26 -0700 (PDT) X-Received: by 10.221.58.144 with SMTP id wk16mr28511188vcb.23.1401692366755; Sun, 01 Jun 2014 23:59:26 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id zb8si7459761vdb.58.2014.06.01.23.59.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 01 Jun 2014 23:59:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.174 as permitted sender) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id jw12so4657879veb.5 for ; Sun, 01 Jun 2014 23:59:26 -0700 (PDT) X-Received: by 10.58.182.129 with SMTP id ee1mr28943474vec.14.1401692366416; Sun, 01 Jun 2014 23:59:26 -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 ib8csp76168vcb; Sun, 1 Jun 2014 23:59:25 -0700 (PDT) X-Received: by 10.68.201.68 with SMTP id jy4mr38278486pbc.64.1401692365478; Sun, 01 Jun 2014 23:59:25 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oy9si14712343pbc.166.2014.06.01.23.59.24; Sun, 01 Jun 2014 23:59:24 -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 S1751991AbaFBG7X (ORCPT + 13 others); Mon, 2 Jun 2014 02:59:23 -0400 Received: from mail-qg0-f41.google.com ([209.85.192.41]:49685 "EHLO mail-qg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751567AbaFBG7X (ORCPT ); Mon, 2 Jun 2014 02:59:23 -0400 Received: by mail-qg0-f41.google.com with SMTP id j5so10180432qga.0 for ; Sun, 01 Jun 2014 23:59:22 -0700 (PDT) X-Received: by 10.140.80.67 with SMTP id b61mr42892826qgd.98.1401692362435; Sun, 01 Jun 2014 23:59:22 -0700 (PDT) Received: from localhost (ec2-23-23-178-99.compute-1.amazonaws.com. [23.23.178.99]) by mx.google.com with ESMTPSA id d8sm20123079qas.24.2014.06.01.23.59.17 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 01 Jun 2014 23:59:21 -0700 (PDT) From: Viresh Kumar To: rjw@rjwysocki.net Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, arvind.chauhan@arm.com, inderpal.s@samsung.com, nm@ti.com, chander.kashyap@linaro.org, pavel@ucw.cz, len.brown@intel.com, sudeep.holla@arm.com, Viresh Kumar Subject: [PATCH V5 2/8] opp: call of_node_{get|put}() from of_init_opp_table() Date: Mon, 2 Jun 2014 12:29:05 +0530 Message-Id: X-Mailer: git-send-email 2.0.0.rc2 In-Reply-To: <4139797fe7501ba99adf63ec8e5cf9fa9b24c197.1401191054.git.viresh.kumar@linaro.org> References: <4139797fe7501ba99adf63ec8e5cf9fa9b24c197.1401191054.git.viresh.kumar@linaro.org> 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.128.174 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: , All callers of of_init_opp_table() are required to take reference of dev->of_node, by initiating calls to of_node_{get|put}(), before and after calling of_init_opp_table(). Its better to call these from within of_init_opp_table(), no fun adding redundant code to every caller. Signed-off-by: Viresh Kumar --- V4->V5: do of_node_put() on errors as well drivers/base/power/opp.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index 89ced95..28696af 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -643,13 +643,21 @@ int of_init_opp_table(struct device *dev) { const struct property *prop; const __be32 *val; - int nr; + int nr, ret = 0; - prop = of_find_property(dev->of_node, "operating-points", NULL); - if (!prop) + if (!of_node_get(dev->of_node)) return -ENODEV; - if (!prop->value) - return -ENODATA; + + prop = of_find_property(dev->of_node, "operating-points", NULL); + if (!prop) { + ret = -ENODEV; + goto out; + } + + if (!prop->value) { + ret = -ENODATA; + goto out; + } /* * Each OPP is a set of tuples consisting of frequency and @@ -658,7 +666,8 @@ int of_init_opp_table(struct device *dev) nr = prop->length / sizeof(u32); if (nr % 2) { dev_err(dev, "%s: Invalid OPP list\n", __func__); - return -EINVAL; + ret = -EINVAL; + goto out; } val = prop->value; @@ -672,6 +681,8 @@ int of_init_opp_table(struct device *dev) nr -= 2; } +out: + of_node_put(dev->of_node); return 0; } EXPORT_SYMBOL_GPL(of_init_opp_table);