From patchwork Tue Aug 11 06:42:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 52282 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 297352152A for ; Tue, 11 Aug 2015 06:42:58 +0000 (UTC) Received: by lbsm2 with SMTP id m2sf32805340lbs.1 for ; Mon, 10 Aug 2015 23:42:57 -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:date:from:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :in-reply-to:user-agent:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=6VBZxcsQWqwTJceoyFGCY252KDWLAjGf1mfttJrdp/Y=; b=CoHRTEgO1PPQNWb0S0ArWl6xaOUEg5NJ9bBrEcP7vDsM4GAsNtwMF5SMa5SsX9y6JZ yY1LSP8Spv+lg9eziq53i8ZCQ5GRFeLG8U2pu2a7DY9ctADH7Sm9gVsCYfKnpcYIq9hf 11YjhgIJMaM//Tkjq1ISnRvlhYV3snFQiFIr+fG4+Ing8ptAxidHsJXdkPVt0nsVPy/v hdp+sj877A+9P/jAFe91NK6Glv01A5R6imnoUWfKYptlShmf85H5ywQQGb6IJBpGLjrx XQC3AkPodYCDuUy8h3LvoTRlX81HElQDf5to0MTmF78Pb7pEKZ2T0po5hn4QkgtHnWhj 0ntg== X-Gm-Message-State: ALoCoQldkZeqM2J1bsUJaUv5c6V1QvFSu6TwcnkbcrM5+u9+L1zoHFt21odxKRKGdRtzd2W8T51B X-Received: by 10.152.6.103 with SMTP id z7mr7487430laz.8.1439275377030; Mon, 10 Aug 2015 23:42:57 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.201 with SMTP id s9ls413104laj.40.gmail; Mon, 10 Aug 2015 23:42:56 -0700 (PDT) X-Received: by 10.152.179.170 with SMTP id dh10mr7250229lac.22.1439275376881; Mon, 10 Aug 2015 23:42:56 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id b9si601209lbc.161.2015.08.10.23.42.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Aug 2015 23:42:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbcbn3 with SMTP id bn3so13041155lbc.2 for ; Mon, 10 Aug 2015 23:42:56 -0700 (PDT) X-Received: by 10.112.166.2 with SMTP id zc2mr24439975lbb.29.1439275376692; Mon, 10 Aug 2015 23:42:56 -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 l6csp2324444lba; Mon, 10 Aug 2015 23:42:55 -0700 (PDT) X-Received: by 10.68.143.40 with SMTP id sb8mr52310766pbb.21.1439275374645; Mon, 10 Aug 2015 23:42:54 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ks1si1705492pbc.41.2015.08.10.23.42.53; Mon, 10 Aug 2015 23:42:54 -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 S1755121AbbHKGmw (ORCPT + 12 others); Tue, 11 Aug 2015 02:42:52 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:35975 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754979AbbHKGmv (ORCPT ); Tue, 11 Aug 2015 02:42:51 -0400 Received: by pacrr5 with SMTP id rr5so120874941pac.3 for ; Mon, 10 Aug 2015 23:42:51 -0700 (PDT) X-Received: by 10.66.139.234 with SMTP id rb10mr53379964pab.118.1439275370916; Mon, 10 Aug 2015 23:42:50 -0700 (PDT) Received: from localhost ([223.227.191.36]) by smtp.gmail.com with ESMTPSA id gs2sm1204802pbc.15.2015.08.10.23.42.47 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 10 Aug 2015 23:42:50 -0700 (PDT) Date: Tue, 11 Aug 2015 12:12:43 +0530 From: Viresh Kumar To: Stephen Boyd Cc: Rafael Wysocki , nm@ti.com, linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, khilman@linaro.org, Greg Kroah-Hartman , Len Brown , open list , Pavel Machek Subject: Re: [PATCH 1/6] PM / OPP: reuse of_parse_phandle() Message-ID: <20150811064243.GD5147@linux> References: <8c4503fe1c1c545d5f7ac68351d81d0238532b54.1439187821.git.viresh.kumar@linaro.org> <20150811060229.GG9678@codeaurora.org> <20150811061044.GA5147@linux> <20150811062353.GA31523@codeaurora.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150811062353.GA31523@codeaurora.org> User-Agent: Mutt/1.5.21 (2010-09-15) 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.217.182 as permitted sender) smtp.mailfrom=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: , On 10-08-15, 23:23, Stephen Boyd wrote: > Ok. That's worth a mention in the commit text please. -----------------------8<------------------------ Message-Id: <8c4503fe1c1c545d5f7ac68351d81d0238532b54.1439275133.git.viresh.kumar@linaro.org> From: Viresh Kumar Date: Thu, 30 Jul 2015 16:58:19 +0530 Subject: [PATCH] PM / OPP: reuse of_parse_phandle() 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. This also kills a check we had earlier (as we are using the generic API now). Earlier we used to check if the operating-points-v2 property contained multiple phandles instead of a single phandle. Killing this check isn't an issue because, we only parse the first entry with of_parse_phandle(). So, if a user passes multiple phandles, its really his problem :) Signed-off-by: Viresh Kumar --- drivers/base/power/opp.c | 70 +++++++++++++----------------------------------- 1 file changed, 18 insertions(+), 52 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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);