From patchwork Tue Feb 9 05:00:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 61490 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1831042lbl; Mon, 8 Feb 2016 21:02:04 -0800 (PST) X-Received: by 10.98.33.135 with SMTP id o7mr47323441pfj.158.1454994124148; Mon, 08 Feb 2016 21:02:04 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u66si51404586pfa.106.2016.02.08.21.02.03; Mon, 08 Feb 2016 21:02:04 -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; 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; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752729AbcBIFB0 (ORCPT + 30 others); Tue, 9 Feb 2016 00:01:26 -0500 Received: from mail-pf0-f173.google.com ([209.85.192.173]:33231 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750978AbcBIFBP (ORCPT ); Tue, 9 Feb 2016 00:01:15 -0500 Received: by mail-pf0-f173.google.com with SMTP id q63so17695529pfb.0 for ; Mon, 08 Feb 2016 21:01: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=q1I3lYpdQGxUrPK2+oeUNnSrrJ+c3SwcD5jjcrPcbRI=; b=QYxCwNNhK6+WlWqYo8cYV9HvskAK/XPQEd3riFjVvV5MqDBBnXEQb+067dL0ObpG0H 8FZgvIZGAMMhSS8l4PUJCHb4AaGRJbN7XETWeVvbfu5FVWoA0Ywj5aG1N3Il5ok42RvH zqlikzAtzeOhLboXC2/m2ddXKlAMaFpP8WN9g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=q1I3lYpdQGxUrPK2+oeUNnSrrJ+c3SwcD5jjcrPcbRI=; b=TLHTZHjDQlwFEjHDmWLU+fkdUTd8ByIXE5rbQA8lrqHjQ2Gjz4HMyRv1k7cg1BjURp ZVl7sZnPsvdlDMSS4SoGdhgmqvQyiNGrzSk+pHVtsTiGVHogyEhZNbN+pyexrx+933Eg CeNB6aMQPN+c2Elihf8aqjcgnG4wnLg3XuUSauuR3EonUtB5AHsmaXrpefIkdAYQsSa8 0A4owzJ4jtBKH62jj6mO/9cUwA3cvC4RIbIlqSv2L/zbNhT48koQPiHyhvECugl1lyI5 6R94tiJI2X0ijXkT0EYLTcyDqDf3idaOzth3qD2YPYQ13NI3Vu2TT2Hs7WlGLcvP8K6v TWVQ== X-Gm-Message-State: AG10YOTwlWlFb6KI4aXgHp9xS3HuHRo9uZxzy8SJ+s31iJO6/T0RX1sC5MUyO5eir85PKCZ5 X-Received: by 10.98.42.10 with SMTP id q10mr47703699pfq.73.1454994074099; Mon, 08 Feb 2016 21:01:14 -0800 (PST) Received: from localhost ([122.172.22.246]) by smtp.gmail.com with ESMTPSA id e14sm46971806pap.24.2016.02.08.21.01.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 21:01:13 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Stephen Boyd , nm@ti.com, Viresh Kumar , Greg Kroah-Hartman , Len Brown , linux-kernel@vger.kernel.org (open list), Pavel Machek , Viresh Kumar Subject: [PATCH V3 02/16] PM / OPP: Disable OPPs that aren't supported by the regulator Date: Tue, 9 Feb 2016 10:30:34 +0530 Message-Id: <4046978926e8e61e56489e8ed348d1725cbfd499.1454992186.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.370.gb2aa7f8 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 Disable any OPPs where the connected regulator isn't able to provide the specified voltage. Signed-off-by: Viresh Kumar Reviewed-by: Stephen Boyd --- drivers/base/power/opp/core.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) -- 2.7.1.370.gb2aa7f8 diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 1e22b71abf1e..71545becfca1 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -687,6 +687,22 @@ static struct dev_pm_opp *_allocate_opp(struct device *dev, return opp; } +static bool _opp_supported_by_regulators(struct dev_pm_opp *opp, + struct device_opp *dev_opp) +{ + struct regulator *reg = dev_opp->regulator; + + if (!IS_ERR(reg) && + !regulator_is_supported_voltage(reg, opp->u_volt_min, + opp->u_volt_max)) { + pr_warn("%s: OPP minuV: %lu maxuV: %lu, not supported by regulator\n", + __func__, opp->u_volt_min, opp->u_volt_max); + return false; + } + + return true; +} + static int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, struct device_opp *dev_opp) { @@ -728,6 +744,12 @@ static int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, dev_err(dev, "%s: Failed to register opp to debugfs (%d)\n", __func__, ret); + if (!_opp_supported_by_regulators(new_opp, dev_opp)) { + new_opp->available = false; + dev_warn(dev, "%s: OPP not supported by regulators (%lu)\n", + __func__, new_opp->rate); + } + return 0; }