From patchwork Thu Jun 2 10:23:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 69142 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp38322qgf; Thu, 2 Jun 2016 03:24:31 -0700 (PDT) X-Received: by 10.98.152.142 with SMTP id d14mr2987850pfk.105.1464863071416; Thu, 02 Jun 2016 03:24:31 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e13si57453732pfd.86.2016.06.02.03.24.31; Thu, 02 Jun 2016 03:24:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932458AbcFBKY1 (ORCPT + 8 others); Thu, 2 Jun 2016 06:24:27 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:36465 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751317AbcFBKXo (ORCPT ); Thu, 2 Jun 2016 06:23:44 -0400 Received: by mail-wm0-f41.google.com with SMTP id n184so72494689wmn.1 for ; Thu, 02 Jun 2016 03:23:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9fNC7qmQM3Ot67g/mV3hY/OEsQ5QBcSURwaZPQK/N9E=; b=D/F1K+BbmFKlq/d9oMKfRcNmwypJ9deo8qquJ8X1MOLzXFtnBNwmsOsakMrvvLhN9g 4LbVS8WRG8clGD5CcA3LikSwL4UNahz5/2+VRULETvItV1T7ZxO4VBq5bFmueM2ImRqG 2limcOACjWQ0rmN4jtw+eJInhz5YKq7twA2No= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9fNC7qmQM3Ot67g/mV3hY/OEsQ5QBcSURwaZPQK/N9E=; b=nCtvCHdT4x9NOUWIYe7/P7F8Z4bYEQj6IxN8iJRDuvV0YcACdxj7iojfZnd+MSTyh9 Fa90JwHOHDxlI5pL6r+GJlD3wrWKboijoLLnYj6GUGbS4ByR2X4lwoTleB3TbtysYsFl 3CzrOCUTqlQ9FT86HE7PtKEurP1dyOZ7NV3gHbuPj700aKDWsCOvrxxlMMkcI2PCXzlY XGi8Nl2trJItAwkGDebcc8lEaQCN90lOfHHva3qhlt01fTinLukB7+FHhh6di0mGiX5c wyeFijHXUwXtjOEmXitvkOVHErMPWa0Xiip2pUzssSB6iEhgbk3yHF2Ga0lxf7fA7PX7 6QZQ== X-Gm-Message-State: ALyK8tJomh3yq5tN/Q+khuUFfppx510mma+Cfn/G4Ggu9CI+k5FOLJMjqqAPvmTJXeJcFPkN X-Received: by 10.194.164.200 with SMTP id ys8mr7846515wjb.79.1464863023457; Thu, 02 Jun 2016 03:23:43 -0700 (PDT) Received: from localhost.localdomain (host-92-17-247-99.as13285.net. [92.17.247.99]) by smtp.gmail.com with ESMTPSA id t3sm39637107wmf.20.2016.06.02.03.23.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Jun 2016 03:23:42 -0700 (PDT) From: Srinivas Kandagatla To: bjorn.andersson@linaro.org, Mark Brown Cc: linux-kernel@vger.kernel.org, Liam Girdwood , linux-arm-msm@vger.kernel.org, Srinivas Kandagatla Subject: [RFC PATCH v1 1/3] regulator: helpers: consider constriants in list_voltage_linear_range Date: Thu, 2 Jun 2016 11:23:14 +0100 Message-Id: <1464862996-3147-2-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1464862996-3147-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1464862996-3147-1-git-send-email-srinivas.kandagatla@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Regulator drivers can have linear range which is according to the regualtor hardware spec, however the board level device tree files can restrict this range by adding constriants. These constriants are not considered in the exsiting code, which gives false supported voltage range to the consumers. Fix this by adding constriants check in the helper function. Signed-off-by: Srinivas Kandagatla --- For now I have added this support for regulator_list_voltage_linear_range() If it makes sense we can extend this to other list voltage helpers too. drivers/regulator/helpers.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -- 2.8.2 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c index bcf38fd..379b2b3 100644 --- a/drivers/regulator/helpers.c +++ b/drivers/regulator/helpers.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -374,7 +375,7 @@ int regulator_list_voltage_linear_range(struct regulator_dev *rdev, unsigned int selector) { const struct regulator_linear_range *range; - int i; + int i, v; if (!rdev->desc->n_linear_ranges) { BUG_ON(!rdev->desc->n_linear_ranges); @@ -389,8 +390,13 @@ int regulator_list_voltage_linear_range(struct regulator_dev *rdev, continue; selector -= range->min_sel; + v = range->min_uV + (range->uV_step * selector); - return range->min_uV + (range->uV_step * selector); + if (v < rdev->constraints->min_uV || + v > rdev->constraints->max_uV) + return -EINVAL; + else + return v; } return -EINVAL;