From patchwork Mon Jan 23 04:41:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 92187 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1055255obz; Sun, 22 Jan 2017 20:42:48 -0800 (PST) X-Received: by 10.98.204.216 with SMTP id j85mr30244854pfk.130.1485146568194; Sun, 22 Jan 2017 20:42:48 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j19si4002740pgk.229.2017.01.22.20.42.47; Sun, 22 Jan 2017 20:42:48 -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 sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751122AbdAWEmn (ORCPT + 13 others); Sun, 22 Jan 2017 23:42:43 -0500 Received: from mail-pg0-f42.google.com ([74.125.83.42]:36542 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750744AbdAWEmk (ORCPT ); Sun, 22 Jan 2017 23:42:40 -0500 Received: by mail-pg0-f42.google.com with SMTP id t6so41351610pgt.3 for ; Sun, 22 Jan 2017 20:42:40 -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=DDxcb1sdFJe8Oy+KSfINuTEbeumjtfjm+fiqrt3isQY=; b=PqcNGhu3S1rO/Tp/Q49bn5OKOKcgI/D/tqjZp0v7R7FRRQL614HjsMJzZfOdFIDyQ3 y4xX4OtYLmxfiVfi0WwRf4MR4xDPn5MrusgS+yE84PbmEZdc2ufEMbz6kJiKsbv/VbW0 49anZvbaDTdbY29aRgJc7qY1knvsBohxcgguE= 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=DDxcb1sdFJe8Oy+KSfINuTEbeumjtfjm+fiqrt3isQY=; b=UXdHn9fiOCmHErqkL7nqivfafP4RdE8pxrSTBLmADEcDkOdHuTewkgJVLQgGRYAdPV 36OqvMsbMB3oWODpfTtskQ2qcP2FajjtcMTbA0okAgQVsMcs+HnWkC4fwsvwU+a8qFHr znNKPs6utxk/7f8i76j/499yGFpwBFGJIvprCEjvfyuQN9rZ+I2XNDE3a+tr0Egt4Qth g8lSvUPew6N2d6QCXm4PBtvd5UUY9LxUrvx6QFdd/uQVgz4XboQMsOlKZ17+H/pp2zGc 34QP9d14qUCrNJjIqw5BRWvJzFgYkhI048yScbXw903k1k6AYhe7u5SjloQACZcS1meM 6hFg== X-Gm-Message-State: AIkVDXJLIZ+35f0a0jOfN1u40Y142bn1v1qInadBZO7vSMWTqbkdq9DUT89b7lSG5KUZj9ch X-Received: by 10.84.128.66 with SMTP id 60mr40774671pla.34.1485146560116; Sun, 22 Jan 2017 20:42:40 -0800 (PST) Received: from localhost ([122.171.65.82]) by smtp.gmail.com with ESMTPSA id b7sm2684110pfg.53.2017.01.22.20.42.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jan 2017 20:42:39 -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 11/12] PM / OPP: Simplify dev_pm_opp_get_max_volt_latency() Date: Mon, 23 Jan 2017 10:11:51 +0530 Message-Id: <36bd3a626e3949ed693fe267d27639403def66cd.1485146406.git.viresh.kumar@linaro.org> 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 dev_pm_opp_get_max_volt_latency() calls _find_opp_table() two times effectively. Merge _get_regulator_count() into dev_pm_opp_get_max_volt_latency() to avoid that. Signed-off-by: Viresh Kumar Reviewed-by: Stephen Boyd --- drivers/base/power/opp/core.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 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 diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index f54ac2484723..541d32c00cbc 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -170,22 +170,6 @@ unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev) } EXPORT_SYMBOL_GPL(dev_pm_opp_get_max_clock_latency); -static int _get_regulator_count(struct device *dev) -{ - struct opp_table *opp_table; - int count; - - opp_table = _find_opp_table(dev); - if (IS_ERR(opp_table)) - return 0; - - count = opp_table->regulator_count; - - dev_pm_opp_put_opp_table(opp_table); - - return count; -} - /** * dev_pm_opp_get_max_volt_latency() - Get max voltage latency in nanoseconds * @dev: device for which we do this operation @@ -204,24 +188,24 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev) unsigned long max; } *uV; - count = _get_regulator_count(dev); + opp_table = _find_opp_table(dev); + if (IS_ERR(opp_table)) + return 0; + + count = opp_table->regulator_count; /* Regulator may not be required for the device */ if (!count) - return 0; + goto put_opp_table; regulators = kmalloc_array(count, sizeof(*regulators), GFP_KERNEL); if (!regulators) - return 0; + goto put_opp_table; uV = kmalloc_array(count, sizeof(*uV), GFP_KERNEL); if (!uV) goto free_regulators; - opp_table = _find_opp_table(dev); - if (IS_ERR(opp_table)) - goto free_uV; - memcpy(regulators, opp_table->regulators, count * sizeof(*regulators)); mutex_lock(&opp_table->lock); @@ -242,7 +226,6 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev) } mutex_unlock(&opp_table->lock); - dev_pm_opp_put_opp_table(opp_table); /* * The caller needs to ensure that opp_table (and hence the regulator) @@ -254,10 +237,11 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev) latency_ns += ret * 1000; } -free_uV: kfree(uV); free_regulators: kfree(regulators); +put_opp_table: + dev_pm_opp_put_opp_table(opp_table); return latency_ns; }