From patchwork Mon Nov 16 08:56:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris BREZILLON X-Patchwork-Id: 7622671 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 13EAF9F2E2 for ; Mon, 16 Nov 2015 09:03:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 227CF205C4 for ; Mon, 16 Nov 2015 09:03:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2902F2047B for ; Mon, 16 Nov 2015 09:03:44 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZyFhO-0000ZA-CT; Mon, 16 Nov 2015 09:03:42 +0000 Received: from down.free-electrons.com ([37.187.137.238] helo=mail.free-electrons.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZyFbX-0002LC-3a; Mon, 16 Nov 2015 08:57:48 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id E43C4417; Mon, 16 Nov 2015 09:57:00 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-5.0 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 (AToulouse-657-1-1082-82.w92-146.abo.wanadoo.fr [92.146.160.82]) by mail.free-electrons.com (Postfix) with ESMTPSA id E1D0A420; Mon, 16 Nov 2015 09:56:57 +0100 (CET) From: Boris Brezillon To: Thierry Reding , linux-pwm@vger.kernel.org Subject: [PATCH v4 07/24] pwm: use pwm_get/set_default_xxx() helpers where appropriate Date: Mon, 16 Nov 2015 09:56:30 +0100 Message-Id: <1447664207-24370-8-git-send-email-boris.brezillon@free-electrons.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447664207-24370-1-git-send-email-boris.brezillon@free-electrons.com> References: <1447664207-24370-1-git-send-email-boris.brezillon@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151116_005739_884717_B4BD36A5 X-CRM114-Status: GOOD ( 13.10 ) X-Spam-Score: -3.2 (---) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kamil Debski , Heiko Stuebner , Mike Turquette , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Alexandre Belloni , Lee Jones , linux-clk@vger.kernel.org, linux-leds@vger.kernel.org, Boris Brezillon , 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 , Guenter Roeck , Jean Delvare , Joachim Eastwood , Bryan Wu , Julia Lawall , Mark Brown , Jacek Anaszewski , linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , Jingoo Han , Dmitry Torokhov , Stephen Boyd , Liam Girdwood , Richard Purdie , Maxime Ripard MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP pwm_set/get_default_xxx() helpers have been introduced to differentiate the default PWM states (those retrieved through DT, PWM lookup table or statically assigned by the driver) and the current PWM ones. Make use of those helpers where appropriate. Signed-off-by: Boris Brezillon Tested-by: Heiko Stuebner Reviewed-by: Alexandre Belloni Acked-by: Robert Jarzmik --- drivers/pwm/core.c | 14 +++++++------- drivers/pwm/pwm-pxa.c | 2 +- drivers/pwm/pwm-sun4i.c | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index d24ca5f..59073a1 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -146,12 +146,12 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args) if (IS_ERR(pwm)) return pwm; - pwm_set_period(pwm, args->args[1]); + pwm_set_default_period(pwm, args->args[1]); if (args->args[2] & PWM_POLARITY_INVERTED) - pwm_set_polarity(pwm, PWM_POLARITY_INVERSED); + pwm_set_default_polarity(pwm, PWM_POLARITY_INVERSED); else - pwm_set_polarity(pwm, PWM_POLARITY_NORMAL); + pwm_set_default_polarity(pwm, PWM_POLARITY_NORMAL); return pwm; } @@ -172,7 +172,7 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args) if (IS_ERR(pwm)) return pwm; - pwm_set_period(pwm, args->args[1]); + pwm_set_default_period(pwm, args->args[1]); return pwm; } @@ -268,7 +268,7 @@ int pwmchip_add_with_polarity(struct pwm_chip *chip, pwm->chip = chip; pwm->pwm = chip->base + i; pwm->hwpwm = i; - pwm->polarity = polarity; + pwm_set_default_polarity(pwm, polarity); mutex_init(&pwm->lock); radix_tree_insert(&pwm_tree, pwm->pwm, pwm); @@ -751,8 +751,8 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id) if (IS_ERR(pwm)) goto out; - pwm_set_period(pwm, chosen->period); - pwm_set_polarity(pwm, chosen->polarity); + pwm_set_default_period(pwm, chosen->period); + pwm_set_default_polarity(pwm, chosen->polarity); out: mutex_unlock(&pwm_lookup_lock); diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c index cb2f702..65b80aa 100644 --- a/drivers/pwm/pwm-pxa.c +++ b/drivers/pwm/pwm-pxa.c @@ -160,7 +160,7 @@ pxa_pwm_of_xlate(struct pwm_chip *pc, const struct of_phandle_args *args) if (IS_ERR(pwm)) return pwm; - pwm_set_period(pwm, args->args[0]); + pwm_set_default_period(pwm, args->args[0]); return pwm; } diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c index 67af9f6..f6a7451 100644 --- a/drivers/pwm/pwm-sun4i.c +++ b/drivers/pwm/pwm-sun4i.c @@ -354,7 +354,8 @@ static int sun4i_pwm_probe(struct platform_device *pdev) val = sun4i_pwm_readl(pwm, PWM_CTRL_REG); for (i = 0; i < pwm->chip.npwm; i++) if (!(val & BIT_CH(PWM_ACT_STATE, i))) - pwm->chip.pwms[i].polarity = PWM_POLARITY_INVERSED; + pwm_set_default_polarity(&pwm->chip.pwms[i], + PWM_POLARITY_INVERSED); clk_disable_unprepare(pwm->clk); return 0;