From patchwork Tue Dec 11 11:26:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 10723681 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 11E0E13AF for ; Tue, 11 Dec 2018 11:26:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0051B29196 for ; Tue, 11 Dec 2018 11:26:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E77602A48F; Tue, 11 Dec 2018 11:26:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AFDD29196 for ; Tue, 11 Dec 2018 11:26:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726426AbeLKL0k (ORCPT ); Tue, 11 Dec 2018 06:26:40 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:40833 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726281AbeLKL0k (ORCPT ); Tue, 11 Dec 2018 06:26:40 -0500 Received: by mail-pl1-f195.google.com with SMTP id u18so6786552plq.7 for ; Tue, 11 Dec 2018 03:26:40 -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:mime-version :content-transfer-encoding; bh=EZLJXHxTcd+FGSvGzSmPEZcFBlWXa9ssKRuIJpqqIhQ=; b=ZwYF8clqq1757VYOEH+GvmCLvcFR71xfv40qaRRvCoqdIX6LfR954dPh6u1aF5ux2I Bnyw/7aJgjOX283wNjb5qEGzE7J3Tk+r7buozpDVyzMy+x3MrTaFhk23OFn0EPawFRa2 WZqC+SrgRCj7MBMwQ/CdAkeUWbxF0NCqMi820= 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:mime-version :content-transfer-encoding; bh=EZLJXHxTcd+FGSvGzSmPEZcFBlWXa9ssKRuIJpqqIhQ=; b=fdMmXMkzhxescGVdSGyjTqXISRCpccVYOhQ09C/7zZ2GQW/A5nBlIaiptlBSatr77J c3X3zbmgAp5sFKhOMLoA9tnKvKiCCIzhxAYS+RGIZ946cMOZ2mDRZi70WTjd2biqEYSx tvSCpBEC4lygzpfhIP0gNH5xd48Y1namzFNrso8Z100ZRVL1df1UXAJkW84PQPM+W/kU YpWMlew1vdKiOd+l87LH9DXg2W/RHTwNO603Xon3PJ32NYrifJWl0Wn1ly/F1Fi89A5N zhunMcQf5oefiMTru588hEIXEHqrQZ7wLU0Fprn0P+PkJnxhIeUA2rm4+95Nf0bWJajq gomQ== X-Gm-Message-State: AA+aEWZoVIuJ1pJiAG3ILHNJt4mNWiZ+goMhQKFeC0arX4W8htGMaNdT fC0sS9EERDhHcFcLEeveILURHQ== X-Google-Smtp-Source: AFSGD/Xih+dE/SIbMCTQWd+eTydgKoriFXJO+Xe0NSTZ25lfYaMb7ozCg4ldrzlcQ2nfKxVUzIW01w== X-Received: by 2002:a17:902:4a0c:: with SMTP id w12mr15880935pld.8.1544527599935; Tue, 11 Dec 2018 03:26:39 -0800 (PST) Received: from localhost ([122.172.23.29]) by smtp.gmail.com with ESMTPSA id v191sm31680073pgb.77.2018.12.11.03.26.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 03:26:39 -0800 (PST) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , Quentin Perret , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] OPP: Use opp_table->regulators to verify no regulator case Date: Tue, 11 Dec 2018 16:56:28 +0530 Message-Id: <90e3577b5feb42bac1269e16bb3d2bdd8f6df40f.1544527580.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.19.1.568.g152ad8e3369a MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The value of opp_table->regulator_count is not very consistent right now and it may end up being 0 while we do have a "opp-microvolt" property in the OPP table. It was kept that way as we used to check if any regulators are set with the OPP core for a device or not using value of regulator_count. Lets use opp_table->regulators for that purpose as the meaning of regulator_count is going to change in the later patches. Reported-by: Quentin Perret Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 2c2df4e4fc14..2d3d0d1180ea 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -196,12 +196,12 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev) if (IS_ERR(opp_table)) return 0; - count = opp_table->regulator_count; - /* Regulator may not be required for the device */ - if (!count) + if (!opp_table->regulators) goto put_opp_table; + count = opp_table->regulator_count; + uV = kmalloc_array(count, sizeof(*uV), GFP_KERNEL); if (!uV) goto put_opp_table; @@ -1049,6 +1049,9 @@ static bool _opp_supported_by_regulators(struct dev_pm_opp *opp, struct regulator *reg; int i; + if (!opp_table->regulators) + return true; + for (i = 0; i < opp_table->regulator_count; i++) { reg = opp_table->regulators[i]; @@ -1333,7 +1336,7 @@ static int _allocate_set_opp_data(struct opp_table *opp_table) struct dev_pm_set_opp_data *data; int len, count = opp_table->regulator_count; - if (WARN_ON(!count)) + if (WARN_ON(!opp_table->regulators)) return -EINVAL; /* space for set_opp_data */