All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pwm: rockchip: simplify rockchip_pwm_get_state()
@ 2019-09-19  9:17 ` Rasmus Villemoes
  0 siblings, 0 replies; 12+ messages in thread
From: Rasmus Villemoes @ 2019-09-19  9:17 UTC (permalink / raw)
  To: Thierry Reding, Heiko Stuebner
  Cc: David Wu, Rasmus Villemoes, linux-pwm, linux-arm-kernel,
	linux-rockchip, linux-kernel

The way state->enabled is computed is rather convoluted and hard to
read - both branches of the if() actually do the exact same thing. So
remove the if(), and further simplify "<boolean condition> ? true :
false" to "<boolean condition>".

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
I stumbled on this while trying to understand how the pwm subsystem
works. This patch is a semantic no-op, but it's also possible that,
say, the first branch simply contains a "double negative" so either
the != should be == or the "false : true" should be "true : false".

 drivers/pwm/pwm-rockchip.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c
index 51b96cb7dd25..54c6399e3f00 100644
--- a/drivers/pwm/pwm-rockchip.c
+++ b/drivers/pwm/pwm-rockchip.c
@@ -83,12 +83,7 @@ static void rockchip_pwm_get_state(struct pwm_chip *chip,
 	state->duty_cycle =  DIV_ROUND_CLOSEST_ULL(tmp, clk_rate);
 
 	val = readl_relaxed(pc->base + pc->data->regs.ctrl);
-	if (pc->data->supports_polarity)
-		state->enabled = ((val & enable_conf) != enable_conf) ?
-				 false : true;
-	else
-		state->enabled = ((val & enable_conf) == enable_conf) ?
-				 true : false;
+	state->enabled = ((val & enable_conf) == enable_conf);
 
 	if (pc->data->supports_polarity) {
 		if (!(val & PWM_DUTY_POSITIVE))
-- 
2.20.1


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

end of thread, other threads:[~2020-06-03  3:18 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-19  9:17 [PATCH] pwm: rockchip: simplify rockchip_pwm_get_state() Rasmus Villemoes
2019-09-19  9:17 ` Rasmus Villemoes
2019-09-19  9:17 ` Rasmus Villemoes
2019-09-19 11:11 ` oUwe Kleine-König
2019-09-19 11:11   ` oUwe Kleine-König
2020-05-23 20:01   ` Uwe Kleine-König
2020-05-23 20:01     ` Uwe Kleine-König
2020-05-23 20:01     ` Uwe Kleine-König
2020-06-02 12:39 ` Thierry Reding
2020-06-02 12:39   ` Thierry Reding
2020-06-03  3:10   ` David Wu
2020-06-03  3:10     ` David Wu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.