Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752951AbbKPJDV (ORCPT ); Mon, 16 Nov 2015 04:03:21 -0500 Received: from down.free-electrons.com ([37.187.137.238]:34686 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750911AbbKPI5F (ORCPT ); Mon, 16 Nov 2015 03:57:05 -0500 From: Boris Brezillon To: Thierry Reding , linux-pwm@vger.kernel.org Cc: Mike Turquette , Stephen Boyd , linux-clk@vger.kernel.org, Mark Brown , Liam Girdwood , Kamil Debski , lm-sensors@lm-sensors.org, Jean Delvare , Guenter Roeck , Dmitry Torokhov , linux-input@vger.kernel.org, Bryan Wu , Richard Purdie , Jacek Anaszewski , linux-leds@vger.kernel.org, Maxime Ripard , Chen-Yu Tsai , linux-sunxi@googlegroups.com, Joachim Eastwood , Thomas Petazzoni , Heiko Stuebner , linux-rockchip@lists.infradead.org, Jingoo Han , Lee Jones , linux-fbdev@vger.kernel.org, Jean-Christophe Plagniol-Villard , Tomi Valkeinen , Robert Jarzmik , Alexandre Belloni , Julia Lawall , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Boris Brezillon Subject: [PATCH v4 06/24] pwm: introduce default period and polarity concepts Date: Mon, 16 Nov 2015 09:56:29 +0100 Message-Id: <1447664207-24370-7-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> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2394 Lines: 69 When requested by a user, the PWM is assigned a default period and polarity extracted from the DT, the platform data or statically set by the driver. Those default values are currently stored in the period and polarity fields of the pwm_device struct, but they will be stored somewhere else once we have introduced the architecture allowing for hardware state retrieval. The pwm_set_default_polarity and pwm_set_default_period should only be used by PWM drivers or the PWM core infrastructure to specify the default period and polarity values. PWM users might call the pwm_get_default_period to query the default period value. There is currently no helper to query the default polarity, but it might be added later on if there is a need for it. Signed-off-by: Boris Brezillon Tested-by: Heiko Stuebner --- include/linux/pwm.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/pwm.h b/include/linux/pwm.h index cfc3ed4..8ba57fc 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -118,11 +118,22 @@ static inline void pwm_set_period(struct pwm_device *pwm, unsigned int period) pwm->period = period; } +static inline void pwm_set_default_period(struct pwm_device *pwm, + unsigned int period) +{ + pwm_set_period(pwm, period); +} + static inline unsigned int pwm_get_period(const struct pwm_device *pwm) { return pwm ? pwm->period : 0; } +static inline unsigned int pwm_get_default_period(const struct pwm_device *pwm) +{ + return pwm_get_period(pwm); +} + static inline void pwm_set_duty_cycle(struct pwm_device *pwm, unsigned int duty) { if (pwm) @@ -139,6 +150,12 @@ static inline unsigned int pwm_get_duty_cycle(const struct pwm_device *pwm) */ int pwm_set_polarity(struct pwm_device *pwm, enum pwm_polarity polarity); +static inline void pwm_set_default_polarity(struct pwm_device *pwm, + enum pwm_polarity polarity) +{ + pwm_set_polarity(pwm, polarity); +} + static inline enum pwm_polarity pwm_get_polarity(const struct pwm_device *pwm) { return pwm ? pwm->polarity : PWM_POLARITY_NORMAL; -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/