From patchwork Thu Jan 28 08:20:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 60676 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp331404lbb; Thu, 28 Jan 2016 00:21:24 -0800 (PST) X-Received: by 10.98.65.91 with SMTP id o88mr2675376pfa.114.1453969284206; Thu, 28 Jan 2016 00:21:24 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 24si2570689pfo.28.2016.01.28.00.21.23; Thu, 28 Jan 2016 00:21:24 -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 S965347AbcA1IVQ (ORCPT + 30 others); Thu, 28 Jan 2016 03:21:16 -0500 Received: from mail-pf0-f177.google.com ([209.85.192.177]:36839 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965152AbcA1IVB (ORCPT ); Thu, 28 Jan 2016 03:21:01 -0500 Received: by mail-pf0-f177.google.com with SMTP id n128so19729243pfn.3 for ; Thu, 28 Jan 2016 00:20:59 -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=XtFtmPxvp9ljjSnXIrgo1KYWdKVCLu83RZsGam53ARo=; b=NylEboDlRijSAQBPcflexpUi1jlAoJg9xJrpDzvkM+Z25TZ/TeCzBaXNhoQCvRWFdx c19iASAS8Dfz0GfILJ93bPSBdzgAo50Uj7gJ1CEEahUGByPrS8fiD0kOlmNoH8teA63X njzlNqck7LkdnxSeLmIgE/ZiG6efR5sDQ1bc8= 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=XtFtmPxvp9ljjSnXIrgo1KYWdKVCLu83RZsGam53ARo=; b=dWjXrbxxpiXwJJ7TfIZ+YCuhrXG5067FNBourbh2BipcjON+9NRL91pPqWG9SzwcAo 5FlxJw2FTKNIDRBU1nOxC9tf0X4jltwq2neahgVaNruO3TijxyvkPf1SQI+8GzczRjsZ 264J5UOC+qlQsjNiYAn0A5silQ3DOe4tXi9bcn7htVhoDdvzJASgs4JhraZXTlp2/Flo QuRngoACprfApjzWbcQyfVKoitK/9RzsIMn82YzxRzcJFrpRNL7fvwLaNJIKeQEig9Un h40PMeKecXdpg2aDLFbeg0IhirTCk84z1Z8IjrwC/VSKu3+SRAEmiNGxnN+Qy0A63ghT wp5A== X-Gm-Message-State: AG10YOTlqPnNo4nHIZH7E7K7Az5AH36+p4lNzcQwSEAgfjRL8F/gZ8MoAYIGT6+D1TMCakTB X-Received: by 10.98.74.71 with SMTP id x68mr2692213pfa.80.1453969259114; Thu, 28 Jan 2016 00:20:59 -0800 (PST) Received: from localhost ([122.171.121.234]) by smtp.gmail.com with ESMTPSA id 68sm14177411pfa.78.2016.01.28.00.20.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jan 2016 00:20:58 -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 V2 02/16] PM / OPP: Disable OPPs that aren't supported by the regulator Date: Thu, 28 Jan 2016 13:50:31 +0530 Message-Id: <16ba415d52ce9c967201f9fca1385014334e1be3.1453965717.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.0.79.gdc08a19 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.0.79.gdc08a19 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; }