From patchwork Mon Jul 20 15:32:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris BREZILLON X-Patchwork-Id: 6828961 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 8C5759F358 for ; Mon, 20 Jul 2015 15:34:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5E3CC20451 for ; Mon, 20 Jul 2015 15:34:39 +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 DBFBF205E9 for ; Mon, 20 Jul 2015 15:34:33 +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 1ZHD5N-0005q5-7X; Mon, 20 Jul 2015 15:34:33 +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 1ZHD3n-0004aT-9x; Mon, 20 Jul 2015 15:32:57 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id 816A73D4; Mon, 20 Jul 2015 17:32:19 +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.4 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-56-159.w82-125.abo.wanadoo.fr [82.125.234.159]) by mail.free-electrons.com (Postfix) with ESMTPSA id A18323D4; Mon, 20 Jul 2015 17:32:18 +0200 (CEST) From: Boris Brezillon To: Thierry Reding , linux-pwm@vger.kernel.org Subject: [PATCH v2 05/10] pwm: declare a default PWM state Date: Mon, 20 Jul 2015 17:32:02 +0200 Message-Id: <1437406327-6207-6-git-send-email-boris.brezillon@free-electrons.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1437406327-6207-1-git-send-email-boris.brezillon@free-electrons.com> References: <1437406327-6207-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-20150720_083255_552787_D152D882 X-CRM114-Status: GOOD ( 13.07 ) X-Spam-Score: -3.8 (---) 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: Boris Brezillon , linux-fbdev@vger.kernel.org, Heiko Stuebner , Jingoo Han , Tomi Valkeinen , Bryan Wu , linux-kernel@vger.kernel.org, Liam Girdwood , linux-rockchip@lists.infradead.org, Mark Brown , Richard Purdie , linux-arm-kernel@lists.infradead.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Jean-Christophe Plagniol-Villard , Maxime Ripard , Doug Anderson , Lee Jones , Jacek Anaszewski , linux-leds@vger.kernel.org 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 Prepare the addition of the PWM initial state retrieval by adding a default state where all the parameters retrieved from DT, platform data or statically forced by the hardware will be stored. Once done we will be able to store the initial state in the ->state field without risking to loose the default parameters. Update the pwm_set/get_default_xxx helpers accordingly. Signed-off-by: Boris Brezillon --- include/linux/pwm.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/linux/pwm.h b/include/linux/pwm.h index f4bc034..1e6e9d1 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -101,6 +101,7 @@ struct pwm_device { void *chip_data; struct pwm_state state; + struct pwm_state default_state; }; static inline bool pwm_is_enabled(const struct pwm_device *pwm) @@ -117,7 +118,8 @@ static inline void pwm_set_period(struct pwm_device *pwm, unsigned int period) static inline void pwm_set_default_period(struct pwm_device *pwm, unsigned int period) { - pwm_set_period(pwm, period); + if (pwm) + pwm->default_state.period = period; } static inline unsigned int pwm_get_period(const struct pwm_device *pwm) @@ -127,7 +129,7 @@ static inline unsigned int pwm_get_period(const struct pwm_device *pwm) static inline unsigned int pwm_get_default_period(const struct pwm_device *pwm) { - return pwm_get_period(pwm); + return pwm ? pwm->default_state.period : 0; } static inline void pwm_set_duty_cycle(struct pwm_device *pwm, unsigned int duty) @@ -149,7 +151,8 @@ 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); + if (pwm) + pwm->default_state.polarity = polarity; } static inline enum pwm_polarity pwm_get_polarity(const struct pwm_device *pwm)