From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03749C282CE for ; Mon, 11 Feb 2019 14:29:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C8DDC20675 for ; Mon, 11 Feb 2019 14:29:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895370; bh=DXy3oMxX7ILCGwVqdqFfLxysEeD9Rlz8AGTtLLjCOC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=IuKpl5y3tqCNY/HMzSfs74AAIBJKWeJdRyBWNls/iX+1aOkGONIR6a08cEgQl5KOV HcxQb5Rtbgl1zWSrzJu07AE7o+vwnFBVwccuSLSjdTGqWzQdHYhMGfgQWiPKOyH88G qz+VHceZsiZWz1vws3WRlOVyE7nxjbTwcOhpOWqM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729996AbfBKO32 (ORCPT ); Mon, 11 Feb 2019 09:29:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:35482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728934AbfBKO3X (ORCPT ); Mon, 11 Feb 2019 09:29:23 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0570F2075C; Mon, 11 Feb 2019 14:29:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895363; bh=DXy3oMxX7ILCGwVqdqFfLxysEeD9Rlz8AGTtLLjCOC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ojaXinqqQM9PCC+k1YMdsQSmggQHxyyVM5BCUSPqvcgJmUIXi5eHLaBgaic9xNPmv XJh7ZyVZGdHpbtmZYByK/lQFr8qCKdCx6sgiRQ+xeIkQoX1slMr8vukZVsJ78OcrcL AN4YyimWJ+5pO80OvxoDOPLdEJucMGpu1lJGbfQw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Quentin Perret , Viresh Kumar , Sasha Levin Subject: [PATCH 4.20 149/352] OPP: Use opp_table->regulators to verify no regulator case Date: Mon, 11 Feb 2019 15:16:16 +0100 Message-Id: <20190211141856.130416362@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 90e3577b5feb42bac1269e16bb3d2bdd8f6df40f ] 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 Signed-off-by: Sasha Levin --- 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 9280f51f1ce6..82baed4b80d4 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; @@ -1102,6 +1102,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]; @@ -1386,7 +1389,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 */ -- 2.19.1