From patchwork Thu Aug 20 07:56:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 248006 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp1135961ils; Thu, 20 Aug 2020 00:56:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUkPXJU3NpayitzTGqWAjq58uHeVHHKkVCgDxqkQbvqLtsCsPYXy1dJTUWM5EJXGLyWXkv X-Received: by 2002:a05:6402:1758:: with SMTP id v24mr1749728edx.274.1597910216563; Thu, 20 Aug 2020 00:56:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597910216; cv=none; d=google.com; s=arc-20160816; b=ivo77eM3dsCGnq2+j4MavXrbpPVMmNBDAKSHiHzjXOhceLSZqQTy3/p+WppvZzTnoS IHxFXJfO4M2Pazav9ZK2xOjVrElW0g3M0TAHzecTNUZ2kHtITQVvEBRrZkAIaU+AfSJu N3pGibiyTy/BlXCkXlYlh+dsqc7gJRbCx5YDezuTM8uKJUspTCWgngCpZOR0uJgTK3Lp e8/UuqGNeT/lWiqNAQUPzy7JMHadSa9JrqAJIVEhDKEuum28tfBU9ZL+28l9wVT5Ts3W 6qOIus6w/azW1I/O5ZrL/soJOLMkU766tbUE14+D1ctTxQttNMJVPKtKMkX/3FxpPRls 6q9A== 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=iqN+JRqBcM9sNS/bUUY7pxB30ldKatY72VtpGF2V5es=; b=bGjrH8Pb/1McO9Pb0tii7OJelpCPN7ZapZGU81PuZAUwA/IIP61wxgF9FD7BAqCEp1 dXGfVsuXBv4vFFYkt/knk6Gkqxx8ihKKgjSFgzwpMR+jfQVW9J9QjpxsJNb9GoAjUzpI ydUIlIbY450+h7R5JZXcTZjmA0YpBw519aXDZex5Iictgf8o6vdI/1Fnl4BLJ7kKRShA Qymt45qMh7cgSAae05FDLyPSXCc6eyuOT6h8j3iJD0wQ6dpJhA5MDRzgaZ/EDr0cc9jL lMM4y7YGVkxnu3JEBToP6UWXk/spkV0HVhkKTJKPcLMS7uDXXrYFbEooNG6bP8PCkpFa D8xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mf3rBwfB; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id cq3si924375edb.474.2020.08.20.00.56.56; Thu, 20 Aug 2020 00:56:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mf3rBwfB; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 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 S1726973AbgHTH4w (ORCPT + 10 others); Thu, 20 Aug 2020 03:56:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726965AbgHTH4u (ORCPT ); Thu, 20 Aug 2020 03:56:50 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D12B9C061383 for ; Thu, 20 Aug 2020 00:56:49 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id 74so609089pfx.13 for ; Thu, 20 Aug 2020 00:56:49 -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=iqN+JRqBcM9sNS/bUUY7pxB30ldKatY72VtpGF2V5es=; b=mf3rBwfBi0yKumSxP8KE3wv22MrRq2xvrN50piShKy6hP8xLXV3o5c16JSMPtHIuy9 +HGYFuxUtPOQIAee5skPIxdRSp80RPp98Qx6YwSDRviMIhgkE82sV9+XsVzIUBMIGU2e lkZcKh7JmQg9xjbLnH9GRK+c0hnXZDbtIKuTMOZ3W57PY29jgpHVO/nMynDjGZGJIrHE K+YfMWeOJij4utbSUAv5OX9S+m1BpIwcShog7ZvylOCusbSalofndd2qgQ4SeOiXiyMG OuXv/60JgKFcucPFV41z8wupsn3Qp0MuPSHYvbPdYjVV6ld3eHhT9ofkMZeqrFjVqJ5z J7tg== 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=iqN+JRqBcM9sNS/bUUY7pxB30ldKatY72VtpGF2V5es=; b=TwT9afCWubtUZrvMEeyOVXi4M4bWuS9YMJLz7yyUdrrEZzqiWrzokInIyJabW1Hk48 TnAU2DJvobnQm8zM7MY8VYCVWWJX0N4HZ5IAYkyzMjFlh8QnJhn5B1rqzIxElCMkvVnp jgKN5yJIpuXh6crJeq1dmsaTNTmicCIoMzezVEK/WEHCRgXNVmxGdSbrPsQpEbdQ31D+ 6FUjKGKvtyqF6+mqoeh1MZU3ab3flxQnDDu/h+iUauS368z8xFIWpJ8ss4yKrRePNTew 3vUhIyJ3rLlm+TjxLCIEfY3kOBUXyW5F6e3aR/PQO+6nopJ6f/zzFM9yPucO5678u6vo scsQ== X-Gm-Message-State: AOAM531WCNIXLRDc/qIT4P2+lESArRwyJ2xRz4VfDZax8q3McBGUeWby UAOgSj5NHTxjty3QYITpJLd6yq0sQ0ut4A== X-Received: by 2002:a63:4b61:: with SMTP id k33mr1583047pgl.195.1597910209384; Thu, 20 Aug 2020 00:56:49 -0700 (PDT) Received: from localhost ([122.172.43.13]) by smtp.gmail.com with ESMTPSA id n17sm1570767pgg.6.2020.08.20.00.56.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2020 00:56:48 -0700 (PDT) From: Viresh Kumar To: rnayak@codeaurora.org, Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , sibis@codeaurora.org, sbhanu@codeaurora.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 3/4] opp: Split out _opp_set_rate_zero() Date: Thu, 20 Aug 2020 13:26:33 +0530 Message-Id: <5a0183fa0b61cf70839fa90aa70f79e33ab4f60a.1597909885.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af 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 separate routine _opp_set_rate_zero() to handle !target_freq case. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 52 ++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 23 deletions(-) -- 2.25.0.rc1.19.g042ed3e048af diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 0b437d483b75..4edd2c3d6d91 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -860,6 +860,34 @@ int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp) } EXPORT_SYMBOL_GPL(dev_pm_opp_set_bw); +static int _opp_set_rate_zero(struct device *dev, struct opp_table *opp_table) +{ + int ret; + + if (!opp_table->enabled) + return 0; + + /* + * Some drivers need to support cases where some platforms may + * have OPP table for the device, while others don't and + * opp_set_rate() just needs to behave like clk_set_rate(). + */ + if (!_get_opp_count(opp_table)) + return 0; + + ret = _set_opp_bw(opp_table, NULL, dev, true); + if (ret) + return ret; + + if (opp_table->regulators) + regulator_disable(opp_table->regulators[0]); + + ret = _set_required_opps(dev, opp_table, NULL); + + opp_table->enabled = false; + return ret; +} + /** * dev_pm_opp_set_rate() - Configure new OPP based on frequency * @dev: device for which we do this operation @@ -886,29 +914,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) } if (unlikely(!target_freq)) { - ret = 0; - - if (!opp_table->enabled) - goto put_opp_table; - - /* - * Some drivers need to support cases where some platforms may - * have OPP table for the device, while others don't and - * opp_set_rate() just needs to behave like clk_set_rate(). - */ - if (!_get_opp_count(opp_table)) - goto put_opp_table; - - ret = _set_opp_bw(opp_table, NULL, dev, true); - if (ret) - goto put_opp_table; - - if (opp_table->regulators) - regulator_disable(opp_table->regulators[0]); - - ret = _set_required_opps(dev, opp_table, NULL); - - opp_table->enabled = false; + ret = _opp_set_rate_zero(dev, opp_table); goto put_opp_table; }