From patchwork Wed Feb 5 20:30:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 3590141 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2EE2FC02DC for ; Wed, 5 Feb 2014 20:30:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7074C20163 for ; Wed, 5 Feb 2014 20:30:56 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (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 30A2420154 for ; Wed, 5 Feb 2014 20:30:55 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WB97R-0005Gw-T0; Wed, 05 Feb 2014 20:30:50 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WB97P-0000oR-61; Wed, 05 Feb 2014 20:30:47 +0000 Received: from mail-lb0-f182.google.com ([209.85.217.182]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WB97M-0000nW-3g for linux-arm-kernel@lists.infradead.org; Wed, 05 Feb 2014 20:30:44 +0000 Received: by mail-lb0-f182.google.com with SMTP id w7so762551lbi.27 for ; Wed, 05 Feb 2014 12:30:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=F2cxOUVUQkIPSMp90e/d8XtoEzOctfVLicgccTamwpk=; b=lmt74T82ymrginCb6tzgG0eZgNA5Er2HMcLPWxF7MV0uC+hFLLVE1HmKcodTJebjN2 nw3CulkW/mCKeQHUS02A1ixkehcCqZYctCp4EXo9MqBy7zntwC8STgw1MAvBqOzg7wiv eY1SoLKxWgwH1cLkpXSLqb+DGIbJVIPdvsxq+mvGUXHZvrCROgMM03BCr9nFE52cumYF xUnwg2M7Rx/WUgbK48eYTsceRg8hcpuHZ5vSpxlW7EmCUhYnJEvuGzAhDz+rC9n9ExKZ IXC0rwVjE4dr4KlrswdCEsCR/OezbnpOrLyBcnMxepckG6MY3EP6IH9Xuy1XErw+Sf8h dv0Q== X-Gm-Message-State: ALoCoQlgivZiSXXMEtk7UEFXghbOY0cIHXmM/gXdvqKhwe0ESMb7hVZBvJlNojKEVgfUQ02k41Ai X-Received: by 10.152.205.163 with SMTP id lh3mr2499317lac.10.1391632221609; Wed, 05 Feb 2014 12:30:21 -0800 (PST) Received: from buildbot.san.rr.com (cpe-76-167-68-231.san.res.rr.com. [76.167.68.231]) by mx.google.com with ESMTPSA id jf8sm10669798lbc.8.2014.02.05.12.30.18 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Feb 2014 12:30:20 -0800 (PST) From: Bjorn Andersson To: Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] regulator: core: Allow regulator_set_voltage for fixed regulators Date: Wed, 5 Feb 2014 12:30:26 -0800 Message-Id: <1391632226-10060-1-git-send-email-bjorn.andersson@sonymobile.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1391493268-3242-1-git-send-email-bjorn.andersson@sonymobile.com> References: <1391493268-3242-1-git-send-email-bjorn.andersson@sonymobile.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140205_153044_303391_0CABA3A1 X-CRM114-Status: GOOD ( 10.75 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Make it okay to call regulator_set_voltage on regulators with fixed voltage if the requested range overlaps the current/configured voltage. Signed-off-by: Bjorn Andersson --- drivers/regulator/core.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index b38a6b6..0cd1a3b 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2395,6 +2395,7 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) struct regulator_dev *rdev = regulator->rdev; int ret = 0; int old_min_uV, old_max_uV; + int current_uV; mutex_lock(&rdev->mutex); @@ -2405,6 +2406,19 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) if (regulator->min_uV == min_uV && regulator->max_uV == max_uV) goto out; + /* If we're trying to set a range that overlaps the current voltage, + * return succesfully even though the regulator does not support + * changing the voltage. + */ + if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) { + current_uV = _regulator_get_voltage(rdev); + if (min_uV <= current_uV && current_uV <= max_uV) { + regulator->min_uV = min_uV; + regulator->max_uV = max_uV; + goto out; + } + } + /* sanity check */ if (!rdev->desc->ops->set_voltage && !rdev->desc->ops->set_voltage_sel) {