linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] pwm: Add new helper to initialize a pwm_state variable with defaults
@ 2018-10-26 18:41 Uwe Kleine-König
  2018-10-26 18:41 ` [PATCH 2/4] ARM: S3C24XX: rx1950: make use of atomic PWM API Uwe Kleine-König
                   ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2018-10-26 18:41 UTC (permalink / raw)
  To: linux-arm-kernel

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 <u.kleine-koenig@pengutronix.de>
---
 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);
 }
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2018-11-16 10:24 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-26 18:41 [PATCH 1/4] pwm: Add new helper to initialize a pwm_state variable with defaults Uwe Kleine-König
2018-10-26 18:41 ` [PATCH 2/4] ARM: S3C24XX: rx1950: make use of atomic PWM API Uwe Kleine-König
2018-10-29 10:46   ` Krzysztof Kozlowski
2018-11-14  9:15     ` Uwe Kleine-König
2018-11-14 12:08   ` Thierry Reding
2018-11-15  8:58     ` Uwe Kleine-König
2018-11-15 16:15       ` Thierry Reding
2018-11-15 21:00         ` Uwe Kleine-König
2018-10-26 18:41 ` [PATCH 3/4] bus: ts-nbus: convert to " Uwe Kleine-König
2018-11-14 12:15   ` Thierry Reding
2018-10-26 18:41 ` [PATCH 4/4] bus: ts-nbus: weaken driver dependency to allow broader compile testing Uwe Kleine-König
2018-11-14 12:18   ` Thierry Reding
2018-10-29 11:33 ` [PATCH 1/4] pwm: Add new helper to initialize a pwm_state variable with defaults Thierry Reding
2018-11-03 14:25   ` Uwe Kleine-König
2018-11-08 15:13     ` Uwe Kleine-König
2018-11-14 12:32 ` Thierry Reding
2018-11-15  9:16   ` Uwe Kleine-König
2018-11-15 16:21     ` Thierry Reding
2018-11-15 21:05       ` Uwe Kleine-König
2018-11-16 10:24         ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).