Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3631026imu; Mon, 28 Jan 2019 08:08:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN77XP8dhiVx7F6tVvgeXDXgbnqfhXY2oblyLDD/ZnOUxq3O2oqHA4GrYj0ig0L6KbDgPy9D X-Received: by 2002:a63:1c09:: with SMTP id c9mr20107704pgc.200.1548691687668; Mon, 28 Jan 2019 08:08:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691687; cv=none; d=google.com; s=arc-20160816; b=ly2eXv8mXNR8CvkdpXSGnCS5qFWrDU0i6DNLZ3gmwL+WEp1kK4ZM+v3n+keHG2W//s JiIwCIgb6/JndKg+yo8+ocEqYdqukAVAAWdyY04941uMvhq+2pJ7ANJRvhXdugR0pB3f 5WUKmPoyYoMhUcEp4k8h7s/kNK7d5ONeq8JGYBXGYopGNJPuOFcWStzMbW78A5cxAYXA 92vr77deDBXpy/d+1Yzin4LFUYIuog2ydasRean6+19XuYwtUBISKbXDBtdlwL3LTEQS eaPdmND/dKxzr9u1r0X8hmYbW9Ac6d6oFjT0FMB8p90e0YpwdTcS8shChK2f+Ft70OV6 qxHA== 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=fjrrlPlbqy/7SsiWB79OSIYhZCmUbe/p/nbJ/KRoOVM=; b=Y9/NV3W/beZPxjgrTolGhekiHlRFlh08fqlMdfVmpm66CV/pdaMYPuIg/QUJfb/IIG sspBWmGP7BB/Q5R/qC11tQixTiB4r/rsRFVOHprk0xZUuDAq8r5dpqLCrdZJ+IYlwsx9 2ej8Jp9CJwq9wftjn59i0pSEbcUoznx8iv20PO4QIIehRLjmwnIOOQJipUQGDEnKtxuS /G4TOwFlVEg96ZSw4GgJH5/UrBM3H50kC1ASsXMQTrh3Al6ORCXFjgvlb4W763yg0Sou Ti5rWSEhYaXmZ5/miHB/nvMScZSbOzwklq4Gce4JdNeZgZyTo72vcVLiiohUPBW/BirP 3Qfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=u3qwHliX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e129si32389309pgc.333.2019.01.28.08.07.51; Mon, 28 Jan 2019 08:08:07 -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; dkim=pass header.i=@kernel.org header.s=default header.b=u3qwHliX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731895AbfA1QFn (ORCPT + 99 others); Mon, 28 Jan 2019 11:05:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:52830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731858AbfA1QFj (ORCPT ); Mon, 28 Jan 2019 11:05:39 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C76EA2173C; Mon, 28 Jan 2019 16:05:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691538; bh=0GBzWdHy8yzAv7ZNOhTeeKixVeEY6VaHUb4E2ryiBZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u3qwHliXnh+fFN30hAua9ceYBGwFpr5/mETwmIGvQSTwfw2lrnSQs7bwjPOqYornA zMJ4SCu0IRUR1M+1qpbL1qsX/yj0SSHUaDQqmYuV9sFueVh9XuI5XOqU+nTAH30vzX 7EyuThz24ykGdn0zHEXWYMXBK9uQ4JswI6SXGicI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Viresh Kumar , Sasha Levin , linux-pm@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 135/258] OPP: Use opp_table->regulators to verify no regulator case Date: Mon, 28 Jan 2019 10:57:21 -0500 Message-Id: <20190128155924.51521-135-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Viresh Kumar [ 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 31ff03dbeb83..f3433bf47b10 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -191,12 +191,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; @@ -976,6 +976,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]; @@ -1263,7 +1266,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