From patchwork Fri Oct 26 18:41:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 10657735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5BC69109C for ; Fri, 26 Oct 2018 18:45:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F9CD281C3 for ; Fri, 26 Oct 2018 18:45:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 428052CA5C; Fri, 26 Oct 2018 18:45:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B14A6281C3 for ; Fri, 26 Oct 2018 18:45:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=lilFNUVQZ5k+PU4kRJTSyVRTr6LFcmRy54Dm8xnC49c=; b=uaPFMWoEoPjBI7 7Wsw9dMp9ykNmGzVumFZNg4keCyKxj2e6rWnHkMRW3JGKtfGllgrTMHDYTzuOr39gXlvWO/3cL3ZQ q7hhzApkKi9CuUDtyY1PXd1kP4Rp/KPAT9KK+UT50aXFYm4j+JvoZ732gzJoGMkJWhP14kEIu5ljx 1D0Qsb8/q4u/HOs6Hv9pvGDG6tVVFucCTh+zoDO+y+Ys9fxqSEb30Mct3QDY54u/VH4z0kUEEkRWp AHaQrr9hKEfSSfW12Il32TPw3C3SHVSo3KGSgEt0N5ZpXvOZ9RYxdZKGYRrZsqDcN0lmazzOov1LU 3s/1eQud/PWnGh8wfbKQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gG76k-00020c-7k; Fri, 26 Oct 2018 18:45:18 +0000 Received: from antares.kleine-koenig.org ([94.130.110.236]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gG76E-0001M9-65 for linux-arm-kernel@lists.infradead.org; Fri, 26 Oct 2018 18:44:53 +0000 Received: by antares.kleine-koenig.org (Postfix, from userid 1000) id 18D52434233; Fri, 26 Oct 2018 20:44:17 +0200 (CEST) From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Thierry Reding Subject: [PATCH 1/4] pwm: Add new helper to initialize a pwm_state variable with defaults Date: Fri, 26 Oct 2018 20:41:55 +0200 Message-Id: <20181026184157.16371-1-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181026_114446_425625_407BF9F3 X-CRM114-Status: GOOD ( 10.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-pwm@vger.kernel.org, Sebastien Bourdelin , Krzysztof Kozlowski , kernel@pengutronix.de Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This helps to convert drivers from the legacy API to pwm_apply_state without having to make the aware of the configured polarity (and in some cases even period). Signed-off-by: Uwe Kleine-König --- include/linux/pwm.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/include/linux/pwm.h b/include/linux/pwm.h index d5199b507d79..017d1e13e29d 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -522,6 +522,15 @@ static inline void devm_pwm_put(struct device *dev, struct pwm_device *pwm) } #endif +static inline void pwm_get_state_default(const struct pwm_device *pwm, + struct pwm_state *state) +{ + state->period = pwm->args.period; + state->duty_cycle = 0; + state->polarity = pwm->args.polarity; + state->enabled = false; +} + static inline void pwm_apply_args(struct pwm_device *pwm) { struct pwm_state state = { }; @@ -547,9 +556,7 @@ static inline void pwm_apply_args(struct pwm_device *pwm) * pwm_apply_args(). */ - state.enabled = false; - state.polarity = pwm->args.polarity; - state.period = pwm->args.period; + pwm_get_state_default(pwm, &state); pwm_apply_state(pwm, &state); }