From patchwork Thu Oct 25 05:52:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 149514 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp913520ljp; Wed, 24 Oct 2018 22:53:29 -0700 (PDT) X-Google-Smtp-Source: AJdET5fsWLf+i6QnkqJD3EpNz3MXc+xOekB5H3rmhThz4YNoJIMWJhFYrKCQQHSkfhNf56veUTgq X-Received: by 2002:a17:902:aa45:: with SMTP id c5-v6mr215963plr.100.1540446809129; Wed, 24 Oct 2018 22:53:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540446809; cv=none; d=google.com; s=arc-20160816; b=oDHVrwHPc8ngqIq0rizvYxj0l8aEDaV7hSJLx6ob8Tj13+UQbmyfdBQIm6rLf+msey 7NTMD0pP5dDCyjOVRssdp/3Z8Qrz2gVpg53Dys0TI0cd2gw+poPn+viz3sqyYaeyalor i5MhQyvpyTzdCXf6Q+i7DdJbigNp0zsuTH0Yx8c0rh+WDVBdnb+nKpajmNuM1i6y/TAt LZWLmc4BzbZa05kVxQpNm8spbxxLUNvcpVgOtwBGSl+6rFfsIUtfoaXqwSQ0OrSqI5IX t70gpbUVZ/oIYBN/ec9w2CDMV6b4vd1Y5uBruVRphiEc1uh/CExDTag11qgIyYcde4FM M7ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v6vTXca6A3jKCvhjLn/Zkg1XwrbNhbzSf4hVfEVdJtU=; b=mq9M5MFxvAVaC1y6SXIwqZX3mUBwb+sN98yJrChYO+GQjj9WSxYR/S1Bna++LTdMML 1LtaqB7ka6djwyK9L6qAS+EIW0trENxliU20bNZ6wJstDrYvrmfYQO3PPl69dd+q/82v y1ypKDbVRhr1vvm37R2PdQoAdUzwjs65K895yD5kU1FCgkddAbvDJdY4szhohfbuvwZ4 dgmErHMmDMHuc1Ps+m5qy+Z6mXSUlVvW7B0OAleLAIb0LKPE93GcFXAvJb8s9Gjs9NpS 5YsjsVkfbeeYixjij9ep+KELvNjt67izE+8yLKh88SgOfpIFpR51H7cejSlfaIXjUwuX SA8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hUXeVMx2; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e11-v6si4692177pff.272.2018.10.24.22.53.28; Wed, 24 Oct 2018 22:53:29 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hUXeVMx2; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727436AbeJYOYg (ORCPT + 11 others); Thu, 25 Oct 2018 10:24:36 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:44192 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727350AbeJYOYg (ORCPT ); Thu, 25 Oct 2018 10:24:36 -0400 Received: by mail-pg1-f194.google.com with SMTP id w3-v6so3472776pgs.11 for ; Wed, 24 Oct 2018 22:53:26 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=v6vTXca6A3jKCvhjLn/Zkg1XwrbNhbzSf4hVfEVdJtU=; b=hUXeVMx2vJv4cDWT3aDqmKMh8MrnV1gvyYapkFPqtEb8Pip/4mZFIbSVilElNRNIp6 tp4qNVM1kQMIIShXmui4NV4yxUcpCllUnLAhy8J+h5rgIoavfKoT73/wVVY0wDDt05+u XKVhwjFGgfPcUKXSI5cz5s879uMPHZ7kTA5uc= 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:mime-version:content-transfer-encoding; bh=v6vTXca6A3jKCvhjLn/Zkg1XwrbNhbzSf4hVfEVdJtU=; b=LIgpA1RgiHEhaSfsxcpfKY756lx0qIdEo3Dar0TuJ0U2ylfFPhBSDx6Ljb8J0QIaEE w0aVg8PYNjCUMXiLpS8pTgzPsP1HzeqrCwnlxE1XZGkxCuWn7Q9+XWF8XA6QB84bSe/n LWcw7NVe7LvOMiGQTX124cWD+1HJIwy3XhLWl0bP+qPRuAu6gESqZU9T995kAlS+75ix /wG8T3JO1jMftb1DZ7mJOnEYAt3mXmfrdy9v5MS9A2NHXasKwopt7dR1UlCkndny/aMd 8HT8UNpCPAWhmL4Lc4Iwxj6PnovEK/aWpxiZr89kRDLb4+rveyVaqKL4KkW5LD7RNlp8 4AIg== X-Gm-Message-State: AGRZ1gJp3wkGf4OdxPZgM9QIoQ/C642VeXK6qC6u7jzoSP63PZiqfKVv iChsz0H+cZr2yaYC9HPMVedkcQ== X-Received: by 2002:a62:9015:: with SMTP id a21-v6mr203519pfe.49.1540446805510; Wed, 24 Oct 2018 22:53:25 -0700 (PDT) Received: from localhost ([122.172.217.9]) by smtp.gmail.com with ESMTPSA id z14-v6sm8826137pfi.4.2018.10.24.22.53.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Oct 2018 22:53:24 -0700 (PDT) From: Viresh Kumar To: ulf.hansson@linaro.org, Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , niklas.cassel@linaro.org, rnayak@codeaurora.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 03/10] OPP: Separate out custom OPP handler specific code Date: Thu, 25 Oct 2018 11:22:40 +0530 Message-Id: <2b94b3d1454a5e5da9e1a984a1a87cc852b44213.1540446493.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.19.1.568.g152ad8e3369a In-Reply-To: References: MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Create a separate routine to take care of custom set_opp() handler specific stuff. Reviewed-by: Ulf Hansson Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 67 +++++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 27 deletions(-) -- 2.19.1.568.g152ad8e3369a diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 2c2df4e4fc14..ebb3b648e0fd 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -635,6 +635,34 @@ static int _generic_set_opp_regulator(const struct opp_table *opp_table, return ret; } +static int _set_opp_custom(const struct opp_table *opp_table, + struct device *dev, unsigned long old_freq, + unsigned long freq, + struct dev_pm_opp_supply *old_supply, + struct dev_pm_opp_supply *new_supply) +{ + struct dev_pm_set_opp_data *data; + int size; + + data = opp_table->set_opp_data; + data->regulators = opp_table->regulators; + data->regulator_count = opp_table->regulator_count; + data->clk = opp_table->clk; + data->dev = dev; + + data->old_opp.rate = old_freq; + size = sizeof(*old_supply) * opp_table->regulator_count; + if (IS_ERR(old_supply)) + memset(data->old_opp.supplies, 0, size); + else + memcpy(data->old_opp.supplies, old_supply, size); + + data->new_opp.rate = freq; + memcpy(data->new_opp.supplies, new_supply, size); + + return opp_table->set_opp(data); +} + /** * dev_pm_opp_set_rate() - Configure new OPP based on frequency * @dev: device for which we do this operation @@ -649,7 +677,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) unsigned long freq, old_freq; struct dev_pm_opp *old_opp, *opp; struct clk *clk; - int ret, size; + int ret; if (unlikely(!target_freq)) { dev_err(dev, "%s: Invalid target frequency %lu\n", __func__, @@ -702,8 +730,17 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) dev_dbg(dev, "%s: switching OPP: %lu Hz --> %lu Hz\n", __func__, old_freq, freq); - /* Only frequency scaling */ - if (!opp_table->regulators) { + if (opp_table->set_opp) { + ret = _set_opp_custom(opp_table, dev, old_freq, freq, + IS_ERR(old_opp) ? NULL : old_opp->supplies, + opp->supplies); + } else if (opp_table->regulators) { + ret = _generic_set_opp_regulator(opp_table, dev, old_freq, freq, + IS_ERR(old_opp) ? NULL : old_opp->supplies, + opp->supplies); + } else { + /* Only frequency scaling */ + /* * We don't support devices with both regulator and * domain performance-state for now. @@ -714,30 +751,6 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) opp->pstate); else ret = _generic_set_opp_clk_only(dev, clk, old_freq, freq); - } else if (!opp_table->set_opp) { - ret = _generic_set_opp_regulator(opp_table, dev, old_freq, freq, - IS_ERR(old_opp) ? NULL : old_opp->supplies, - opp->supplies); - } else { - struct dev_pm_set_opp_data *data; - - data = opp_table->set_opp_data; - data->regulators = opp_table->regulators; - data->regulator_count = opp_table->regulator_count; - data->clk = clk; - data->dev = dev; - - data->old_opp.rate = old_freq; - size = sizeof(*opp->supplies) * opp_table->regulator_count; - if (IS_ERR(old_opp)) - memset(data->old_opp.supplies, 0, size); - else - memcpy(data->old_opp.supplies, old_opp->supplies, size); - - data->new_opp.rate = freq; - memcpy(data->new_opp.supplies, opp->supplies, size); - - ret = opp_table->set_opp(data); } dev_pm_opp_put(opp);