From patchwork Thu Jul 9 15:35:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 50973 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C3CB5213FD for ; Thu, 9 Jul 2015 15:35:55 +0000 (UTC) Received: by wipp2 with SMTP id p2sf61259865wip.2 for ; Thu, 09 Jul 2015 08:35:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=apNrWGbINBFmj/3hXpQXh7ANCBq+jTQtCaIuL6jdtWw=; b=GxUB/bpXRqmGlHfJuv8NvhATfMQnIJ6ppHyq1NpR38XN4/YJFy28oWbtOVL6mN5T4+ DLdNKZLyuCTVTwKkBVpVUiR9X0FigJe6kYRd2BRf9QtEpKQbCcZr7M3mKLYwLtXL4hlQ 0hAbrhcGm8/ylcmpLqqya9O2eBAiY8ArccvlwDlyECktFTnusIas9wKPiwFxflVgHMx9 c4wS6Kdq2wwtoeSBUdBQCnw5hme9758psxWCzh+HhGtp7fUqQMbma/BsDNwGJK+pPiZ/ iW2m8aHNxO5XXuB/XIZ5dTTOTzsplZXryXEbAlSlnk2wOEEARUoq1vxOJDfEhhntm9uK AYTw== X-Gm-Message-State: ALoCoQlNGXhJlT1EFHAt8jAFgacZjACdQ+JbUPfmBVdjdSzi4/rfKMYIEgx2Bo4LKxhNK2z6z+e7 X-Received: by 10.152.6.103 with SMTP id z7mr8263485laz.8.1436456154982; Thu, 09 Jul 2015 08:35:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.224.162 with SMTP id rd2ls1051040lac.84.gmail; Thu, 09 Jul 2015 08:35:54 -0700 (PDT) X-Received: by 10.112.48.68 with SMTP id j4mr15238339lbn.60.1436456154765; Thu, 09 Jul 2015 08:35:54 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id pk3si5103878lbb.75.2015.07.09.08.35.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jul 2015 08:35:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by labgy5 with SMTP id gy5so96509583lab.2 for ; Thu, 09 Jul 2015 08:35:54 -0700 (PDT) X-Received: by 10.152.18.162 with SMTP id x2mr15488601lad.73.1436456154662; Thu, 09 Jul 2015 08:35:54 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp744110lbb; Thu, 9 Jul 2015 08:35:53 -0700 (PDT) X-Received: by 10.70.55.1 with SMTP id n1mr32188985pdp.21.1436456152910; Thu, 09 Jul 2015 08:35:52 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pi2si9790109pbb.128.2015.07.09.08.35.52; Thu, 09 Jul 2015 08:35:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753206AbbGIPfs (ORCPT + 8 others); Thu, 9 Jul 2015 11:35:48 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:35179 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753222AbbGIPfh (ORCPT ); Thu, 9 Jul 2015 11:35:37 -0400 Received: by wiga1 with SMTP id a1so316431500wig.0 for ; Thu, 09 Jul 2015 08:35:36 -0700 (PDT) X-Received: by 10.180.77.200 with SMTP id u8mr87850906wiw.70.1436456136585; Thu, 09 Jul 2015 08:35:36 -0700 (PDT) Received: from localhost.localdomain (host86-178-207-130.range86-178.btcentralplus.com. [86.178.207.130]) by smtp.gmail.com with ESMTPSA id e7sm8822001wib.22.2015.07.09.08.35.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Jul 2015 08:35:36 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: kernel@stlinux.com, broonie@kernel.org, lgirdwood@gmail.com, devicetree@vger.kernel.org, Lee Jones Subject: [PATCH 3/3] regulator: pwm-regulator: Small clean-ups Date: Thu, 9 Jul 2015 16:35:28 +0100 Message-Id: <1436456128-18278-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436456128-18278-1-git-send-email-lee.jones@linaro.org> References: <1436456128-18278-1-git-send-email-lee.jones@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Remove over-bracketing, use framework API to fetch PWM period and be more forthcoming that pwm_voltage_to_duty_cycle() actually returns duty cycle as a percentage, rather than a register value. Signed-off-by: Lee Jones --- drivers/regulator/pwm-regulator.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c index d92e667..936e387 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c @@ -92,13 +92,13 @@ static int pwm_regulator_list_voltage(struct regulator_dev *rdev, /** * Continuous voltage call-backs */ -static int pwm_voltage_to_duty_cycle(struct regulator_dev *rdev, int req_uV) +static int pwm_voltage_to_duty_cycle_percentage(struct regulator_dev *rdev, int req_uV) { int min_uV = rdev->constraints->min_uV; int max_uV = rdev->constraints->max_uV; int diff = max_uV - min_uV; - return 100 - ((((req_uV * 100) - (min_uV * 100)) / diff)); + return 100 - (((req_uV * 100) - (min_uV * 100)) / diff); } static int pwm_regulator_get_voltage(struct regulator_dev *rdev) @@ -114,14 +114,13 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev, { struct pwm_regulator_data *drvdata = rdev_get_drvdata(rdev); unsigned int ramp_delay = rdev->constraints->ramp_delay; + unsigned int period = pwm_get_period(drvdata->pwm); int duty_cycle; int ret; - duty_cycle = pwm_voltage_to_duty_cycle(rdev, min_uV); + duty_cycle = pwm_voltage_to_duty_cycle_percentage(rdev, min_uV); - ret = pwm_config(drvdata->pwm, - (drvdata->pwm->period / 100) * duty_cycle, - drvdata->pwm->period); + ret = pwm_config(drvdata->pwm, (period / 100) * duty_cycle, period); if (ret) { dev_err(&rdev->dev, "Failed to configure PWM\n"); return ret;