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: 3590131 Return-Path: X-Original-To: patchwork-linux-arm-msm@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 39CF99F2E9 for ; Wed, 5 Feb 2014 20:30:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 63BCF20154 for ; Wed, 5 Feb 2014 20:30:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 977BE20145 for ; Wed, 5 Feb 2014 20:30:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932378AbaBEUa0 (ORCPT ); Wed, 5 Feb 2014 15:30:26 -0500 Received: from mail-la0-f44.google.com ([209.85.215.44]:49625 "EHLO mail-la0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755272AbaBEUaX (ORCPT ); Wed, 5 Feb 2014 15:30:23 -0500 Received: by mail-la0-f44.google.com with SMTP id hr13so770286lab.3 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=HX2wz21mY1xm8rYg3YESGPxqcNvt/cvzpVolGXmNcehuKyq/iB4Q5pVRDwZnMjQoA7 I1QUI4A+ASZiJ48yQkMY9G+W8tAvcZj+em+uComZNauQgzio/pJhStwS6sq/E9jnYOJX 4cfYuPV6G58QpdIwhIYU9W026V0AQQqRdM8zjn79A8K4Htvr8nVJF02p03qI+M3xNQgt oFdj2LiOtvqCFvEVihjT/rUJL3O3whrQxK0AyLek4fOvpiqJAoWoOUgkOS++Cy/gq7Kd N7XoHV4IwB360ztQ393fGQuSD8LMEYMlYOXRwMtqkCDxjhaocH6vDOe0c+aW3049jHlQ N08g== X-Gm-Message-State: ALoCoQmFLgFq4LgBLo0Stm0iIIi2Q+3QRO6kxqP5TzSAe6EdColxTqY/LLM72yqMA1y4m74tdQUA 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> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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) {