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: 989744 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uaPFMWoE"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42hXxb0Xtyz9sCW for ; Sat, 27 Oct 2018 05:45:39 +1100 (AEDT) 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 1gG76s-00020c-RA; Fri, 26 Oct 2018 18:45:27 +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-Spam-Score: 0.2 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [94.130.110.236 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list 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+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org 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); }