Skip to content

Commit

Permalink
pwm: rockchip: Simplify rockchip_pwm_get_state()
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
  • Loading branch information
Rasmus Villemoes authored and Thierry Reding committed Jun 2, 2020
1 parent ca162ce commit cad0f29
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions drivers/pwm/pwm-rockchip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 && !(val & PWM_DUTY_POSITIVE))
state->polarity = PWM_POLARITY_INVERSED;
Expand Down

0 comments on commit cad0f29

Please sign in to comment.