From patchwork Tue Dec 6 09:16:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 86721 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1917175qgi; Tue, 6 Dec 2016 01:17:07 -0800 (PST) X-Received: by 10.84.136.75 with SMTP id 69mr132150113plk.52.1481015827490; Tue, 06 Dec 2016 01:17:07 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2si18669902pgb.135.2016.12.06.01.17.07; Tue, 06 Dec 2016 01:17:07 -0800 (PST) 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; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752308AbcLFJRG (ORCPT + 13 others); Tue, 6 Dec 2016 04:17:06 -0500 Received: from mail-pg0-f42.google.com ([74.125.83.42]:35927 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752524AbcLFJQv (ORCPT ); Tue, 6 Dec 2016 04:16:51 -0500 Received: by mail-pg0-f42.google.com with SMTP id f188so146920294pgc.3 for ; Tue, 06 Dec 2016 01:16:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=Okz6dWWipQvoDp/360/1GKEGrdH0iweJ+JfrDvPc508=; b=QKMGXCA1eACLYzYEJtd3WNw66lEF+6cAgBg9cVpU9vk6pjXjc6S5lTYhQudq3hVw/q 3A3P3cwONF8sjmP6PS0PIhG177EzFT0C2X0jMhI6mCBtHjNl1QbnkaHF0ujctuLj+TdK BJvNAXfx6Ao+2Z/zQ9vHlx77qzlA3FhNY4lzk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=Okz6dWWipQvoDp/360/1GKEGrdH0iweJ+JfrDvPc508=; b=hvR/PCXaie4HWpEiXVC15lw1EEQwzb2mdzCHxRHutREp3hoz2Q1tDU+ScHiTughsuP 8KTpkmM6bU97IY+EyILrC0TKuXlF4EjXsBQgOc8Hd/l/D3be8V7DYH6+7mYoJv1D1VQ6 cpXDlC0gLyMvrURq9Kyu8ueJjNcJcyEnV6F1Ld9DgPTCUR0yTR1RIK6HlhDlHNfWayQw ZpFc2VMb690rd5IGR5NGNVlA/2esNBZMdASSat3VkyyGVMGR88GPmUm1+x4B0DHpoqx9 rY/6Xs2cxjfFcPZgODlaeGSFK+73twARNMSj3OzZkVTYGHiR0wYyzAYbRij2EcAt8jDE 6ltg== X-Gm-Message-State: AKaTC03rS9KZK5LMNQuYtJ9d9JR5SzXEwzi3Mc1kGAWYB8MNPFMG8U9DRYTSwUe1vb7oMZJa X-Received: by 10.84.198.129 with SMTP id p1mr50528594pld.14.1481015806837; Tue, 06 Dec 2016 01:16:46 -0800 (PST) Received: from localhost ([122.172.43.83]) by smtp.gmail.com with ESMTPSA id d197sm33137420pfd.38.2016.12.06.01.16.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Dec 2016 01:16:46 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Vincent Guittot , Viresh Kumar Subject: [PATCH 10/10] PM / OPP: Split out part of _add_opp_table() and _remove_opp_table() Date: Tue, 6 Dec 2016 14:46:02 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Split out parts of _add_opp_table() and _remove_opp_table() into separate routines. This will be useful going forward (while doing further cleanups). Should result in no functional changes. Signed-off-by: Viresh Kumar --- drivers/base/power/opp/core.c | 76 +++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 32 deletions(-) -- 2.7.1.410.g6faf27b -- 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 Reviewed-by: Stephen Boyd diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index f4b935892f5b..9dd9d3287854 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -832,26 +832,12 @@ struct opp_device *_add_opp_dev(const struct device *dev, return opp_dev; } -/** - * _add_opp_table() - Find OPP table or allocate a new one - * @dev: device for which we do this operation - * - * It tries to find an existing table first, if it couldn't find one, it - * allocates a new OPP table and returns that. - * - * Return: valid opp_table pointer if success, else NULL. - */ -struct opp_table *_add_opp_table(struct device *dev) +static struct opp_table *_allocate_opp_table(struct device *dev) { struct opp_table *opp_table; struct opp_device *opp_dev; int ret; - /* Check for existing table for 'dev' first */ - opp_table = _find_opp_table(dev); - if (!IS_ERR(opp_table)) - return opp_table; - /* * Allocate a new OPP table. In the infrequent case where a new * device is needed to be added, we pay this penalty. @@ -888,6 +874,27 @@ struct opp_table *_add_opp_table(struct device *dev) } /** + * _add_opp_table() - Find OPP table or allocate a new one + * @dev: device for which we do this operation + * + * It tries to find an existing table first, if it couldn't find one, it + * allocates a new OPP table and returns that. + * + * Return: valid opp_table pointer if success, else NULL. + */ +struct opp_table *_add_opp_table(struct device *dev) +{ + struct opp_table *opp_table; + + /* Check for existing table for 'dev' first */ + opp_table = _find_opp_table(dev); + if (!IS_ERR(opp_table)) + return opp_table; + + return _allocate_opp_table(dev); +} + +/** * _kfree_device_rcu() - Free opp_table RCU handler * @head: RCU head */ @@ -899,6 +906,27 @@ static void _kfree_device_rcu(struct rcu_head *head) kfree_rcu(opp_table, rcu_head); } +static void _free_opp_table(struct opp_table *opp_table) +{ + struct opp_device *opp_dev; + + /* Release clk */ + if (!IS_ERR(opp_table->clk)) + clk_put(opp_table->clk); + + opp_dev = list_first_entry(&opp_table->dev_list, struct opp_device, + node); + + _remove_opp_dev(opp_dev, opp_table); + + /* dev_list must be empty now */ + WARN_ON(!list_empty(&opp_table->dev_list)); + + list_del_rcu(&opp_table->node); + call_srcu(&opp_table->srcu_head.srcu, &opp_table->rcu_head, + _kfree_device_rcu); +} + /** * _remove_opp_table() - Removes a OPP table * @opp_table: OPP table to be removed. @@ -907,8 +935,6 @@ static void _kfree_device_rcu(struct rcu_head *head) */ static void _remove_opp_table(struct opp_table *opp_table) { - struct opp_device *opp_dev; - if (!list_empty(&opp_table->opp_list)) return; @@ -924,21 +950,7 @@ static void _remove_opp_table(struct opp_table *opp_table) if (opp_table->set_opp) return; - /* Release clk */ - if (!IS_ERR(opp_table->clk)) - clk_put(opp_table->clk); - - opp_dev = list_first_entry(&opp_table->dev_list, struct opp_device, - node); - - _remove_opp_dev(opp_dev, opp_table); - - /* dev_list must be empty now */ - WARN_ON(!list_empty(&opp_table->dev_list)); - - list_del_rcu(&opp_table->node); - call_srcu(&opp_table->srcu_head.srcu, &opp_table->rcu_head, - _kfree_device_rcu); + _free_opp_table(opp_table); } void _opp_free(struct dev_pm_opp *opp)