From patchwork Mon Jan 23 04:41:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 92182 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1055216obz; Sun, 22 Jan 2017 20:42:38 -0800 (PST) X-Received: by 10.99.215.5 with SMTP id d5mr29938977pgg.51.1485146558464; Sun, 22 Jan 2017 20:42:38 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s185si14404172pgc.259.2017.01.22.20.42.38; Sun, 22 Jan 2017 20:42:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751002AbdAWEmX (ORCPT + 25 others); Sun, 22 Jan 2017 23:42:23 -0500 Received: from mail-pg0-f54.google.com ([74.125.83.54]:32978 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750931AbdAWEmT (ORCPT ); Sun, 22 Jan 2017 23:42:19 -0500 Received: by mail-pg0-f54.google.com with SMTP id 204so41435764pge.0 for ; Sun, 22 Jan 2017 20:42:14 -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=AWD/biikQU3mOfuRdTGa1XS5V9QuQKzAE0SJ6VBWgNY=; b=DRigarICO7q/mN+QIuZrH6e1hkvV+pNIWKc8oUm/03jPcgti70uiLXtes3C82s/1No pV2WrWDJSrGiWqwWFQ4agip2I1NLqjP6ukDk16mAdggIKcqbJtWGAx2ZsSNNGNo8nm7C /JWWdlcEIE8YTewahtEhL0AqB5PWL5CtlaC3I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=AWD/biikQU3mOfuRdTGa1XS5V9QuQKzAE0SJ6VBWgNY=; b=WIw9fhGnLXWv6bizrQXcD7k4+u30I0ns161qZI7AldqggwuXdetZq+aQubKuPfGzZB RHTMSIolPeyltC3GVWupCkCMlCo6ZuRhfu3HkovavNIN1D8o8lkude/RCrb3t4MotKza Nl9duLd1UX48RewPokD8G0MUdOLm3TpdN3T0ODLBy/Qgea1Iuhn/+RLaiWLotIKklcgo wSMFo84aR/gr24kB6FWXUINoGxMmsN6dtYrSQBXjZe1xZ0+60rR3c/c45n+yQfv0CSiT pwHI3PJspjBKOiHIBm9Vn5C+SEZE9s+aQetz44QIyKvWMoNFXlxpYsZXZ0HqhQQOYbiH KmMA== X-Gm-Message-State: AIkVDXLIVMVaUunBW8c4WGKAfZbrBtzabYbS2z6rg05HmZ3Orp1JlYPV4Y+kAo66X/M4oeCy X-Received: by 10.99.153.26 with SMTP id d26mr30859805pge.44.1485146533836; Sun, 22 Jan 2017 20:42:13 -0800 (PST) Received: from localhost ([122.171.65.82]) by smtp.gmail.com with ESMTPSA id w76sm32635311pfd.74.2017.01.22.20.42.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jan 2017 20:42:13 -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, linux-kernel@vger.kernel.org, Vincent Guittot , Viresh Kumar Subject: [PATCH V2 04/12] PM / OPP: Take reference of the OPP table while adding/removing OPPs Date: Mon, 23 Jan 2017 10:11:44 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Take reference of the OPP table while adding and removing OPPs, that helps us remove special checks in _remove_opp_table(). Signed-off-by: Viresh Kumar Reviewed-by: Stephen Boyd --- drivers/base/power/opp/core.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 1af349ab630e..1a38b5d8dc54 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -971,9 +971,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_put_opp_table); */ static void _remove_opp_table(struct opp_table *opp_table) { - if (!list_empty(&opp_table->opp_list)) - return; - dev_pm_opp_put_opp_table_unlocked(opp_table); } @@ -1018,8 +1015,7 @@ static void _opp_remove(struct opp_table *opp_table, struct dev_pm_opp *opp) call_srcu(&opp_table->srcu_head.srcu, &opp->rcu_head, _kfree_opp_rcu); mutex_unlock(&opp_table->lock); - - _remove_opp_table(opp_table); + dev_pm_opp_put_opp_table(opp_table); } /** @@ -1170,6 +1166,9 @@ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, new_opp->opp_table = opp_table; + /* Get a reference to the OPP table */ + _get_opp_table_kref(opp_table); + ret = opp_debug_create_one(new_opp, opp_table); if (ret) dev_err(dev, "%s: Failed to register opp to debugfs (%d)\n",