From patchwork Tue Jul 29 16:28:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 4641341 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BC97F9F32F for ; Tue, 29 Jul 2014 16:31:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E87A420149 for ; Tue, 29 Jul 2014 16:31:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 293DE20145 for ; Tue, 29 Jul 2014 16:31:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XCAHl-0000t3-7N; Tue, 29 Jul 2014 16:29:57 +0000 Received: from bhuna.collabora.co.uk ([93.93.135.160]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XCAHU-0000lw-Mu for linux-arm-kernel@lists.infradead.org; Tue, 29 Jul 2014 16:29:43 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: javier) with ESMTPSA id D2CB926880D7 From: Javier Martinez Canillas To: Mark Brown Subject: [RFC 3/5] regulator: core: Only apply constraints if available on list voltage Date: Tue, 29 Jul 2014 18:28:57 +0200 Message-Id: <1406651339-28901-4-git-send-email-javier.martinez@collabora.co.uk> X-Mailer: git-send-email 2.0.0.rc2 In-Reply-To: <1406651339-28901-1-git-send-email-javier.martinez@collabora.co.uk> References: <1406651339-28901-1-git-send-email-javier.martinez@collabora.co.uk> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140729_092940_905070_2C3D8AF1 X-CRM114-Status: GOOD ( 10.02 ) X-Spam-Score: -0.7 (/) Cc: devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Doug Anderson , linux-kernel@vger.kernel.org, Kukjin Kim , Yuvaraj Kumar C D , Olof Johansson , Javier Martinez Canillas , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If a selector can't be used on a platform due to voltage constraints, regulator_list_voltage() returns 0. Doing this unconditionally made sense since constraints were set in machine_constraints_voltage() at regulator registration time. But for load switches that don't define a voltage output, the parent supply voltage is used so the constraints should only be applied if they were defined for the child regulators. Signed-off-by: Javier Martinez Canillas --- drivers/regulator/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a3c3785..7472535 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2228,9 +2228,11 @@ int regulator_list_voltage(struct regulator *regulator, unsigned selector) } if (ret > 0) { - if (ret < rdev->constraints->min_uV) + if (rdev->constraints->min_uV && + ret < rdev->constraints->min_uV) ret = 0; - else if (ret > rdev->constraints->max_uV) + else if (rdev->constraints->max_uV && + ret > rdev->constraints->max_uV) ret = 0; }