From patchwork Fri Jun 29 06:19:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 140499 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp450810ljj; Thu, 28 Jun 2018 23:20:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ5Jq6IGuAEy13WwOgTodNdH+NL5NmLTaKIIwG3+9RTQyCCthZBfeVe2Ah3o3byQBBR7xp4 X-Received: by 2002:a63:7558:: with SMTP id f24-v6mr11686638pgn.314.1530253209997; Thu, 28 Jun 2018 23:20:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530253209; cv=none; d=google.com; s=arc-20160816; b=rsAzco2Sz1Qf5HLY7QP5B7+alXs3XmfN86q8U7ZX/q+ho0+ZjzsTvIV7Dx/eqveNwp daah49CAwQ4KP5NKmb0kj9tqwIb0RaY751rJYsYpm+kkiWe4y9dvXQjVK0PE06neSts7 BzWwfzYN4lAXDW+/vQK+BiiJenlxJNXXnndy7SX0gmGOpcEOkVLiLlzH4G+UHBWDcH3n C5tvxnHyRSdMeGV/LDXUTnUVzTBp08U6idbOqkxh7Grhxq/Qf7hyXdD00UUC3+8w7bLg Mcov2MeNFQ5l7YWuN4V5EgD63yeuNcMBAXVE+I0bonpyU7t7gMNa0FPQtW3981pWphrO suGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=b7P0x4OPyLm2pT3XAYOXCOfkFYVojybdEOu/Rewxw1o=; b=GeZuFvCJnOVPchBi7pm2FH3V7ji5/7XNgKx/2aoOeB8LKL3nbqRwy+ikyS0AgUdCKg hG2VVi/ybqJoGDEdIe9yV1zyh+fEV830c63n4Xe8rtobCjS6waiCJwRwB4DK0eXefyVf uh+BkmqxDo42OI3QI62xMJPeqn26vxMQloK4kDIhSBl3lpr7TQgIs6RAQ6w/YPlKBMpZ Qn0XNBfIir4k0uYy1Z3d6q84YlcNvCYycASKiSv/Nv+6ZgDi6E5MQjP139Bi3iRjg9Cv aGS7QtQnPVT/0+8s4RGKjy5tkoStjE2z5h0cjEVhV7xrSogjM2N393w5P+SB1QrPtsvF i7QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ce8hkccx; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f35-v6si8318665plh.193.2018.06.28.23.20.09; Thu, 28 Jun 2018 23:20:09 -0700 (PDT) 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 header.s=google header.b=ce8hkccx; 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 S1754572AbeF2GUH (ORCPT + 31 others); Fri, 29 Jun 2018 02:20:07 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:36694 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754309AbeF2GUF (ORCPT ); Fri, 29 Jun 2018 02:20:05 -0400 Received: by mail-pg0-f65.google.com with SMTP id m19-v6so6452pgv.3 for ; Thu, 28 Jun 2018 23:20:05 -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; bh=b7P0x4OPyLm2pT3XAYOXCOfkFYVojybdEOu/Rewxw1o=; b=ce8hkccx/nIS0ZS90LwxVOBNjolNhOA05dHPgxThIzEHOBiW3Z3b9ii11t2m2Rqyq/ wq1QWsKE1uJbXbi5LNfH/jAHF2/NM9imAvtMgvej3PQOAhveciiIoxpF5dXshpa4cndY mObrjyJmc3dTH7dROZqnrZWrN2Fyb/n58l/yQ= 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; bh=b7P0x4OPyLm2pT3XAYOXCOfkFYVojybdEOu/Rewxw1o=; b=K/7dqebYCAgy07HzTnfPU8KMroWr5JerSVS97WiCVhcOj3r4Pus9cvaBHmKmdM5HLh 3D91jZfxQ/vBiayW+oPk955cMAgW9y/Ray48mawjjcFZrrB5mHe+96J4y/JFZ4XqauxL thNh7SIRgR9ej0tM8fhZhH6WPEXnmDbPUCeC2XEZ/M5sDeb4zhs79gQReGcJ/vY/uNc3 +XWZ/It4DoM3hoHT3zQPz7jU6e9EBOh3bai2HYJ0hOUNylfSIxKTOWRmZ1+0C2VTY00u lU90Cc3wOW43T+dNV22sAcUA/nsMP1Wp3oHf+05no42wrIqGNWCbu/N0ZIbGgcZm18T5 2b9A== X-Gm-Message-State: APt69E0cpbG8iX1VAXeKHMDVDp2PMXnUB0nLOqp8cerQxPArqb7uDj1h mRSvERLKA5YfBenifL+cH4X/LiMPo6w= X-Received: by 2002:aa7:808f:: with SMTP id v15-v6mr13221389pff.38.1530253204809; Thu, 28 Jun 2018 23:20:04 -0700 (PDT) Received: from localhost ([122.172.117.17]) by smtp.gmail.com with ESMTPSA id m7-v6sm13232046pgr.5.2018.06.28.23.20.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 23:20:04 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , ulf.hansson@linaro.org, Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rajendra Nayak , linux-kernel@vger.kernel.org Subject: [PATCH 03/10] OPP: Separate out custom OPP handler specific code Date: Fri, 29 Jun 2018 11:49:33 +0530 Message-Id: <152adbb18a6d7129327a0f320cf8c60e5434dead.1530252803.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.18.0.rc1.242.g61856ae69a2c In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Create a separate routine to take care of custom set_opp() handler specific stuff. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 67 +++++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 27 deletions(-) -- 2.18.0.rc1.242.g61856ae69a2c diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 31ff03dbeb83..c0c657fdbf33 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -630,6 +630,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 @@ -644,7 +672,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__, @@ -697,8 +725,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. @@ -709,30 +746,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);