From patchwork Mon Aug 10 06:31:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 52134 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by patches.linaro.org (Postfix) with ESMTPS id 8CAFC22919 for ; Mon, 10 Aug 2015 06:32:35 +0000 (UTC) Received: by lbck9 with SMTP id k9sf6577321lbc.0 for ; Sun, 09 Aug 2015 23:32:34 -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=LGZUj0YHzCt12VDlSJ4RuADxE6t7I8XVt62KRIXwRh8=; b=C9BNUeu/pRd128VTW8tDgcZFFnoFw2QigM4VEFZqkTkJvEQmXT1seoOKQXEdI+pFEQ 9HxjdgOB9YfKxbQO3R9bSzM4BEJevL4AsesWYnF2vmYa7TCcy5bFRdk2hosmXpuBWCOp YgFjB2fLXWWJeE/hIlthJ++7UnMIxHE8SjEbbyymBQFxBfwOTIcNm7rljU9SHhoWF83X xksf+X20VBJvOtS3ND8wIV8HyaOuRKmi/PgHjysBO3witMSs1+7QD/U1Hmflx1SsP1zU dUT79eMvQ1y5PwXYayUJc3H64LY39wXtyautJRlNmmtj+JcYjShW8nOykMSLb9QCu55f dMsg== X-Gm-Message-State: ALoCoQmuYA05xzYyrDko4hqzwcHTdEI6hBoCfpDYKZtQeCpO9oCmBQ3K5wd+wmrJtiPfg8Dmu5o5 X-Received: by 10.194.173.3 with SMTP id bg3mr5818378wjc.5.1439188354488; Sun, 09 Aug 2015 23:32:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.103 with SMTP id l7ls692580laf.35.gmail; Sun, 09 Aug 2015 23:32:34 -0700 (PDT) X-Received: by 10.112.148.162 with SMTP id tt2mr2645620lbb.121.1439188354327; Sun, 09 Aug 2015 23:32:34 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id j10si13398475lbv.162.2015.08.09.23.32.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Aug 2015 23:32:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by lahi9 with SMTP id i9so17942986lah.2 for ; Sun, 09 Aug 2015 23:32:34 -0700 (PDT) X-Received: by 10.112.125.34 with SMTP id mn2mr17198304lbb.76.1439188354153; Sun, 09 Aug 2015 23:32:34 -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.112.7.198 with SMTP id l6csp1746429lba; Sun, 9 Aug 2015 23:32:32 -0700 (PDT) X-Received: by 10.66.139.138 with SMTP id qy10mr42120376pab.30.1439188352038; Sun, 09 Aug 2015 23:32:32 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bv3si31532728pbb.63.2015.08.09.23.32.31; Sun, 09 Aug 2015 23:32:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753448AbbHJGca (ORCPT + 12 others); Mon, 10 Aug 2015 02:32:30 -0400 Received: from mail-pd0-f170.google.com ([209.85.192.170]:35252 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752614AbbHJGc3 (ORCPT ); Mon, 10 Aug 2015 02:32:29 -0400 Received: by pdrg1 with SMTP id g1so67956067pdr.2 for ; Sun, 09 Aug 2015 23:32:29 -0700 (PDT) X-Received: by 10.70.132.228 with SMTP id ox4mr41928234pdb.0.1439188349136; Sun, 09 Aug 2015 23:32:29 -0700 (PDT) Received: from localhost ([223.227.137.11]) by smtp.gmail.com with ESMTPSA id kr1sm18466810pbc.93.2015.08.09.23.32.26 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 09 Aug 2015 23:32:28 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , nm@ti.com, sboyd@codeaurora.org Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, khilman@linaro.org, Viresh Kumar , Greg Kroah-Hartman , Len Brown , linux-kernel@vger.kernel.org (open list), Pavel Machek Subject: [PATCH 1/6] PM / OPP: reuse of_parse_phandle() Date: Mon, 10 Aug 2015 12:01:57 +0530 Message-Id: <8c4503fe1c1c545d5f7ac68351d81d0238532b54.1439187821.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.4.0 In-Reply-To: References: 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.215.51 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: , We already have a better API to get the opp descriptor block's node from cpu-node. Lets reuse that instead of creating our own routines for the same stuff. That cleans the code a lot. Signed-off-by: Viresh Kumar --- drivers/base/power/opp.c | 70 +++++++++++++----------------------------------- 1 file changed, 18 insertions(+), 52 deletions(-) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index 204c6c945168..1daaa1a418a2 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -1250,69 +1250,33 @@ void of_cpumask_free_opp_table(cpumask_var_t cpumask) } EXPORT_SYMBOL_GPL(of_cpumask_free_opp_table); -/* Returns opp descriptor node from its phandle. Caller must do of_node_put() */ -static struct device_node * -_of_get_opp_desc_node_from_prop(struct device *dev, const struct property *prop) -{ - struct device_node *opp_np; - - opp_np = of_find_node_by_phandle(be32_to_cpup(prop->value)); - if (!opp_np) { - dev_err(dev, "%s: Prop: %s contains invalid opp desc phandle\n", - __func__, prop->name); - return ERR_PTR(-EINVAL); - } - - return opp_np; -} - -/* Returns opp descriptor node for a device. Caller must do of_node_put() */ +/* Returns opp descriptor node for a device, caller must do of_node_put() */ static struct device_node *_of_get_opp_desc_node(struct device *dev) { - const struct property *prop; - - prop = of_find_property(dev->of_node, "operating-points-v2", NULL); - if (!prop) - return ERR_PTR(-ENODEV); - if (!prop->value) - return ERR_PTR(-ENODATA); - /* * TODO: Support for multiple OPP tables. * * There should be only ONE phandle present in "operating-points-v2" * property. */ - if (prop->length != sizeof(__be32)) { - dev_err(dev, "%s: Invalid opp desc phandle\n", __func__); - return ERR_PTR(-EINVAL); - } - return _of_get_opp_desc_node_from_prop(dev, prop); + return of_parse_phandle(dev->of_node, "operating-points-v2", 0); } /* Initializes OPP tables based on new bindings */ static int _of_init_opp_table_v2(struct device *dev, - const struct property *prop) + struct device_node *opp_np) { - struct device_node *opp_np, *np; + struct device_node *np; struct device_opp *dev_opp; int ret = 0, count = 0; - if (!prop->value) - return -ENODATA; - - /* Get opp node */ - opp_np = _of_get_opp_desc_node_from_prop(dev, prop); - if (IS_ERR(opp_np)) - return PTR_ERR(opp_np); - dev_opp = _managed_opp(opp_np); if (dev_opp) { /* OPPs are already managed */ if (!_add_list_dev(dev, dev_opp)) ret = -ENOMEM; - goto put_opp_np; + goto out; } /* We have opp-list node now, iterate over it and add OPPs */ @@ -1329,13 +1293,13 @@ static int _of_init_opp_table_v2(struct device *dev, /* There should be one of more OPP defined */ if (WARN_ON(!count)) - goto put_opp_np; + goto out; if (!ret) { if (!dev_opp) { dev_opp = _find_device_opp(dev); if (WARN_ON(!dev_opp)) - goto put_opp_np; + goto out; } dev_opp->np = opp_np; @@ -1345,9 +1309,7 @@ static int _of_init_opp_table_v2(struct device *dev, of_free_opp_table(dev); } -put_opp_np: - of_node_put(opp_np); - +out: return ret; } @@ -1413,14 +1375,15 @@ static int _of_init_opp_table_v1(struct device *dev) */ int of_init_opp_table(struct device *dev) { - const struct property *prop; + struct device_node *opp_np; + int ret; /* * OPPs have two version of bindings now. The older one is deprecated, * try for the new binding first. */ - prop = of_find_property(dev->of_node, "operating-points-v2", NULL); - if (!prop) { + opp_np = _of_get_opp_desc_node(dev); + if (!opp_np) { /* * Try old-deprecated bindings for backward compatibility with * older dtbs. @@ -1428,7 +1391,10 @@ int of_init_opp_table(struct device *dev) return _of_init_opp_table_v1(dev); } - return _of_init_opp_table_v2(dev, prop); + ret = _of_init_opp_table_v2(dev, opp_np); + of_node_put(opp_np); + + return ret; } EXPORT_SYMBOL_GPL(of_init_opp_table); @@ -1517,7 +1483,7 @@ int of_get_cpus_sharing_opps(struct device *cpu_dev, cpumask_var_t cpumask) /* Get OPP descriptor node */ np = _of_get_opp_desc_node(cpu_dev); - if (IS_ERR(np)) { + if (!np) { dev_dbg(cpu_dev, "%s: Couldn't find opp node: %ld\n", __func__, PTR_ERR(np)); return -ENOENT; @@ -1541,7 +1507,7 @@ int of_get_cpus_sharing_opps(struct device *cpu_dev, cpumask_var_t cpumask) /* Get OPP descriptor node */ tmp_np = _of_get_opp_desc_node(tcpu_dev); - if (IS_ERR(tmp_np)) { + if (!tmp_np) { dev_err(tcpu_dev, "%s: Couldn't find opp node: %ld\n", __func__, PTR_ERR(tmp_np)); ret = PTR_ERR(tmp_np);