From patchwork Wed Mar 30 20:03:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris BREZILLON X-Patchwork-Id: 8706681 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D1069C0553 for ; Thu, 31 Mar 2016 00:50:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F262620383 for ; Thu, 31 Mar 2016 00:50:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 5E58B20386 for ; Thu, 31 Mar 2016 00:50:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8C0956E935; Thu, 31 Mar 2016 00:50:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.free-electrons.com (down.free-electrons.com [37.187.137.238]) by gabe.freedesktop.org (Postfix) with ESMTP id 8C9DD6E8A9; Wed, 30 Mar 2016 20:05:35 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 4E9FE1861; Wed, 30 Mar 2016 22:05:34 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost.localdomain (LFbn-1-2159-240.w90-76.abo.wanadoo.fr [90.76.216.240]) by mail.free-electrons.com (Postfix) with ESMTPSA id 32C09184E; Wed, 30 Mar 2016 22:05:07 +0200 (CEST) From: Boris Brezillon To: Thierry Reding , linux-pwm@vger.kernel.org Subject: [PATCH v5 28/46] regulator: pwm: swith to the atomic PWM API Date: Wed, 30 Mar 2016 22:03:51 +0200 Message-Id: <1459368249-13241-29-git-send-email-boris.brezillon@free-electrons.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459368249-13241-1-git-send-email-boris.brezillon@free-electrons.com> References: <1459368249-13241-1-git-send-email-boris.brezillon@free-electrons.com> X-Mailman-Approved-At: Thu, 31 Mar 2016 00:47:56 +0000 Cc: Milo Kim , Kamil Debski , linux-doc@vger.kernel.org, Mike Turquette , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Alexandre Belloni , Daniel Vetter , Lee Jones , linux-clk@vger.kernel.org, linux-leds@vger.kernel.org, Krzysztof Kozlowski , linux-samsung-soc@vger.kernel.org, Alexander Shiyan , Jonathan Corbet , Robert Jarzmik , lm-sensors@lm-sensors.org, linux-rockchip@lists.infradead.org, Chen-Yu Tsai , Tomi Valkeinen , linux-input@vger.kernel.org, Jean-Christophe Plagniol-Villard , intel-gfx@lists.freedesktop.org, Guenter Roeck , Jean Delvare , Joachim Eastwood , Bryan Wu , Mark Brown , Jacek Anaszewski , linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , Ryan Mallon , Jingoo Han , Dmitry Torokhov , Stephen Boyd , Liam Girdwood , Hartley Sweeten , Richard Purdie , Kukjin Kim , Maxime Ripard X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP pwm_config/enable/disable() have been deprecated in favor of pwm_apply_state(). Replace all those calls with the equivalent pwm_get/apply_state(). Signed-off-by: Boris Brezillon --- drivers/regulator/pwm-regulator.c | 54 ++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c index 9590fb0..42cc312 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c @@ -59,16 +59,18 @@ static int pwm_regulator_set_voltage_sel(struct regulator_dev *rdev, unsigned selector) { struct pwm_regulator_data *drvdata = rdev_get_drvdata(rdev); - struct pwm_args pargs = { }; - int dutycycle; + struct pwm_state pstate = { }; + u64 dutycycle; int ret; - pwm_get_args(drvdata->pwm, &pargs); + pwm_get_state(drvdata->pwm, &pstate); - dutycycle = (pargs.period * - drvdata->duty_cycle_table[selector].dutycycle) / 100; + dutycycle = drvdata->duty_cycle_table[selector].dutycycle; + dutycycle *= pstate.period; + do_div(dutycycle, 100); + pstate.duty_cycle = dutycycle; - ret = pwm_config(drvdata->pwm, dutycycle, pargs.period); + ret = pwm_apply_state(drvdata->pwm, &pstate); if (ret) { dev_err(&rdev->dev, "Failed to configure PWM\n"); return ret; @@ -93,24 +95,39 @@ static int pwm_regulator_list_voltage(struct regulator_dev *rdev, static int pwm_regulator_enable(struct regulator_dev *dev) { struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev); + struct pwm_state pstate = { }; + + pwm_get_state(drvdata->pwm, &pstate); + if (pstate.enabled) + return 0; + + pstate.enabled = true; - return pwm_enable(drvdata->pwm); + return pwm_apply_state(drvdata->pwm, &pstate); } static int pwm_regulator_disable(struct regulator_dev *dev) { struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev); + struct pwm_state pstate = { }; - pwm_disable(drvdata->pwm); + pwm_get_state(drvdata->pwm, &pstate); + if (!pstate.enabled) + return 0; - return 0; + pstate.enabled = false; + + return pwm_apply_state(drvdata->pwm, &pstate); } static int pwm_regulator_is_enabled(struct regulator_dev *dev) { struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev); + struct pwm_state pstate = { }; - return pwm_is_enabled(drvdata->pwm); + pwm_get_state(drvdata->pwm, &pstate); + + return pstate.enabled; } /** @@ -138,25 +155,22 @@ 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; - struct pwm_args pargs = { }; - int duty_cycle; + struct pwm_state pstate = { }; + u64 duty_cycle; int ret; - pwm_get_args(drvdata->pwm, &pargs); + pwm_get_state(drvdata->pwm, &pstate); duty_cycle = pwm_voltage_to_duty_cycle_percentage(rdev, min_uV); + duty_cycle *= pstate.period; + do_div(duty_cycle, 100); + pstate.duty_cycle = duty_cycle; - ret = pwm_config(drvdata->pwm, (pargs.period / 100) * duty_cycle, - pargs.period); + ret = pwm_apply_state(drvdata->pwm, &pstate); if (ret) { dev_err(&rdev->dev, "Failed to configure PWM\n"); return ret; } - ret = pwm_enable(drvdata->pwm); - if (ret) { - dev_err(&rdev->dev, "Failed to enable PWM\n"); - return ret; - } drvdata->volt_uV = min_uV; /* Delay required by PWM regulator to settle to the new voltage */